Skip to main content

cudaKernelSetAttributeForDevice

Function cudaKernelSetAttributeForDevice 

Source
pub unsafe extern "C" fn cudaKernelSetAttributeForDevice(
    kernel: cudaKernel_t,
    attr: cudaFuncAttribute,
    value: c_int,
    device: c_int,
) -> cudaError_t
Expand description

Sets information about a kernel.

This call sets the value of a specified attribute attr on the kernel kernel for the requested device device to an integer value specified by value. This function returns cudaError_t::CUDA_SUCCESS if the new value of the attribute could be successfully set. If the set fails, this call will return an error. Not all attributes can have values set. Attempting to set a value on a read-only attribute will result in an error (cudaError_t::CUDA_ERROR_INVALID_VALUE)

Note that attributes set using cudaFuncSetAttribute will override the attribute set by this API irrespective of whether the call to cudaFuncSetAttribute is made before or after this API call. Because of this and the stricter locking requirements mentioned below it is suggested that this call be used during the initialization path and not on each thread accessing kernel such as on kernel launches or on the critical path.

Valid values for attr are:

Note: The API has stricter locking requirements in comparison to its legacy counterpart cudaFuncSetAttribute due to device-wide semantics. If multiple threads are trying to set the same attribute on the same device simultaneously, the attribute setting will depend on the interleavings chosen by the OS scheduler and memory consistency.

§Parameters

  • kernel: Kernel to set attribute of.
  • attr: Attribute requested.
  • value: Value to set.
  • device: Device to set attribute of.

§Return value

See also: cudaLibraryLoadData, cudaLibraryLoadFromFile, cudaLibraryUnload, cudaLibraryGetKernel, cudaLaunchKernel, cudaFuncSetAttribute, cuKernelSetAttribute.