Skip to main content

cudaDeviceSynchronize

Function cudaDeviceSynchronize 

Source
pub unsafe extern "C" fn cudaDeviceSynchronize() -> cudaError_t
Expand description

Wait for compute device to finish.

Blocks until the device has completed all preceding requested tasks. cudaDeviceSynchronize returns an error if one of the preceding tasks has failed. If the cudaDeviceScheduleBlockingSync flag was set for this device, the host thread will block until the device has finished its work.

Note: Use of cudaDeviceSynchronize in device code was deprecated in CUDA 11.6 and removed for compute_90+ compilation. For compute capability < 9.0, compile-time opt-in by specifying -D CUDA_FORCE_CDP1_IF_SUPPORTED is required to continue using cudaDeviceSynchronize in device code for now. Note that this is different from host-side cudaDeviceSynchronize, which is still supported.

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.

ยงReturn value

See also: cudaDeviceReset, cuCtxSynchronize.