Ginkgo: ginkgo/core/base/version.hpp Source File

| Ginkgo Generated from branch based on main. Ginkgo version 1.11.0 A numerical linear algebra library targeting many-core architectures

Loading...
Searching...
No Matches
version.hpp
1// SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#ifndef GKO_PUBLIC_CORE_BASE_VERSION_HPP_
6#define GKO_PUBLIC_CORE_BASE_VERSION_HPP_
7
8
9#include <ostream>
10
11#include <ginkgo/config.hpp>
12#include <ginkgo/core/base/types.hpp>
13
14
15namespace gko {
16
17
25 struct version {
26 constexpr version(const uint64 major, const uint64 minor,
27 const uint64 patch, const char* tag)
28 : major{major}, minor{minor}, patch{patch}, tag{tag}
29 {}
30
34 const uint64 major;
35
39 const uint64 minor;
40
44 const uint64 patch;
45
51 const char* const tag;
52};
53
54inline bool operator==(const version& first, const version& second)
55{
56 return first.major == second.major && first.minor == second.minor &&
57 first.patch == second.patch;
58}
59
60inline bool operator!=(const version& first, const version& second)
61{
62 return !(first == second);
63}
64
65inline bool operator<(const version& first, const version& second)
66{
67 if (first.major < second.major) return true;
68 if (first.major == second.major && first.minor < second.minor) return true;
69 if (first.major == second.major && first.minor == second.minor &&
70 first.patch < second.patch)
71 return true;
72 return false;
73}
74
75inline bool operator<=(const version& first, const version& second)
76{
77 return !(second < first);
78}
79
80inline bool operator>(const version& first, const version& second)
81{
82 return second < first;
83}
84
85inline bool operator>=(const version& first, const version& second)
86{
87 return !(first < second);
88}
89
90#undef GKO_ENABLE_VERSION_COMPARISON
91
92
101 inline std::ostream& operator<<(std::ostream& os, const version& ver)
102{
103 os << ver.major << "." << ver.minor << "." << ver.patch;
104 if (ver.tag) {
105 os << " (" << ver.tag << ")";
106 }
107 return os;
108}
109
110
132 class version_info {
133public:
139 static const version_info& get()
140 {
141 static version_info info{};
142 return info;
143 }
144
148 version header_version;
149
155 version core_version;
156
163 version reference_version;
164
170 version omp_version;
171
177 version cuda_version;
178
184 version hip_version;
185
191 version dpcpp_version;
192
193private:
194 static constexpr version get_header_version() noexcept
195 {
196 return version{GKO_VERSION_MAJOR, GKO_VERSION_MINOR, GKO_VERSION_PATCH,
197 GKO_VERSION_TAG};
198 }
199
200 static version get_core_version() noexcept;
201
202 static version get_reference_version() noexcept;
203
204 static version get_omp_version() noexcept;
205
206 static version get_cuda_version() noexcept;
207
208 static version get_hip_version() noexcept;
209
210 static version get_dpcpp_version() noexcept;
211
212 version_info()
213 : header_version{get_header_version()},
214 core_version{get_core_version()},
215 reference_version{get_reference_version()},
216 omp_version{get_omp_version()},
217 cuda_version{get_cuda_version()},
218 hip_version{get_hip_version()},
219 dpcpp_version{get_dpcpp_version()}
220 {}
221};
222
223
232std::ostream& operator<<(std::ostream& os, const version_info& ver_info);
233
234
235} // namespace gko
236
237
238#endif // GKO_PUBLIC_CORE_BASE_VERSION_HPP_
gko::version_info
Ginkgo uses version numbers to label new features and to communicate backward compatibility guarantee...
Definition version.hpp:132
gko::version_info::dpcpp_version
version dpcpp_version
Contains version information of the DPC++ module.
Definition version.hpp:191
gko::version_info::header_version
version header_version
Contains version information of the header files.
Definition version.hpp:148
gko::version_info::cuda_version
version cuda_version
Contains version information of the CUDA module.
Definition version.hpp:177
gko::version_info::reference_version
version reference_version
Contains version information of the reference module.
Definition version.hpp:163
gko::version_info::omp_version
version omp_version
Contains version information of the OMP module.
Definition version.hpp:170
gko::version_info::core_version
version core_version
Contains version information of the core library.
Definition version.hpp:155
gko::version_info::hip_version
version hip_version
Contains version information of the HIP module.
Definition version.hpp:184
gko::version_info::get
static const version_info & get()
Returns an instance of version_info.
Definition version.hpp:139
gko
The Ginkgo namespace.
Definition abstract_factory.hpp:20
gko::uint64
std::uint64_t uint64
64-bit unsigned integral type.
Definition types.hpp:136
gko::version
This structure is used to represent versions of various Ginkgo modules.
Definition version.hpp:25
gko::version::major
const uint64 major
The major version number.
Definition version.hpp:34
gko::version::tag
const char *const tag
Addition tag string that describes the version in more detail.
Definition version.hpp:51
gko::version::patch
const uint64 patch
The patch version number.
Definition version.hpp:44
gko::version::minor
const uint64 minor
The minor version number.
Definition version.hpp:39