cuda.bindings._v2.driver.launch_cooperative_kernel#

cuda.bindings._v2.driver.launch_cooperative_kernel(
intptr_t f,
unsigned int grid_dim_x,
unsigned int grid_dim_y,
unsigned int grid_dim_z,
unsigned int block_dim_x,
unsigned int block_dim_y,
unsigned int block_dim_z,
unsigned int shared_mem_bytes,
intptr_t h_stream,
kernel_params,
)#

Launches a CUDA function CUfunction or a CUDA kernel CUkernel where thread blocks can cooperate and synchronize as they execute.

Invokes the function CUfunction or the kernel CUkernel f on a grid_dim_x x grid_dim_y x grid_dim_z grid of blocks. Each block contains block_dim_x x block_dim_y x block_dim_z threads. shared_mem_bytes sets the amount of dynamic shared memory that will be available to each thread block. The device on which this kernel is invoked must have a non-zero value for the device attribute CU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH. The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned by cuOccupancyMaxActiveBlocksPerMultiprocessor (or cuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attribute CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT. The kernel cannot make use of CUDA dynamic parallelism. Kernel parameters must be specified via kernel_params. If f has N parameters, then kernel_params needs to be an array of N pointers. Each of kernel_params[0] through kernel_params[N-1] must point to a region of memory from which the actual kernel parameter will be copied. The number of kernel parameters and their offsets and sizes do not need to be specified as that information is retrieved directly from the kernel’s image. Calling launch_cooperative_kernel() sets persistent function state that is the same as function state set through cuLaunchKernel API. When the kernel f is launched via launch_cooperative_kernel(), the previous block shape, shared size and parameter info associated with f is overwritten. Note that to use launch_cooperative_kernel(), the kernel f must either have been compiled with toolchain version 3.2 or later so that it will contain kernel parameter information, or have no kernel parameters. If either of these conditions is not met, then launch_cooperative_kernel() will return CUDA_ERROR_INVALID_IMAGE. Note that the API can also be used to launch context-less kernel CUkernel by querying the handle using library_get_kernel() and then passing it to the API by casting to CUfunction. Here, the context to launch the kernel on will either be taken from the specified stream h_stream or the current context in case of NULL stream.

Parameters:
  • f (intptr_t) – Function CUfunction or Kernel CUkernel to launch.

  • grid_dim_x (unsigned int) – Width of grid in blocks.

  • grid_dim_y (unsigned int) – Height of grid in blocks.

  • grid_dim_z (unsigned int) – Depth of grid in blocks.

  • block_dim_x (unsigned int) – X dimension of each thread block.

  • block_dim_y (unsigned int) – Y dimension of each thread block.

  • block_dim_z (unsigned int) – Z dimension of each thread block.

  • shared_mem_bytes (unsigned int) – Dynamic shared-memory size per thread block in bytes.

  • h_stream (intptr_t) – Stream identifier.

  • kernel_params (object) – Array of pointers to kernel parameters.

See also

cuLaunchCooperativeKernel