Skip to content

Commit 397b7c7

Browse files
committed
support kernel launch with CUDA 11 driver
1 parent f1bfaf0 commit 397b7c7

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

cuda_core/cuda/core/experimental/_launcher.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
class LaunchConfig:
2020
"""
2121
"""
22+
# TODO: expand LaunchConfig to include other attributes
2223
grid: Union[tuple, int] = None
2324
block: Union[tuple, int] = None
2425
stream: Stream = None
@@ -67,24 +68,30 @@ def launch(kernel, config, *kernel_args):
6768
if not isinstance(kernel, Kernel):
6869
raise ValueError
6970
config = check_or_create_options(LaunchConfig, config, "launch config")
71+
if config.stream is None:
72+
raise CUDAError("stream cannot be None")
73+
7074
# TODO: can we ensure kernel_args is valid/safe to use here?
75+
# TODO: merge with HelperKernelParams?
76+
kernel_args = ParamHolder(kernel_args)
77+
args_ptr = kernel_args.ptr
7178

7279
driver_ver = handle_return(cuda.cuDriverGetVersion())
7380
if driver_ver >= 12000:
7481
drv_cfg = cuda.CUlaunchConfig()
7582
drv_cfg.gridDimX, drv_cfg.gridDimY, drv_cfg.gridDimZ = config.grid
7683
drv_cfg.blockDimX, drv_cfg.blockDimY, drv_cfg.blockDimZ = config.block
77-
if config.stream is None:
78-
raise CUDAError("stream cannot be None")
7984
drv_cfg.hStream = config.stream._handle
8085
drv_cfg.sharedMemBytes = config.shmem_size
81-
drv_cfg.numAttrs = 0 # FIXME
82-
83-
# TODO: merge with HelperKernelParams?
84-
kernel_args = ParamHolder(kernel_args)
85-
args_ptr = kernel_args.ptr
86-
86+
drv_cfg.numAttrs = 0 # TODO
8787
handle_return(cuda.cuLaunchKernelEx(
8888
drv_cfg, int(kernel._handle), args_ptr, 0))
8989
else:
90-
raise NotImplementedError("TODO")
90+
# TODO: check if config has any unsupported attrs
91+
handle_return(cuda.cuLaunchKernel(
92+
int(kernel._handle),
93+
*config.grid,
94+
*config.block,
95+
config.shmem_size,
96+
config.stream._handle,
97+
args_ptr, 0))

0 commit comments

Comments
 (0)