cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
error.hpp
Go to the documentation of this file.
1 
16 #pragma once
17 #ifndef CUDA_API_WRAPPERS_ERROR_HPP_
18 #define CUDA_API_WRAPPERS_ERROR_HPP_
19 
20 #include "types.hpp"
21 #include <cuda_runtime_api.h>
22 
23 #include <type_traits>
24 #include <string>
25 #include <stdexcept>
26 
27 namespace cuda {
28 
29 namespace status {
30 
36 enum named_t : ::std::underlying_type<status_t>::type {
37  success = CUDA_SUCCESS,
38  memory_allocation_failure = CUDA_ERROR_OUT_OF_MEMORY, // corresponds to cudaErrorMemoryAllocation
39  not_yet_initialized = CUDA_ERROR_NOT_INITIALIZED, // corresponds to cudaErrorInitializationError
40  already_deinitialized = CUDA_ERROR_DEINITIALIZED, // corresponds to cudaErrorCudartUnloading
41  profiler_disabled = CUDA_ERROR_PROFILER_DISABLED,
42 #if CUDA_VERSION >= 10100
43  profiler_not_initialized = CUDA_ERROR_PROFILER_NOT_INITIALIZED,
44 #endif
45  profiler_already_started = CUDA_ERROR_PROFILER_ALREADY_STARTED,
46  profiler_already_stopped = CUDA_ERROR_PROFILER_ALREADY_STOPPED,
47 #if CUDA_VERSION >= 11100
48  stub_library = CUDA_ERROR_STUB_LIBRARY,
49  device_not_licensed = CUDA_ERROR_DEVICE_NOT_LICENSED,
50 #endif
51  prior_launch_failure = cudaErrorPriorLaunchFailure,
52  launch_timeout = CUDA_ERROR_LAUNCH_TIMEOUT,
53  launch_out_of_resources = CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES,
54  kernel_launch_incompatible_texturing_mode = CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING,
55  invalid_kernel_function = cudaErrorInvalidDeviceFunction,
56  invalid_configuration = cudaErrorInvalidConfiguration,
57  invalid_device = CUDA_ERROR_INVALID_DEVICE,
58  invalid_value = CUDA_ERROR_INVALID_VALUE,
59  invalid_pitch_value = cudaErrorInvalidPitchValue,
60  invalid_symbol = cudaErrorInvalidSymbol,
61  map_buffer_object_failed = CUDA_ERROR_MAP_FAILED, // corresponds to cudaErrorMapBufferObjectFailed,
62  unmap_buffer_object_failed = CUDA_ERROR_UNMAP_FAILED, // corresponds to cudaErrorUnmapBufferObjectFailed,
63  array_still_mapped = CUDA_ERROR_ARRAY_IS_MAPPED,
64  resource_already_mapped = CUDA_ERROR_ALREADY_MAPPED,
65  resource_already_acquired = CUDA_ERROR_ALREADY_ACQUIRED,
66  resource_not_mapped = CUDA_ERROR_NOT_MAPPED,
67  not_mapped_as_pointer = CUDA_ERROR_NOT_MAPPED_AS_POINTER,
68  not_mapped_as_array = CUDA_ERROR_NOT_MAPPED_AS_ARRAY,
69  invalid_host_pointer = cudaErrorInvalidHostPointer,
70  invalid_device_pointer = cudaErrorInvalidDevicePointer,
71  invalid_texture = cudaErrorInvalidTexture,
72  invalid_texture_binding = cudaErrorInvalidTextureBinding,
73  invalid_channel_descriptor = cudaErrorInvalidChannelDescriptor,
74  invalid_memcpy_direction = cudaErrorInvalidMemcpyDirection,
75  address_of_constant = cudaErrorAddressOfConstant,
76  texture_fetch_failed = cudaErrorTextureFetchFailed,
77  texture_not_bound = cudaErrorTextureNotBound,
78  synchronization_error = cudaErrorSynchronizationError,
79  invalid_filter_setting = cudaErrorInvalidFilterSetting,
80  invalid_norm_setting = cudaErrorInvalidNormSetting,
81  mixed_device_execution = cudaErrorMixedDeviceExecution,
82  unknown = CUDA_ERROR_UNKNOWN,
83  not_yet_implemented = cudaErrorNotYetImplemented,
84  memory_value_too_large = cudaErrorMemoryValueTooLarge,
85  invalid_resource_handle = CUDA_ERROR_INVALID_HANDLE,
86 #if CUDA_VERSION >= 10000
87  resource_not_in_valid_state = CUDA_ERROR_ILLEGAL_STATE,
88 #endif
89  async_operations_not_yet_completed = CUDA_ERROR_NOT_READY,
90  insufficient_driver = cudaErrorInsufficientDriver,
91  set_on_active_process = cudaErrorSetOnActiveProcess,
92  invalid_surface = cudaErrorInvalidSurface,
93  symbol_not_found = CUDA_ERROR_NOT_FOUND, // corresponds to cudaErrorSymbolNotFound
94  no_device = CUDA_ERROR_NO_DEVICE,
95  ecc_uncorrectable = CUDA_ERROR_ECC_UNCORRECTABLE,
96  shared_object_symbol_not_found = CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND,
97  invalid_source = CUDA_ERROR_INVALID_SOURCE,
98  file_not_found = CUDA_ERROR_FILE_NOT_FOUND,
99  shared_object_init_failed = CUDA_ERROR_SHARED_OBJECT_INIT_FAILED,
100  jit_compiler_not_found = CUDA_ERROR_JIT_COMPILER_NOT_FOUND,
101 #if CUDA_VERSION >= 11100
102  unsupported_ptx_version = CUDA_ERROR_UNSUPPORTED_PTX_VERSION,
103 #endif
104 #if CUDA_VERSION >= 11200
105  jit_compilation_disabled = CUDA_ERROR_JIT_COMPILATION_DISABLED,
106 #endif
107 #if CUDA_VERSION >= 11400
108  unsupported_exec_affinity = CUDA_ERROR_UNSUPPORTED_EXEC_AFFINITY,
109 #endif
110  unsupported_limit = CUDA_ERROR_UNSUPPORTED_LIMIT,
111  duplicate_variable_name = cudaErrorDuplicateVariableName,
112  duplicate_texture_name = cudaErrorDuplicateTextureName,
113  duplicate_surface_name = cudaErrorDuplicateSurfaceName,
114  devices_unavailable = cudaErrorDevicesUnavailable,
115  invalid_kernel_image = CUDA_ERROR_INVALID_IMAGE, // corresponds to cudaErrorInvalidKernelImage,
116  no_kernel_image_for_device = CUDA_ERROR_NO_BINARY_FOR_GPU, // corresponds to cudaErrorNoKernelImageForDevice,
117  incompatible_driver_context = cudaErrorIncompatibleDriverContext,
118  missing_configuration = cudaErrorMissingConfiguration,
119  invalid_context = CUDA_ERROR_INVALID_CONTEXT,
120  context_already_current = CUDA_ERROR_CONTEXT_ALREADY_CURRENT,
121  context_already_in_use = CUDA_ERROR_CONTEXT_ALREADY_IN_USE,
122  peer_access_already_enabled = CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED,
123  peer_access_not_enabled = CUDA_ERROR_PEER_ACCESS_NOT_ENABLED,
124  device_already_in_use = cudaErrorDeviceAlreadyInUse,
125  primary_context_already_active = CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE,
126  context_is_destroyed = CUDA_ERROR_CONTEXT_IS_DESTROYED,
127  primary_context_is_uninitialized = CUDA_ERROR_CONTEXT_IS_DESTROYED, // an alias!
128 #if CUDA_VERSION >= 10200
129  device_uninitialized = cudaErrorDeviceUninitialized,
130 #endif
131  assert = CUDA_ERROR_ASSERT,
132  too_many_peers = CUDA_ERROR_TOO_MANY_PEERS,
133  host_memory_already_registered = CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED,
134  host_memory_not_registered = CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED,
135  operating_system = CUDA_ERROR_OPERATING_SYSTEM,
136  peer_access_unsupported = CUDA_ERROR_PEER_ACCESS_UNSUPPORTED,
137  launch_max_depth_exceeded = cudaErrorLaunchMaxDepthExceeded,
138  launch_file_scoped_tex = cudaErrorLaunchFileScopedTex,
139  launch_file_scoped_surf = cudaErrorLaunchFileScopedSurf,
140  sync_depth_exceeded = cudaErrorSyncDepthExceeded,
141  launch_pending_count_exceeded = cudaErrorLaunchPendingCountExceeded,
142  invalid_device_function = cudaErrorInvalidDeviceFunction,
143  not_permitted = CUDA_ERROR_NOT_PERMITTED,
144  not_supported = CUDA_ERROR_NOT_SUPPORTED,
145  hardware_stack_error = CUDA_ERROR_HARDWARE_STACK_ERROR,
146  illegal_instruction = CUDA_ERROR_ILLEGAL_INSTRUCTION,
147  misaligned_address = CUDA_ERROR_MISALIGNED_ADDRESS,
148  exception_during_kernel_execution = CUDA_ERROR_LAUNCH_FAILED,
149  cooperative_launch_too_large = CUDA_ERROR_COOPERATIVE_LAUNCH_TOO_LARGE,
150  invalid_address_space = CUDA_ERROR_INVALID_ADDRESS_SPACE,
151  invalid_pc = CUDA_ERROR_INVALID_PC,
152  illegal_address = CUDA_ERROR_ILLEGAL_ADDRESS,
153  invalid_ptx = CUDA_ERROR_INVALID_PTX,
154  invalid_graphics_context = CUDA_ERROR_INVALID_GRAPHICS_CONTEXT,
155  nvlink_uncorrectable = CUDA_ERROR_NVLINK_UNCORRECTABLE,
156  startup_failure = cudaErrorStartupFailure,
157  api_failure_base = cudaErrorApiFailureBase,
158 #if CUDA_VERSION >= 10000
159  system_not_ready = CUDA_ERROR_SYSTEM_NOT_READY,
160 #endif
161 #if CUDA_VERSION >= 10100
162  system_driver_mismatch = CUDA_ERROR_SYSTEM_DRIVER_MISMATCH,
163  not_supported_on_device = CUDA_ERROR_COMPAT_NOT_SUPPORTED_ON_DEVICE,
164 #endif
165 #if CUDA_VERSION >= 10000
166  stream_capture_unsupported = CUDA_ERROR_STREAM_CAPTURE_UNSUPPORTED,
167  stream_capture_invalidated = CUDA_ERROR_STREAM_CAPTURE_INVALIDATED,
168  stream_capture_merge = CUDA_ERROR_STREAM_CAPTURE_MERGE,
169  stream_capture_unmatched = CUDA_ERROR_STREAM_CAPTURE_UNMATCHED,
170  stream_capture_unjoined = CUDA_ERROR_STREAM_CAPTURE_UNJOINED,
171  stream_capture_isolation = CUDA_ERROR_STREAM_CAPTURE_ISOLATION,
172  stream_capture_disallowed_implicit_dependency = CUDA_ERROR_STREAM_CAPTURE_IMPLICIT,
173  not_permitted_on_captured_event = CUDA_ERROR_CAPTURED_EVENT,
174 #endif
175 #if CUDA_VERSION >= 10100
176  stream_capture_wrong_thread = CUDA_ERROR_STREAM_CAPTURE_WRONG_THREAD,
177 #endif
178 #if CUDA_VERSION >= 10200
179  timeout_lapsed = CUDA_ERROR_TIMEOUT,
180  graph_update_would_violate_constraints = CUDA_ERROR_GRAPH_EXEC_UPDATE_FAILURE,
181 #endif
182 #if CUDA_VERSION >= 11400
183  mps_connection_failed = CUDA_ERROR_MPS_CONNECTION_FAILED,
184  mps_rpc_failure = CUDA_ERROR_MPS_RPC_FAILURE,
185  mps_server_not_ready = CUDA_ERROR_MPS_SERVER_NOT_READY,
186  mps_max_clients_reached = CUDA_ERROR_MPS_MAX_CLIENTS_REACHED,
187  mps_max_connections_reached = CUDA_ERROR_MPS_MAX_CONNECTIONS_REACHED,
188  async_error_in_external_device = CUDA_ERROR_EXTERNAL_DEVICE,
189 #endif
190 };
191 
193 constexpr inline bool operator==(const status_t& lhs, const named_t& rhs) noexcept { return lhs == static_cast<status_t>(rhs); }
194 constexpr inline bool operator!=(const status_t& lhs, const named_t& rhs) noexcept { return lhs != static_cast<status_t>(rhs); }
195 constexpr inline bool operator==(const named_t& lhs, const status_t& rhs) noexcept { return static_cast<status_t>(lhs) == rhs; }
196 constexpr inline bool operator!=(const named_t& lhs, const status_t& rhs) noexcept { return static_cast<status_t>(lhs) != rhs; }
198 
199 } // namespace status
200 
203 constexpr bool is_success(status_t status) { return status == static_cast<status_t>(status::success); }
204 constexpr bool is_success(cudaError_t status) { return static_cast<status_t>(status) == static_cast<status_t>(status::success); }
206 
209 constexpr bool is_failure(status_t status) { return not is_success(status); }
210 constexpr bool is_failure(cudaError_t status) { return is_failure(static_cast<status_t>(status)); }
212 
215 inline ::std::string describe(status_t status)
216 {
217  // Even though status_t aliases the driver's CUresult type, some values are actually
218  // runtime error codes. The driver will fail to identify them (they're luckily distinct),
219  // and we can't distinguish proper failure from the case of a Runtime-API-only error
220  // code - so we also try the runtime API.
221  const char* description;
222  auto description_lookup_status = cuGetErrorString(status, &description);
223  return (description_lookup_status == CUDA_SUCCESS) ?
224  description : cudaGetErrorString(static_cast<cudaError_t>(status));
225 }
226 inline ::std::string describe(cudaError_t status) { return cudaGetErrorString(status); }
228 
229 namespace detail_ {
230 
231 template <typename I, bool UpperCase = false>
232 ::std::string as_hex(I x)
233 {
234  static_assert(::std::is_unsigned<I>::value, "only signed representations are supported");
235  unsigned num_hex_digits = 2*sizeof(I);
236  if (x == 0) return "0x0";
237 
238  enum { bits_per_hex_digit = 4 }; // = log_2 of 16
239  static const char* digit_characters =
240  UpperCase ? "0123456789ABCDEF" : "0123456789abcdef" ;
241 
242  ::std::string result(num_hex_digits,'0');
243  for (unsigned digit_index = 0; digit_index < num_hex_digits ; digit_index++)
244  {
245  size_t bit_offset = (num_hex_digits - 1 - digit_index) * bits_per_hex_digit;
246  auto hexadecimal_digit = (x >> bit_offset) & 0xF;
247  result[digit_index] = digit_characters[hexadecimal_digit];
248  }
249  return "0x0" + result.substr(result.find_first_not_of('0'), ::std::string::npos);
250 }
251 
252 // TODO: Perhaps find a way to avoid the extra function, so that as_hex() can
253 // be called for pointer types as well? Would be easier with boost's uint<T>...
254 template <typename I, bool UpperCase = false>
255 inline ::std::string ptr_as_hex(const I* ptr)
256 {
257  return as_hex(reinterpret_cast<uintptr_t>(ptr));
258 }
259 
260 } // namespace detail_
261 
271 class runtime_error : public ::std::runtime_error {
272 public:
274  runtime_error(status_t error_code) :
275  ::std::runtime_error(describe(error_code)), code_(error_code)
276  { }
277  // I wonder if I should do this the other way around
278  runtime_error(status_t error_code, const ::std::string& what_arg) :
279  ::std::runtime_error(what_arg + ": " + describe(error_code)),
280  code_(error_code)
281  { }
282  // I wonder if I should do this the other way around
283  runtime_error(status_t error_code, ::std::string&& what_arg) :
284  runtime_error(error_code, what_arg)
285  { }
287  explicit runtime_error(status::named_t error_code) :
288  runtime_error(static_cast<status_t>(error_code)) { }
289  runtime_error(status::named_t error_code, const ::std::string& what_arg) :
290  runtime_error(static_cast<status_t>(error_code), what_arg) { }
291  runtime_error(status::named_t error_code, ::std::string&& what_arg) :
292  runtime_error(static_cast<status_t>(error_code), what_arg) { }
293 
294 protected:
295  runtime_error(status_t error_code, ::std::runtime_error&& err) :
296  ::std::runtime_error(::std::move(err)), code_(error_code)
297  { }
298 
299 public:
302  static runtime_error with_message_override(status_t error_code, ::std::string complete_what_arg)
303  {
304  return runtime_error(error_code, ::std::runtime_error(::std::move(complete_what_arg)));
305  }
306 
308  status_t code() const { return code_; }
309 
310 private:
311  status_t code_;
312 };
313 
316 #define throw_if_error_lazy(status__, ... ) \
317 do { \
318  const ::cuda::status_t tie_status__ = static_cast<::cuda::status_t>(status__); \
319  if (::cuda::is_failure(tie_status__)) { \
320  throw ::cuda::runtime_error(tie_status__, (__VA_ARGS__)); \
321  } \
322 } while(false)
323 
334 inline void throw_if_error(status_t status, const ::std::string& message) noexcept(false)
336 {
337  if (is_failure(status)) { throw runtime_error(status, message); }
338 }
339 
340 inline void throw_if_error(cudaError_t status, const ::std::string& message) noexcept(false)
341 {
342  throw_if_error(static_cast<status_t>(status), message);
343 }
344 
345 inline void throw_if_error(status_t status, ::std::string&& message) noexcept(false)
346 {
347  if (is_failure(status)) { throw runtime_error(status, message); }
348 }
349 
350 inline void throw_if_error(cudaError_t status, ::std::string&& message) noexcept(false)
351 {
352  return throw_if_error(static_cast<status_t>(status), message);
353 }
355 
365 inline void throw_if_error(status_t status) noexcept(false)
366 {
367  if (is_failure(status)) { throw runtime_error(status); }
368 }
369 
370 inline void throw_if_error(cudaError_t status) noexcept(false)
371 {
372  throw_if_error(static_cast<status_t>(status));
373 }
374 
375 enum : bool {
376  dont_clear_errors = false,
377  do_clear_errors = true
378 };
379 
380 namespace detail_ {
381 
382 namespace outstanding_runtime_error {
383 
389 inline status_t clear() noexcept
390 {
391  return static_cast<status_t>(cudaGetLastError());
392 }
393 
399 inline status_t get() noexcept
400 {
401  return static_cast<status_t>(cudaPeekAtLastError());
402 }
403 
404 } // namespace outstanding_runtime_error
405 } // namespace detail_
406 
414 namespace outstanding_error {
415 
420 inline status_t get(bool try_clearing = false) noexcept(true)
421 {
422  static constexpr const unsigned dummy_flags{0};
423  auto status = cuInit(dummy_flags);
424  if (not is_success(status)) { return status; }
425  return static_cast<status_t>(try_clearing ? cudaGetLastError() : cudaPeekAtLastError());
426 }
427 
438 inline void ensure_none(const ::std::string &message) noexcept(false)
439 {
440  auto status = get();
441  throw_if_error(status, message);
442 }
443 
450 inline void ensure_none(const char *message) noexcept(false)
451 {
452  return ensure_none(::std::string{message});
453 }
454 
464 inline void ensure_none() noexcept(false)
465 {
466  auto status = get();
467  throw_if_error(status);
468 }
469 
470 } // namespace outstanding_error
471 
472 // The following few functions are used in the error messages
473 // generated for exceptions thrown by various API wrappers.
474 
475 namespace device {
476 namespace detail_ {
477 inline ::std::string identify(device::id_t device_id)
478 {
479  return ::std::string("device ") + ::std::to_string(device_id);
480 }
481 } // namespace detail_
482 } // namespace device
483 
484 namespace context {
485 namespace detail_ {
486 
487 inline ::std::string identify(handle_t handle)
488 {
489  return "context " + cuda::detail_::ptr_as_hex(handle);
490 }
491 
492 inline ::std::string identify(handle_t handle, device::id_t device_id)
493 {
494  return identify(handle) + " on " + device::detail_::identify(device_id);
495 }
496 
497 } // namespace detail_
498 
499 namespace current {
500 namespace detail_ {
501 inline ::std::string identify(context::handle_t handle)
502 {
503  return "current context: " + context::detail_::identify(handle);
504 }
505 inline ::std::string identify(context::handle_t handle, device::id_t device_id)
506 {
507  return "current context: " + context::detail_::identify(handle, device_id);
508 }
509 } // namespace detail_
510 } // namespace current
511 
512 } // namespace context
513 
514 namespace device {
515 namespace primary_context {
516 namespace detail_ {
517 
518 inline ::std::string identify(handle_t handle, device::id_t device_id)
519 {
520  return "context " + context::detail_::identify(handle, device_id);
521 }
522 inline ::std::string identify(handle_t handle)
523 {
524  return "context " + context::detail_::identify(handle);
525 }
526 } // namespace detail_
527 } // namespace primary_context
528 } // namespace device
529 
530 namespace stream {
531 namespace detail_ {
532 inline ::std::string identify(handle_t handle)
533 {
534  return "stream " + cuda::detail_::ptr_as_hex(handle);
535 }
536 inline ::std::string identify(handle_t handle, device::id_t device_id)
537 {
538  return identify(handle) + " on " + device::detail_::identify(device_id);
539 }
540 inline ::std::string identify(handle_t handle, context::handle_t context_handle)
541 {
542  return identify(handle) + " in " + context::detail_::identify(context_handle);
543 }
544 inline ::std::string identify(handle_t handle, context::handle_t context_handle, device::id_t device_id)
545 {
546  return identify(handle) + " in " + context::detail_::identify(context_handle, device_id);
547 }
548 } // namespace detail_
549 } // namespace stream
550 
551 namespace event {
552 namespace detail_ {
553 inline ::std::string identify(handle_t handle)
554 {
555  return "event " + cuda::detail_::ptr_as_hex(handle);
556 }
557 inline ::std::string identify(handle_t handle, device::id_t device_id)
558 {
559  return identify(handle) + " on " + device::detail_::identify(device_id);
560 }
561 inline ::std::string identify(handle_t handle, context::handle_t context_handle)
562 {
563  return identify(handle) + " on " + context::detail_::identify(context_handle);
564 }
565 inline ::std::string identify(handle_t handle, context::handle_t context_handle, device::id_t device_id)
566 {
567  return identify(handle) + " on " + context::detail_::identify(context_handle, device_id);
568 }
569 } // namespace detail_
570 } // namespace event
571 
572 namespace kernel {
573 namespace detail_ {
574 
575 inline ::std::string identify(const void* ptr)
576 {
577  return "kernel " + cuda::detail_::ptr_as_hex(ptr);
578 }
579 inline ::std::string identify(const void* ptr, device::id_t device_id)
580 {
581  return identify(ptr) + " on " + device::detail_::identify(device_id);
582 }
583 inline ::std::string identify(const void* ptr, context::handle_t context_handle)
584 {
585  return identify(ptr) + " in " + context::detail_::identify(context_handle);
586 }
587 inline ::std::string identify(const void* ptr, context::handle_t context_handle, device::id_t device_id)
588 {
589  return identify(ptr) + " in " + context::detail_::identify(context_handle, device_id);
590 }
591 inline ::std::string identify(handle_t handle)
592 {
593  return "kernel at " + cuda::detail_::ptr_as_hex(handle);
594 }
595 inline ::std::string identify(handle_t handle, context::handle_t context_handle)
596 {
597  return identify(handle) + " in " + context::detail_::identify(context_handle);
598 }
599 inline ::std::string identify(handle_t handle, device::id_t device_id)
600 {
601  return identify(handle) + " on " + device::detail_::identify(device_id);
602 }
603 inline ::std::string identify(handle_t handle, context::handle_t context_handle, device::id_t device_id)
604 {
605  return identify(handle) + " in " + context::detail_::identify(context_handle, device_id);
606 }
607 
608 } // namespace detail_
609 } // namespace kernel
610 
611 namespace memory {
612 namespace detail_ {
613 
614 inline ::std::string identify(region_t region)
615 {
616  return ::std::string("memory region at ") + cuda::detail_::ptr_as_hex(region.data())
617  + " of size " + ::std::to_string(region.size());
618 }
619 
620 } // namespace detail_
621 
622 } // namespace memory
623 
624 } // namespace cuda
625 
626 #endif // CUDA_API_WRAPPERS_ERROR_HPP_
static runtime_error with_message_override(status_t error_code, ::std::string complete_what_arg)
Construct a runtime error which will not produce the default description for the error code...
Definition: error.hpp:302
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
detail_::region_helper< memory::region_t > region_t
A child class of the generic region_t with some managed-memory-specific functionality.
Definition: memory.hpp:1960
void ensure_none() noexcept(false)
Does nothing (except possibly throwing an exception)
Definition: error.hpp:464
CUcontext handle_t
Raw CUDA driver handle for a context; see {context_t}.
Definition: types.hpp:878
Operation was successful; no errors.
Definition: error.hpp:38
constexpr bool is_failure(status_t status)
Determine whether the API call returning the specified status had failed.
Definition: error.hpp:209
CUdevice id_t
Numeric ID of a CUDA device used by the CUDA Runtime API.
Definition: types.hpp:850
void throw_if_error(status_t status, const ::std::string &message) noexcept(false)
Do nothing...
Definition: error.hpp:335
named_t
Aliases for CUDA status codes.
Definition: error.hpp:36
A (base?) class for exceptions raised by CUDA code; these errors are thrown by essentially all CUDA R...
Definition: error.hpp:271
status_t code() const
Obtain the CUDA status code which resulted in this error being thrown.
Definition: error.hpp:308
inline ::std::string describe(status_t status)
Obtain a brief textual explanation for a specified kind of CUDA Runtime API status or error code...
Definition: error.hpp:215
bool operator==(const context_t &lhs, const context_t &rhs) noexcept
Definition: context.hpp:762
CUarray handle_t
Raw CUDA driver handle for arrays (of any dimension)
Definition: array.hpp:34
Fundamental CUDA-related type definitions.
constexpr bool is_success(status_t status)
Determine whether the API call returning the specified status had succeeded.
Definition: error.hpp:203
CUresult status_t
Indicates either the result (success or error index) of a CUDA Runtime or Driver API call...
Definition: types.hpp:77