8 #ifndef CUDA_API_WRAPPERS_MISCELLANY_HPP_ 9 #define CUDA_API_WRAPPERS_MISCELLANY_HPP_ 28 static constexpr
const unsigned dummy_flags{0};
29 auto status = cuInit(dummy_flags);
42 thread_local
bool driver_known_to_be_initialized{
false};
43 if (not driver_known_to_be_initialized) {
45 driver_known_to_be_initialized =
true;
69 status_t result = cuDeviceGetCount(&device_count);
76 throw runtime_error(result,
"Failed obtaining the number of CUDA devices on the system");
78 if (device_count < 0) {
79 throw ::std::logic_error(
"cudaGetDeviceCount() reports an invalid number of CUDA devices");
89 #endif // CUDA_API_WRAPPERS_MISCELLANY_HPP_ void ensure_driver_is_initialized()
A mechanism for ensuring a cuInit() call has been made, to use before making any other driver API cal...
Definition: miscellany.hpp:40
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
device::id_t count()
Get the number of CUDA devices usable on the system (with the current CUDA library and kernel driver)...
Definition: miscellany.hpp:63
CUdevice id_t
Numeric ID of a CUDA device used by the CUDA Runtime API.
Definition: types.hpp:850
void initialize_driver()
Obtains the CUDA Runtime version.
Definition: miscellany.hpp:26
A (base?) class for exceptions raised by CUDA code; these errors are thrown by essentially all CUDA R...
Definition: error.hpp:271
#define throw_if_error_lazy(status__,...)
A macro for only throwing an error if we've failed - which also ensures no string is constructed unle...
Definition: error.hpp:316
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
Fundamental CUDA-related type definitions.
CUresult status_t
Indicates either the result (success or error index) of a CUDA Runtime or Driver API call...
Definition: types.hpp:77