-
Notifications
You must be signed in to change notification settings - Fork 317
cuda.core: add LaunchConfig.programmatic_stream_serialization for programmatic dependent launch #2456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cuda.core: add LaunchConfig.programmatic_stream_serialization for programmatic dependent launch #2456
Changes from all commits
0576da3
436f34b
cc85a50
d3b3b25
717fe7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,14 @@ from cuda.core._utils.cuda_utils import ( | |
| driver, | ||
| ) | ||
|
|
||
| _LAUNCH_CONFIG_ATTRS = ('grid', 'cluster', 'block', 'shmem_size', 'is_cooperative') | ||
| _LAUNCH_CONFIG_ATTRS = ( | ||
| 'grid', | ||
| 'cluster', | ||
| 'block', | ||
| 'shmem_size', | ||
| 'is_cooperative', | ||
| 'programmatic_stream_serialization', | ||
| ) | ||
|
|
||
| __all__ = ['LaunchConfig'] | ||
|
|
||
|
|
@@ -48,6 +55,10 @@ cdef class LaunchConfig: | |
| (Default to size 0) | ||
| is_cooperative : bool, optional | ||
| Whether this config can be used to launch a cooperative kernel. | ||
| programmatic_stream_serialization : bool, optional | ||
| Whether to allow programmatic stream serialization (PDL). When True, | ||
| the kernel may overlap with a previous kernel in the same stream that | ||
| signals completion via programmatic means. | ||
| """ | ||
|
|
||
| # TODO: expand LaunchConfig to include other attributes | ||
|
|
@@ -60,6 +71,7 @@ cdef class LaunchConfig: | |
| block: int | tuple[int, ...] | None = None, | ||
| shmem_size: int | None = None, | ||
| is_cooperative: bool = False, | ||
| programmatic_stream_serialization: bool = False, | ||
| ) -> None: | ||
| """Initialize LaunchConfig with validation. | ||
|
|
||
|
|
@@ -75,6 +87,8 @@ cdef class LaunchConfig: | |
| Dynamic shared memory size in bytes (default: 0) | ||
| is_cooperative : bool, optional | ||
| Whether to launch as cooperative kernel (default: False) | ||
| programmatic_stream_serialization : bool, optional | ||
| Whether to allow programmatic stream serialization / PDL (default: False) | ||
| """ | ||
| # Convert and validate grid and block dimensions | ||
| self.grid = cast_to_3_tuple("LaunchConfig.grid", grid) | ||
|
|
@@ -101,6 +115,7 @@ cdef class LaunchConfig: | |
| self.shmem_size = shmem_size | ||
|
|
||
| self.is_cooperative = is_cooperative | ||
| self.programmatic_stream_serialization = programmatic_stream_serialization | ||
|
|
||
| if self.is_cooperative and not Device().properties.cooperative_launch: | ||
| raise CUDAError("cooperative kernels are not supported on this device") | ||
|
|
@@ -149,6 +164,11 @@ cdef class LaunchConfig: | |
| attr.value.cooperative = 1 | ||
| self._attrs.push_back(attr) | ||
|
|
||
| if self.programmatic_stream_serialization: | ||
| attr.id = cydriver.CUlaunchAttributeID.CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION | ||
| attr.value.programmaticStreamSerializationAllowed = 1 | ||
| self._attrs.push_back(attr) | ||
|
|
||
| drv_cfg.numAttrs = self._attrs.size() | ||
| drv_cfg.attrs = self._attrs.data() | ||
|
|
||
|
|
@@ -204,6 +224,12 @@ cpdef object _to_native_launch_config(LaunchConfig config): | |
| attr.value.cooperative = 1 | ||
| attrs.append(attr) | ||
|
|
||
| if config.programmatic_stream_serialization: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non blocking Q: I see from the comment to this function "once all modules are cythonized, this function can be dropped in favor of the cdef method above". Are all modules cythonized?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no answer. this cpdef function might still be needed for tests / non-Cython callers.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checked codebase. This function is used in |
||
| attr = driver.CUlaunchAttribute() | ||
| attr.id = driver.CUlaunchAttributeID.CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION | ||
| attr.value.programmaticStreamSerializationAllowed = 1 | ||
| attrs.append(attr) | ||
|
|
||
| drv_cfg.numAttrs = len(attrs) | ||
| drv_cfg.attrs = attrs | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.