Ginkgo  Generated from tags/v1.0.0^0 branch based on master. Ginkgo version 1.0.0
A numerical linear algebra library targeting many-core architectures
version.hpp
1 /*******************************<GINKGO LICENSE>******************************
2 Copyright (c) 2017-2019, the Ginkgo authors
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions
7 are met:
8 
9 1. Redistributions of source code must retain the above copyright
10 notice, this list of conditions and the following disclaimer.
11 
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
15 
16 3. Neither the name of the copyright holder nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
19 
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 ******************************<GINKGO LICENSE>*******************************/
32 
33 #ifndef GKO_CORE_BASE_VERSION_HPP_
34 #define GKO_CORE_BASE_VERSION_HPP_
35 
36 
37 #include <ginkgo/config.hpp>
38 #include <ginkgo/core/base/types.hpp>
39 
40 
41 #include <ostream>
42 #include <tuple>
43 
44 
45 namespace gko {
46 
47 
55 struct version {
59  const uint64 major;
60 
64  const uint64 minor;
65 
69  const uint64 patch;
70 
76  const char *const tag;
77 };
78 
79 
80 #define GKO_ENABLE_VERSION_COMPARISON(_operator) \
81  inline bool operator _operator(const version &first, \
82  const version &second) \
83  { \
84  return std::tie(first.major, first.minor, first.patch) \
85  _operator std::tie(second.major, second.minor, second.patch); \
86  } \
87  static_assert(true, \
88  "This assert is used to counter the false positive extra " \
89  "semi-colon warnings")
90 
91 GKO_ENABLE_VERSION_COMPARISON(<);
92 GKO_ENABLE_VERSION_COMPARISON(<=);
93 GKO_ENABLE_VERSION_COMPARISON(==);
94 GKO_ENABLE_VERSION_COMPARISON(!=);
95 GKO_ENABLE_VERSION_COMPARISON(>=);
96 GKO_ENABLE_VERSION_COMPARISON(>);
97 
98 #undef GKO_ENABLE_VERSION_COMPARISON
99 
100 
109 inline std::ostream &operator<<(std::ostream &os, const version &ver)
110 {
111  os << ver.major << "." << ver.minor << "." << ver.patch;
112  if (ver.tag) {
113  os << " (" << ver.tag << ")";
114  }
115  return os;
116 }
117 
118 
141 public:
147  static const version_info &get()
148  {
149  static version_info info{};
150  return info;
151  }
152 
157 
164 
172 
179 
186 
187 private:
188  static constexpr version get_header_version() noexcept
189  {
190  return {GKO_VERSION_MAJOR, GKO_VERSION_MINOR, GKO_VERSION_PATCH,
191  GKO_VERSION_TAG};
192  }
193 
194  static version get_core_version() noexcept;
195 
196  static version get_reference_version() noexcept;
197 
198  static version get_omp_version() noexcept;
199 
200  static version get_cuda_version() noexcept;
201 
202  version_info()
203  : header_version{get_header_version()},
204  core_version{get_core_version()},
205  reference_version{get_reference_version()},
206  omp_version{get_omp_version()},
207  cuda_version{get_cuda_version()}
208  {}
209 };
210 
211 
220 std::ostream &operator<<(std::ostream &os, const version_info &ver_info);
221 
222 
223 } // namespace gko
224 
225 
226 #endif // GKO_CORE_BASE_VERSION_HPP_
version cuda_version
Contains version information of the CUDA module.
Definition: version.hpp:185
version reference_version
Contains version information of the reference module.
Definition: version.hpp:171
version core_version
Contains version information of the core library.
Definition: version.hpp:163
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
std::uint64_t uint64
64-bit unsigned integral type.
Definition: types.hpp:140
Ginkgo uses version numbers to label new features and to communicate backward compatibility guarantee...
Definition: version.hpp:140
version omp_version
Contains version information of the OMP module.
Definition: version.hpp:178
const uint64 minor
The minor version number.
Definition: version.hpp:64
This structure is used to represent versions of various Ginkgo modules.
Definition: version.hpp:55
const uint64 major
The major version number.
Definition: version.hpp:59
version header_version
Contains version information of the header files.
Definition: version.hpp:156
const char *const tag
Addition tag string that describes the version in more detail.
Definition: version.hpp:76
const uint64 patch
The patch version number.
Definition: version.hpp:69