Skip to main content

cudaLaunchKernel

Function cudaLaunchKernel 

Source
pub unsafe extern "C" fn cudaLaunchKernel(
    func: *const c_void,
    gridDim: dim3,
    blockDim: dim3,
    args: *mut *mut c_void,
    sharedMem: size_t,
    stream: cudaStream_t,
) -> cudaError_t
Expand description

Launches a device function.

The function invokes kernel func on gridDim (gridDim.x ``gridDim.y ``gridDim.z) grid of blocks. Each block contains blockDim (blockDim.x ``blockDim.y ``blockDim.z) threads.

If the kernel has N parameters the args should point to array of N pointers. Each pointer, from args[0] to args[N - 1], point to the region of memory from which the actual parameter will be copied.

For templated functions, pass the function symbol as follows: func_name<template_arg_0,…,template_arg_N>

sharedMem sets the amount of dynamic shared memory that will be available to each thread block.

stream specifies a stream the invocation is associated to.

Note: This function uses standard default stream semantics.

Note that this function may also return error codes from previous, asynchronous launches.

Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.

Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.

Note: The API can also be used with a kernel cudaKernel_t by querying the handle using cudaLibraryGetKernel or cudaGetKernel and then passing it to the API by casting to void*. The symbol entryFuncAddr passed to cudaGetKernel should be a symbol that is registered with the same CUDA Runtime instance.

Note: Passing a symbol that belongs that belongs to a different runtime instance will result in undefined behavior. The only type that can be reliably passed to a different runtime instance is cudaKernel_t.

§Parameters

  • func: Device function symbol.
  • gridDim: Grid dimentions.
  • blockDim: Block dimentions.
  • args: Arguments.
  • sharedMem: Shared memory.
  • stream: Stream identifier.

§Return value

See also: (C++, API), cuLaunchKernel.