Ginkgo  Generated from pipelines/2837190956 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
version.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 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 
15 namespace gko {
16 
17 
24 struct version {
25  constexpr version(const uint64 major, const uint64 minor,
26  const uint64 patch, const char* tag)
28  {}
29 
33  const uint64 major;
34 
38  const uint64 minor;
39 
43  const uint64 patch;
44 
50  const char* const tag;
51 };
52 
53 inline bool operator==(const version& first, const version& second)
54 {
55  return first.major == second.major && first.minor == second.minor &&
56  first.patch == second.patch;
57 }
58 
59 inline bool operator!=(const version& first, const version& second)
60 {
61  return !(first == second);
62 }
63 
64 inline bool operator<(const version& first, const version& second)
65 {
66  if (first.major < second.major) return true;
67  if (first.major == second.major && first.minor < second.minor) return true;
68  if (first.major == second.major && first.minor == second.minor &&
69  first.patch < second.patch)
70  return true;
71  return false;
72 }
73 
74 inline bool operator<=(const version& first, const version& second)
75 {
76  return !(second < first);
77 }
78 
79 inline bool operator>(const version& first, const version& second)
80 {
81  return second < first;
82 }
83 
84 inline bool operator>=(const version& first, const version& second)
85 {
86  return !(first < second);
87 }
88 
89 #undef GKO_ENABLE_VERSION_COMPARISON
90 
91 
100 inline std::ostream& operator<<(std::ostream& os, const version& ver)
101 {
102  os << ver.major << "." << ver.minor << "." << ver.patch;
103  if (ver.tag) {
104  os << " (" << ver.tag << ")";
105  }
106  return os;
107 }
108 
109 
132 public:
138  static const version_info& get()
139  {
140  static version_info info{};
141  return info;
142  }
143 
148 
155 
163 
170 
177 
184 
191 
192 private:
193  static constexpr version get_header_version() noexcept
194  {
195  return version{GKO_VERSION_MAJOR, GKO_VERSION_MINOR, GKO_VERSION_PATCH,
196  GKO_VERSION_TAG};
197  }
198 
199  static version get_core_version() noexcept;
200 
201  static version get_reference_version() noexcept;
202 
203  static version get_omp_version() noexcept;
204 
205  static version get_cuda_version() noexcept;
206 
207  static version get_hip_version() noexcept;
208 
209  static version get_dpcpp_version() noexcept;
210 
211  version_info()
212  : header_version{get_header_version()},
213  core_version{get_core_version()},
214  reference_version{get_reference_version()},
215  omp_version{get_omp_version()},
216  cuda_version{get_cuda_version()},
217  hip_version{get_hip_version()},
218  dpcpp_version{get_dpcpp_version()}
219  {}
220 };
221 
222 
231 std::ostream& operator<<(std::ostream& os, const version_info& ver_info);
232 
233 
234 } // namespace gko
235 
236 
237 #endif // GKO_PUBLIC_CORE_BASE_VERSION_HPP_
gko::version::minor
const uint64 minor
The minor version number.
Definition: version.hpp:38
gko::version_info::core_version
version core_version
Contains version information of the core library.
Definition: version.hpp:154
gko::version::tag
const char *const tag
Addition tag string that describes the version in more detail.
Definition: version.hpp:50
gko::version_info::dpcpp_version
version dpcpp_version
Contains version information of the DPC++ module.
Definition: version.hpp:190
gko::version_info::reference_version
version reference_version
Contains version information of the reference module.
Definition: version.hpp:162
gko::version::patch
const uint64 patch
The patch version number.
Definition: version.hpp:43
gko::version_info::omp_version
version omp_version
Contains version information of the OMP module.
Definition: version.hpp:169
gko::version_info::hip_version
version hip_version
Contains version information of the HIP module.
Definition: version.hpp:183
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
gko::version_info::get
static const version_info & get()
Returns an instance of version_info.
Definition: version.hpp:138
gko::version
This structure is used to represent versions of various Ginkgo modules.
Definition: version.hpp:24
gko::version_info::header_version
version header_version
Contains version information of the header files.
Definition: version.hpp:147
gko::version::major
const uint64 major
The major version number.
Definition: version.hpp:33
gko::version_info
Ginkgo uses version numbers to label new features and to communicate backward compatibility guarantee...
Definition: version.hpp:131
gko::version_info::cuda_version
version cuda_version
Contains version information of the CUDA module.
Definition: version.hpp:176
gko::uint64
std::uint64_t uint64
64-bit unsigned integral type.
Definition: types.hpp:147