Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
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 
12 #include <ginkgo/config.hpp>
13 #include <ginkgo/core/base/types.hpp>
14 
15 
16 namespace gko {
17 
18 
26 struct version {
27  constexpr version(const uint64 major, const uint64 minor,
28  const uint64 patch, const char* tag)
30  {}
31 
35  const uint64 major;
36 
40  const uint64 minor;
41 
45  const uint64 patch;
46 
52  const char* const tag;
53 };
54 
55 inline bool operator==(const version& first, const version& second)
56 {
57  return first.major == second.major && first.minor == second.minor &&
58  first.patch == second.patch;
59 }
60 
61 inline bool operator!=(const version& first, const version& second)
62 {
63  return !(first == second);
64 }
65 
66 inline bool operator<(const version& first, const version& second)
67 {
68  if (first.major < second.major) return true;
69  if (first.major == second.major && first.minor < second.minor) return true;
70  if (first.major == second.major && first.minor == second.minor &&
71  first.patch < second.patch)
72  return true;
73  return false;
74 }
75 
76 inline bool operator<=(const version& first, const version& second)
77 {
78  return !(second < first);
79 }
80 
81 inline bool operator>(const version& first, const version& second)
82 {
83  return second < first;
84 }
85 
86 inline bool operator>=(const version& first, const version& second)
87 {
88  return !(first < second);
89 }
90 
91 #undef GKO_ENABLE_VERSION_COMPARISON
92 
93 
102 inline std::ostream& operator<<(std::ostream& os, const version& ver)
103 {
104  os << ver.major << "." << ver.minor << "." << ver.patch;
105  if (ver.tag) {
106  os << " (" << ver.tag << ")";
107  }
108  return os;
109 }
110 
111 
134 public:
140  static const version_info& get()
141  {
142  static version_info info{};
143  return info;
144  }
145 
150 
157 
165 
172 
179 
186 
193 
194 private:
195  static constexpr version get_header_version() noexcept
196  {
197  return version{GKO_VERSION_MAJOR, GKO_VERSION_MINOR, GKO_VERSION_PATCH,
198  GKO_VERSION_TAG};
199  }
200 
201  static version get_core_version() noexcept;
202 
203  static version get_reference_version() noexcept;
204 
205  static version get_omp_version() noexcept;
206 
207  static version get_cuda_version() noexcept;
208 
209  static version get_hip_version() noexcept;
210 
211  static version get_dpcpp_version() noexcept;
212 
213  version_info()
214  : header_version{get_header_version()},
215  core_version{get_core_version()},
216  reference_version{get_reference_version()},
217  omp_version{get_omp_version()},
218  cuda_version{get_cuda_version()},
219  hip_version{get_hip_version()},
220  dpcpp_version{get_dpcpp_version()}
221  {}
222 };
223 
224 
233 std::ostream& operator<<(std::ostream& os, const version_info& ver_info);
234 
235 
236 } // namespace gko
237 
238 
239 #endif // GKO_PUBLIC_CORE_BASE_VERSION_HPP_
gko::version::minor
const uint64 minor
The minor version number.
Definition: version.hpp:40
gko::version_info::core_version
version core_version
Contains version information of the core library.
Definition: version.hpp:156
gko::version::tag
const char *const tag
Addition tag string that describes the version in more detail.
Definition: version.hpp:52
gko::version_info::dpcpp_version
version dpcpp_version
Contains version information of the DPC++ module.
Definition: version.hpp:192
gko::version_info::reference_version
version reference_version
Contains version information of the reference module.
Definition: version.hpp:164
gko::version::patch
const uint64 patch
The patch version number.
Definition: version.hpp:45
gko::version_info::omp_version
version omp_version
Contains version information of the OMP module.
Definition: version.hpp:171
gko::version_info::hip_version
version hip_version
Contains version information of the HIP module.
Definition: version.hpp:185
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::version_info::get
static const version_info & get()
Returns an instance of version_info.
Definition: version.hpp:140
gko::version
This structure is used to represent versions of various Ginkgo modules.
Definition: version.hpp:26
gko::version_info::header_version
version header_version
Contains version information of the header files.
Definition: version.hpp:149
gko::version::major
const uint64 major
The major version number.
Definition: version.hpp:35
gko::version_info
Ginkgo uses version numbers to label new features and to communicate backward compatibility guarantee...
Definition: version.hpp:133
gko::version_info::cuda_version
version cuda_version
Contains version information of the CUDA module.
Definition: version.hpp:178
gko::uint64
std::uint64_t uint64
64-bit unsigned integral type.
Definition: types.hpp:154