10 #ifndef CUDA_API_WRAPPERS_VERSIONS_HPP_ 11 #define CUDA_API_WRAPPERS_VERSIONS_HPP_ 20 using combined_version_t = int;
31 static version_t from_single_number(combined_version_t combined_version) noexcept
33 return { combined_version / 1000, (combined_version % 100) / 10 };
36 operator ::std::pair<int, int>()
const noexcept {
return { major, minor }; }
41 inline ::std::ostream& operator<<(::std::ostream& os,
version_t v)
43 return os << v.major <<
'.' << v.minor;
50 return lhs.operator ::std::pair<int,
int>() == rhs.operator ::std::pair<
int,
int>();
55 return lhs.operator ::std::pair<int,
int>() != rhs.operator ::std::pair<
int,
int>();
60 return lhs.operator ::std::pair<int,
int>() < rhs.operator ::std::pair<
int,
int>();
65 return lhs.operator ::std::pair<int,
int>() <= rhs.operator ::std::pair<
int,
int>();
70 return lhs.operator ::std::pair<int,
int>() > rhs.operator ::std::pair<
int,
int>();
75 return lhs.operator ::std::pair<int,
int>() >= rhs.operator ::std::pair<
int,
int>();
80 inline bool operator==(
const version_t& lhs,
int rhs) noexcept {
return lhs == version_t::from_single_number(rhs); }
81 inline bool operator!=(
const version_t& lhs,
int rhs) noexcept {
return lhs != version_t::from_single_number(rhs); }
82 inline bool operator< (
const version_t& lhs,
int rhs) noexcept {
return lhs < version_t::from_single_number(rhs); }
83 inline bool operator> (
const version_t& lhs,
int rhs) noexcept {
return lhs > version_t::from_single_number(rhs); }
84 inline bool operator<=(
const version_t& lhs,
int rhs) noexcept {
return lhs <= version_t::from_single_number(rhs); }
85 inline bool operator>=(
const version_t& lhs,
int rhs) noexcept {
return lhs >= version_t::from_single_number(rhs); }
90 namespace version_numbers {
110 return version_t::from_single_number(combined_version);
119 return { major, minor };
135 combined_version_t version;
136 auto status = cuDriverGetVersion(&version);
138 throw_if_error_lazy(status,
"Failed obtaining the CUDA driver version");
139 return version_t::from_single_number(version);
149 combined_version_t version;
150 auto status = cudaRuntimeGetVersion(&version);
151 throw_if_error_lazy(status,
"Failed obtaining the CUDA runtime version");
152 return version_t::from_single_number(version);
158 #endif // CUDA_API_WRAPPERS_VERSIONS_HPP_ All definitions and functionality wrapping the CUDA Runtime API.
Definition: array.hpp:22
version_t make(combined_version_t combined_version) noexcept
Convert an integer representing a major and minor number (e.g.
Definition: versions.hpp:108
Facilities for exception-based handling of Runtime and Driver API errors, including a basic exception...
CUDA Runtime version.
Definition: versions.hpp:27
version_t driver()
Obtains the maximum version of the CUDA Runtime supported by the driver currently loaded by the opera...
Definition: versions.hpp:134
version_t runtime()
Obtains the CUDA Runtime version.
Definition: versions.hpp:148