Skip to main content

cudaGetDevice

Function cudaGetDevice 

Source
pub unsafe extern "C" fn cudaGetDevice(
    device: *mut c_int,
) -> cudaError_t
Expand description

Returns which device is currently being used.

Returns in *device the current device for the calling host thread.

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.

§Parameters

  • device: Returns the device on which the active host thread executes the device code.

§Return value

See also: cudaGetDeviceCount, cudaSetDevice, cudaGetDeviceProperties, cudaChooseDevice, cuCtxGetCurrent.