Skip to content

Commit

Permalink
Fixes #305, #306, regards #304.
Browse files Browse the repository at this point in the history
* Now using CUDA driver API error enum values wherever possible.
* Added all missing CUDA driver and runtime API error enum values to our own named error enum.
* Renamed some named errors for clarity, based on their Doxygen comment in the CUDA headers.
* Now (apparently) fully-compatible with CUDA 9.2.
  • Loading branch information
eyalroz committed Mar 24, 2022
1 parent 100c7bf commit 6dde596
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 91 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Detailed Doxygen-genereated documentation is [available](https://codedocs.xyz/ey

## Requirements

- CUDA: v11.x or later recommended, v10.x or later supported. Earlier versions are semi-supported.
- CUDA: v11.x or later recommended, v9.2 or later supported. Earlier versions are semi-supported.

Remember that an NVIDIA driver compatible with your CUDA version also needs to be installed. Typically, this can be the one bundled in your CUDA distribution itself.

Expand Down
2 changes: 1 addition & 1 deletion examples/by_runtime_api_module/event_management.cu
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int main(int argc, char **argv)

} catch(cuda::runtime_error& e) {
(void) e; // This avoids a spurious warning in MSVC 16.11
assert(e.code() == cuda::status::not_ready);
assert(e.code() == cuda::status::async_operations_not_yet_completed);
}
event_2.synchronize();
report_occurrence("After synchronizing on event_2, but before synchronizing on the stream", event_1, event_2);
Expand Down
238 changes: 151 additions & 87 deletions src/cuda/api/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,93 +35,157 @@ namespace status {
* @note unfortunately, this enum can't inherit from @ref cuda::status_t
*/
enum named_t : ::std::underlying_type<status_t>::type {
success = cudaSuccess,
missing_configuration = cudaErrorMissingConfiguration,
memory_allocation_failure = cudaErrorMemoryAllocation, // == CUDA_ERROR_OUT_OF_MEMORY
initialization_error = cudaErrorInitializationError, // == CUDA_ERROR_NOT_INITIALIZED
already_deinitialized = cudaErrorCudartUnloading, // == CUDA_ERROR_DEINITIALIZED
profiler_disabled = cudaErrorProfilerDisabled,
profiler_not_initialized = cudaErrorProfilerNotInitialized,
profiler_already_started = cudaErrorProfilerAlreadyStarted,
profiler_already_stopped = cudaErrorProfilerAlreadyStopped,
launch_failure = cudaErrorLaunchFailure,
prior_launch_failure = cudaErrorPriorLaunchFailure,
launch_timeout = cudaErrorLaunchTimeout,
launch_out_of_resources = cudaErrorLaunchOutOfResources,
invalid_kernel_function = cudaErrorInvalidDeviceFunction,
invalid_configuration = cudaErrorInvalidConfiguration,
invalid_device = cudaErrorInvalidDevice,
invalid_value = cudaErrorInvalidValue,
invalid_pitch_value = cudaErrorInvalidPitchValue,
invalid_symbol = cudaErrorInvalidSymbol,
map_buffer_object_failed = cudaErrorMapBufferObjectFailed,
unmap_buffer_object_failed = cudaErrorUnmapBufferObjectFailed,
invalid_host_pointer = cudaErrorInvalidHostPointer,
invalid_device_pointer = cudaErrorInvalidDevicePointer,
invalid_texture = cudaErrorInvalidTexture,
invalid_texture_binding = cudaErrorInvalidTextureBinding,
invalid_channel_descriptor = cudaErrorInvalidChannelDescriptor,
invalid_memcpy_direction = cudaErrorInvalidMemcpyDirection,
address_of_constant = cudaErrorAddressOfConstant,
texture_fetch_failed = cudaErrorTextureFetchFailed,
texture_not_bound = cudaErrorTextureNotBound,
synchronization_error = cudaErrorSynchronizationError,
invalid_filter_setting = cudaErrorInvalidFilterSetting,
invalid_norm_setting = cudaErrorInvalidNormSetting,
mixed_device_execution = cudaErrorMixedDeviceExecution,
unknown = cudaErrorUnknown,
not_yet_implemented = cudaErrorNotYetImplemented,
memory_value_too_large = cudaErrorMemoryValueTooLarge,
invalid_resource_handle = cudaErrorInvalidResourceHandle,
not_ready = cudaErrorNotReady,
insufficient_driver = cudaErrorInsufficientDriver,
set_on_active_process = cudaErrorSetOnActiveProcess,
invalid_surface = cudaErrorInvalidSurface,
#if CUDA_VERSION < 10000
no_device = CUDA_ERROR_NO_DEVICE,
#else
no_device = cudaErrorNoDevice, // == 100
#endif // CUDA_VERSION < 10000
ecc_uncorrectable = cudaErrorECCUncorrectable,
shared_object_symbol_not_found = cudaErrorSharedObjectSymbolNotFound,
shared_object_init_failed = cudaErrorSharedObjectInitFailed,
unsupported_limit = cudaErrorUnsupportedLimit,
duplicate_variable_name = cudaErrorDuplicateVariableName,
duplicate_texture_name = cudaErrorDuplicateTextureName,
duplicate_surface_name = cudaErrorDuplicateSurfaceName,
devices_unavailable = cudaErrorDevicesUnavailable,
invalid_kernel_image = cudaErrorInvalidKernelImage,
no_kernel_image_for_device = cudaErrorNoKernelImageForDevice,
incompatible_driver_context = cudaErrorIncompatibleDriverContext,
invalid_context = CUDA_ERROR_INVALID_CONTEXT,
context_already_current = CUDA_ERROR_CONTEXT_ALREADY_CURRENT,
peer_access_already_enabled = cudaErrorPeerAccessAlreadyEnabled,
peer_access_not_enabled = cudaErrorPeerAccessNotEnabled,
device_already_in_use = cudaErrorDeviceAlreadyInUse,
assert = cudaErrorAssert,
too_many_peers = cudaErrorTooManyPeers,
host_memory_already_registered = cudaErrorHostMemoryAlreadyRegistered,
host_memory_not_registered = cudaErrorHostMemoryNotRegistered,
operating_system = cudaErrorOperatingSystem,
peer_access_unsupported = cudaErrorPeerAccessUnsupported,
launch_max_depth_exceeded = cudaErrorLaunchMaxDepthExceeded,
launch_file_scoped_tex = cudaErrorLaunchFileScopedTex,
launch_file_scoped_surf = cudaErrorLaunchFileScopedSurf,
sync_depth_exceeded = cudaErrorSyncDepthExceeded,
launch_pending_count_exceeded = cudaErrorLaunchPendingCountExceeded,
not_permitted = cudaErrorNotPermitted,
not_supported = cudaErrorNotSupported,
hardware_stack_error = cudaErrorHardwareStackError,
illegal_instruction = cudaErrorIllegalInstruction,
misaligned_address = cudaErrorMisalignedAddress,
invalid_address_space = cudaErrorInvalidAddressSpace,
invalid_pc = cudaErrorInvalidPc,
illegal_address = cudaErrorIllegalAddress,
invalid_ptx = cudaErrorInvalidPtx,
invalid_graphics_context = cudaErrorInvalidGraphicsContext,
nvlink_uncorrectable = cudaErrorNvlinkUncorrectable,
startup_failure = cudaErrorStartupFailure,
api_failure_base = cudaErrorApiFailureBase
success = CUDA_SUCCESS,
memory_allocation_failure = CUDA_ERROR_OUT_OF_MEMORY, // corresponds to cudaErrorMemoryAllocation
initialization_error = CUDA_ERROR_NOT_INITIALIZED, // corresponds to cudaErrorInitializationError
already_deinitialized = CUDA_ERROR_DEINITIALIZED, // corresponds to cudaErrorCudartUnloading
profiler_disabled = CUDA_ERROR_PROFILER_DISABLED,
#if CUDA_VERSION >= 10100
profiler_not_initialized = CUDA_ERROR_PROFILER_NOT_INITIALIZED,
#endif
profiler_already_started = CUDA_ERROR_PROFILER_ALREADY_STARTED,
profiler_already_stopped = CUDA_ERROR_PROFILER_ALREADY_STOPPED,
#if CUDA_VERSION >= 11000
stub_library = CUDA_ERROR_STUB_LIBRARY,
device_not_licensed = CUDA_ERROR_DEVICE_NOT_LICENSED,
#endif
prior_launch_failure = cudaErrorPriorLaunchFailure,
launch_timeout = CUDA_ERROR_LAUNCH_TIMEOUT,
launch_out_of_resources = CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
kernel_launch_incompatible_texturing_mode = CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
invalid_kernel_function = cudaErrorInvalidDeviceFunction,
invalid_configuration = cudaErrorInvalidConfiguration,
invalid_device = CUDA_ERROR_INVALID_DEVICE,
invalid_value = CUDA_ERROR_INVALID_VALUE,
invalid_pitch_value = cudaErrorInvalidPitchValue,
invalid_symbol = cudaErrorInvalidSymbol,
map_buffer_object_failed = CUDA_ERROR_MAP_FAILED, // corresponds to cudaErrorMapBufferObjectFailed,
unmap_buffer_object_failed = CUDA_ERROR_UNMAP_FAILED, // corresponds to cudaErrorUnmapBufferObjectFailed,
array_still_mapped = CUDA_ERROR_ARRAY_IS_MAPPED,
resource_already_mapped = CUDA_ERROR_ALREADY_MAPPED,
resource_already_acquired = CUDA_ERROR_ALREADY_ACQUIRED,
resource_not_mapped = CUDA_ERROR_NOT_MAPPED,
not_mapped_as_pointer = CUDA_ERROR_NOT_MAPPED_AS_POINTER,
not_mapped_as_array = CUDA_ERROR_NOT_MAPPED_AS_ARRAY,
invalid_host_pointer = cudaErrorInvalidHostPointer,
invalid_device_pointer = cudaErrorInvalidDevicePointer,
invalid_texture = cudaErrorInvalidTexture,
invalid_texture_binding = cudaErrorInvalidTextureBinding,
invalid_channel_descriptor = cudaErrorInvalidChannelDescriptor,
invalid_memcpy_direction = cudaErrorInvalidMemcpyDirection,
address_of_constant = cudaErrorAddressOfConstant,
texture_fetch_failed = cudaErrorTextureFetchFailed,
texture_not_bound = cudaErrorTextureNotBound,
synchronization_error = cudaErrorSynchronizationError,
invalid_filter_setting = cudaErrorInvalidFilterSetting,
invalid_norm_setting = cudaErrorInvalidNormSetting,
mixed_device_execution = cudaErrorMixedDeviceExecution,
unknown = CUDA_ERROR_UNKNOWN,
not_yet_implemented = cudaErrorNotYetImplemented,
memory_value_too_large = cudaErrorMemoryValueTooLarge,
invalid_resource_handle = CUDA_ERROR_INVALID_HANDLE,
#if CUDA_VERSION >= 10000
resource_not_in_valid_state = CUDA_ERROR_ILLEGAL_STATE,
#endif
async_operations_not_yet_completed = CUDA_ERROR_NOT_READY,
insufficient_driver = cudaErrorInsufficientDriver,
set_on_active_process = cudaErrorSetOnActiveProcess,
invalid_surface = cudaErrorInvalidSurface,
symbol_not_found = CUDA_ERROR_NOT_FOUND, // corresponds to cudaErrorSymbolNotFound
no_device = CUDA_ERROR_NO_DEVICE,
ecc_uncorrectable = CUDA_ERROR_ECC_UNCORRECTABLE,
shared_object_symbol_not_found = CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
invalid_source = CUDA_ERROR_INVALID_SOURCE,
file_not_found = CUDA_ERROR_FILE_NOT_FOUND,
shared_object_init_failed = CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
jit_compiler_not_found = CUDA_ERROR_JIT_COMPILER_NOT_FOUND,
#if CUDA_VERSION >= 11000
unsupported_ptx_version = CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
jit_compilation_disabled = CUDA_ERROR_JIT_COMPILATION_DISABLED,
#endif
#if CUDA_VERSION >= 11400
unsupported_exec_affinity = CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY,
#endif
unsupported_limit = CUDA_ERROR_UNSUPPORTED_LIMIT,
duplicate_variable_name = cudaErrorDuplicateVariableName,
duplicate_texture_name = cudaErrorDuplicateTextureName,
duplicate_surface_name = cudaErrorDuplicateSurfaceName,
devices_unavailable = cudaErrorDevicesUnavailable,
invalid_kernel_image = CUDA_ERROR_INVALID_IMAGE, // corresponds to cudaErrorInvalidKernelImage,
no_kernel_image_for_device = CUDA_ERROR_NO_BINARY_FOR_GPU, // corresponds to cudaErrorNoKernelImageForDevice,
incompatible_driver_context = cudaErrorIncompatibleDriverContext,
missing_configuration = cudaErrorMissingConfiguration,
invalid_context = CUDA_ERROR_INVALID_CONTEXT,
context_already_current = CUDA_ERROR_CONTEXT_ALREADY_CURRENT,
context_already_in_use = CUDA_ERROR_CONTEXT_ALREADY_IN_USE,
peer_access_already_enabled = CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED,
peer_access_not_enabled = CUDA_ERROR_PEER_ACCESS_NOT_ENABLED,
device_already_in_use = cudaErrorDeviceAlreadyInUse,
primary_context_already_active = CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE,
context_is_destroyed = CUDA_ERROR_CONTEXT_IS_DESTROYED,
primary_context_is_uninitialized = CUDA_ERROR_CONTEXT_IS_DESTROYED, // an alias!
#if CUDA_VERSION >= 10200
device_uninitialized = cudaErrorDeviceUninitialized,
#endif
assert = CUDA_ERROR_ASSERT,
too_many_peers = CUDA_ERROR_TOO_MANY_PEERS,
host_memory_already_registered = CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED,
host_memory_not_registered = CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED,
operating_system = CUDA_ERROR_OPERATING_SYSTEM,
peer_access_unsupported = CUDA_ERROR_PEER_ACCESS_UNSUPPORTED,
launch_max_depth_exceeded = cudaErrorLaunchMaxDepthExceeded,
launch_file_scoped_tex = cudaErrorLaunchFileScopedTex,
launch_file_scoped_surf = cudaErrorLaunchFileScopedSurf,
sync_depth_exceeded = cudaErrorSyncDepthExceeded,
launch_pending_count_exceeded = cudaErrorLaunchPendingCountExceeded,
invalid_device_function = cudaErrorInvalidDeviceFunction,
not_permitted = CUDA_ERROR_NOT_PERMITTED,
not_supported = CUDA_ERROR_NOT_SUPPORTED,
hardware_stack_error = CUDA_ERROR_HARDWARE_STACK_ERROR,
illegal_instruction = CUDA_ERROR_ILLEGAL_INSTRUCTION,
misaligned_address = CUDA_ERROR_MISALIGNED_ADDRESS,
exception_during_kernel_execution = CUDA_ERROR_LAUNCH_FAILED,
cooperative_launch_too_large = CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE,
invalid_address_space = CUDA_ERROR_INVALID_ADDRESS_SPACE,
invalid_pc = CUDA_ERROR_INVALID_PC,
illegal_address = CUDA_ERROR_ILLEGAL_ADDRESS,
invalid_ptx = CUDA_ERROR_INVALID_PTX,
invalid_graphics_context = CUDA_ERROR_INVALID_GRAPHICS_CONTEXT,
nvlink_uncorrectable = CUDA_ERROR_NVLINK_UNCORRECTABLE,
startup_failure = cudaErrorStartupFailure,
api_failure_base = cudaErrorApiFailureBase,
#if CUDA_VERSION >= 10000
system_not_ready = CUDA_ERROR_SYSTEM_NOT_READY,
#endif
#if CUDA_VERSION >= 10100
system_driver_mismatch = CUDA_ERROR_SYSTEM_DRIVER_MISMATCH,
not_supported_on_device = CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE,
#endif
#if CUDA_VERSION >= 10000
stream_capture_unsupported = CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED,
stream_capture_invalidated = CUDA_ERROR_STREAM_CAPTURE_INVALIDATED,
stream_capture_merge = CUDA_ERROR_STREAM_CAPTURE_MERGE,
stream_capture_unmatched = CUDA_ERROR_STREAM_CAPTURE_UNMATCHED,
stream_capture_unjoined = CUDA_ERROR_STREAM_CAPTURE_UNJOINED,
stream_capture_isolation = CUDA_ERROR_STREAM_CAPTURE_ISOLATION,
stream_capture_disallowed_implicit_dependency = CUDA_ERROR_STREAM_CAPTURE_IMPLICIT,
not_permitted_on_captured_event = CUDA_ERROR_CAPTURED_EVENT,
#endif
#if CUDA_VERSION >= 10100
stream_capture_wrong_thread = CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD,
#endif
#if CUDA_VERSION >= 10200
timeout_lapsed = CUDA_ERROR_TIMEOUT,
graph_update_would_violate_constraints = CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE,
#endif
#if CUDA_VERSION >= 11400
mps_connection_failed = CUDA_ERROR_MPS_CONNECTION_FAILED,
mps_rpc_failure = CUDA_ERROR_MPS_RPC_FAILURE,
mps_server_not_ready = CUDA_ERROR_MPS_SERVER_NOT_READY,
mps_max_clients_reached = CUDA_ERROR_MPS_MAX_CLIENTS_REACHED,
mps_max_connections_reached = CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED,
async_error_in_external_device = CUDA_ERROR_EXTERNAL_DEVICE,
#endif
};

///@cond
Expand Down
4 changes: 2 additions & 2 deletions src/cuda/api/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class event_t {
{
auto status = cuEventQuery(handle_);
if (status == cuda::status::success) return true;
if (status == cuda::status::not_ready) return false;
if (status == cuda::status::async_operations_not_yet_completed) return false;
throw cuda::runtime_error(status,
"Could not determine whether " + event::detail_::identify(handle_)
+ "has already occurred or not.");
+ "has already occurred or not");
}

/**
Expand Down

0 comments on commit 6dde596

Please sign in to comment.