10 #ifndef CUDA_API_WRAPPERS_VERSIONS_HPP_ 11 #define CUDA_API_WRAPPERS_VERSIONS_HPP_ 15 #if CUDA_VERSION >= 12040 48 return { combined_version / 1000, (combined_version % 100) / 10 };
52 operator ::std::pair<int, int>()
const noexcept {
return { major, minor }; }
57 inline ::std::ostream& operator<<(::std::ostream& os,
version_t v)
59 return os << v.major <<
'.' << v.minor;
66 return lhs.operator ::std::pair<int,
int>() == rhs.operator ::std::pair<
int,
int>();
71 return lhs.operator ::std::pair<int,
int>() != rhs.operator ::std::pair<
int,
int>();
76 return lhs.operator ::std::pair<int,
int>() < rhs.operator ::std::pair<
int,
int>();
81 return lhs.operator ::std::pair<int,
int>() <= rhs.operator ::std::pair<
int,
int>();
86 return lhs.operator ::std::pair<int,
int>() > rhs.operator ::std::pair<
int,
int>();
91 return lhs.operator ::std::pair<int,
int>() >= rhs.operator ::std::pair<
int,
int>();
106 namespace version_numbers {
135 return { major, minor };
152 auto status = cuDriverGetVersion(&version);
165 auto status = cudaRuntimeGetVersion(&version);
170 #if CUDA_VERSION >= 12040 173 unsigned int major { 0 }, minor { 0 };
175 auto status = nvFatbinVersion(&major, &minor);
178 if ((major == 0) or (major > ::std::numeric_limits<int>::max())
179 or (minor == 0) or (minor > ::std::numeric_limits<int>::max())) {
180 throw ::std::logic_error(
"Invalid version encountered: (" 181 + ::std::to_string(major) +
", " + ::std::to_string(minor) +
')' );
184 return version_t{
static_cast<int>(major), static_cast<int>(minor) };
186 #endif // CUDA_VERSION >= 12040 191 #endif // CUDA_API_WRAPPERS_VERSIONS_HPP_ Definitions and functionality wrapping CUDA APIs.
Definition: array.hpp:22
int combined_version_t
A combination of the major and minor version numbers for a CUDA release into a single integer...
Definition: versions.hpp:31
version_t make(combined_version_t combined_version) noexcept
Convert an integer representing a major and minor number (e.g.
Definition: versions.hpp:124
#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
bool operator==(const context_t &lhs, const context_t &rhs) noexcept
Definition: context.hpp:762
static version_t from_single_number(combined_version_t combined_version) noexcept
Parse the combined single-number representation, separating it.
Definition: versions.hpp:46
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
A structure representing a CUDA release version.
Definition: versions.hpp:39
version_t driver()
Obtains the maximum version of the CUDA Runtime supported by the driver currently loaded by the opera...
Definition: versions.hpp:150
version_t runtime()
Obtains the CUDA Runtime version.
Definition: versions.hpp:163