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
CUfunctionor a CUDA kernelCUkernelwhere thread blocks can cooperate and synchronize as they execute.Invokes the function
CUfunctionor the kernelCUkernelfon agrid_dim_xxgrid_dim_yxgrid_dim_zgrid of blocks. Each block containsblock_dim_xxblock_dim_yxblock_dim_zthreads.shared_mem_bytessets 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 attributeCU_DEVICE_ATTRIBUTE_COOPERATIVE_LAUNCH. The total number of blocks launched cannot exceed the maximum number of blocks per multiprocessor as returned bycuOccupancyMaxActiveBlocksPerMultiprocessor(orcuOccupancyMaxActiveBlocksPerMultiprocessorWithFlags) times the number of multiprocessors as specified by the device attributeCU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT. The kernel cannot make use of CUDA dynamic parallelism. Kernel parameters must be specified viakernel_params. Iffhas N parameters, thenkernel_paramsneeds to be an array of N pointers. Each ofkernel_params[0] throughkernel_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. Callinglaunch_cooperative_kernel()sets persistent function state that is the same as function state set throughcuLaunchKernelAPI. When the kernelfis launched vialaunch_cooperative_kernel(), the previous block shape, shared size and parameter info associated withfis overwritten. Note that to uselaunch_cooperative_kernel(), the kernelfmust 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, thenlaunch_cooperative_kernel()will returnCUDA_ERROR_INVALID_IMAGE. Note that the API can also be used to launch context-less kernelCUkernelby querying the handle usinglibrary_get_kernel()and then passing it to the API by casting toCUfunction. Here, the context to launch the kernel on will either be taken from the specified streamh_streamor the current context in case of NULL stream.- Parameters:
f (intptr_t) – Function
CUfunctionor KernelCUkernelto 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