cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
versions.hpp
Go to the documentation of this file.
1 
9 #pragma once
10 #ifndef CUDA_API_WRAPPERS_FATBIN_VERSIONS_HPP_
11 #define CUDA_API_WRAPPERS_FATBIN_VERSIONS_HPP_
12 
13 #include "error.hpp"
14 
15 #if CUDA_VERSION >= 12040
16 #include <nvFatbin.h>
17 #endif
18 
19 #include <limits>
20 
21 namespace cuda {
22 namespace version_numbers {
23 
24 #if CUDA_VERSION >= 12040
25 
26 inline version_t fatbin() {
27  unsigned int major { 0 }, minor { 0 };
28 
29  auto status = nvFatbinVersion(&major, &minor);
30  throw_if_error_lazy(status, "Failed obtaining the nvfatbin library version");
31 #ifndef NDEBUG
32  if ( (major == 0) or (major > ::std::numeric_limits<int>::max())
33  or (minor == 0) or (minor > ::std::numeric_limits<int>::max())) {
34  throw ::std::logic_error("Invalid version encountered: ("
35  + ::std::to_string(major) + ", " + ::std::to_string(minor) + ')' );
36  }
37 #endif
38  return version_t{ static_cast<int>(major), static_cast<int>(minor) };
39 }
40 #endif // CUDA_VERSION >= 12040
41 
42 } // namespace version_numbers
43 } // namespace cuda
44 
45 #endif // CUDA_API_WRAPPERS_FATBIN_VERSIONS_HPP_
Facilities for exception-based handling of errors originating in NVIDIA&#39;s fatbin creating library (nv...
Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
#define throw_if_error_lazy(status__,...)
A macro for only throwing an error if we&#39;ve failed - which also ensures no string is constructed unle...
Definition: error.hpp:316