33 #ifndef GKO_CORE_TYPES_HPP_ 34 #define GKO_CORE_TYPES_HPP_ 44 #include <type_traits> 50 #define GKO_ATTRIBUTES __host__ __device__ 51 #define GKO_INLINE __forceinline__ 53 #define GKO_ATTRIBUTES 54 #define GKO_INLINE inline 58 #if defined(__CUDA_ARCH__) && defined(__APPLE__) 61 #define GKO_ASSERT(condition) ((void)0) 65 #define GKO_ASSERT(condition) \ 68 : ((void)printf("%s: %d: %s: Assertion `" #condition "' failed\n", \ 69 __FILE__, __LINE__, __func__))) 72 #else // defined(__CUDA_ARCH__) && defined(__APPLE__) 75 #define GKO_ASSERT(condition) assert(condition) 77 #endif // defined(__CUDA_ARCH__) && defined(__APPLE__) 82 #define GKO_DEPRECATED(msg) __declspec(deprecated(msg)) 84 #define GKO_DEPRECATED(msg) __attribute__((deprecated(msg))) 85 #endif // defined(_WIN32) 146 using uintptr = std::uintptr_t;
236 static constexpr
auto nonpreserving_bits = 4u;
237 static constexpr
auto preserving_bits =
239 static constexpr
auto nonpreserving_mask =
241 static constexpr
auto preserving_mask =
242 storage_type{(0x1 << preserving_bits) - 1} << nonpreserving_bits;
261 : data_((GKO_ASSERT(preserving < (0x1 << preserving_bits) - 1),
262 GKO_ASSERT(nonpreserving < (0x1 << nonpreserving_bits) - 1),
263 (preserving << nonpreserving_bits) | nonpreserving))
283 return (data_ & preserving_mask) >> nonpreserving_bits;
293 return data_ & nonpreserving_mask;
323 min(x.data_ & preserving_mask, y.data_ & preserving_mask) |
324 min(x.data_ & nonpreserving_mask, y.data_ & nonpreserving_mask));
335 return x < y ? x : y;
354 return static_cast<st
>(x) == static_cast<st>(y);
370 return static_cast<st
>(x) != static_cast<st>(y);
386 #define GKO_ENABLE_FOR_ALL_EXECUTORS(_enable_macro) \ 387 _enable_macro(OmpExecutor, omp); \ 388 _enable_macro(CudaExecutor, cuda) 399 #define GKO_INSTANTIATE_FOR_EACH_VALUE_TYPE(_macro) \ 400 template _macro(float); \ 401 template _macro(double); \ 402 template _macro(std::complex<float>); \ 403 template _macro(std::complex<double>) 414 #define GKO_INSTANTIATE_FOR_EACH_INDEX_TYPE(_macro) \ 415 template _macro(int32); \ 416 template _macro(int64) 427 #define GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(_macro) \ 428 template _macro(float, int32); \ 429 template _macro(double, int32); \ 430 template _macro(std::complex<float>, int32); \ 431 template _macro(std::complex<double>, int32); \ 432 template _macro(float, int64); \ 433 template _macro(double, int64); \ 434 template _macro(std::complex<float>, int64); \ 435 template _macro(std::complex<double>, int64) 441 #endif // GKO_CORE_TYPES_HPP_ constexpr precision_reduction(storage_type preserving, storage_type nonpreserving) noexcept
Creates a precision_reduction encoding with the specified number of conversions.
Definition: types.hpp:259
std::uint16_t uint16
16-bit unsigned integral type.
Definition: types.hpp:128
This class is used to encode storage precisions of low precision algorithms.
Definition: types.hpp:228
constexpr size_type byte_size
Number of bits in a byte.
Definition: types.hpp:185
double default_precision
Precision used if no precision is explicitly specified.
Definition: types.hpp:179
double float64
Double precision floating point type.
Definition: types.hpp:167
constexpr bool operator!=(const dim< Dimensionality, DimensionType > &x, const dim< Dimensionality, DimensionType > &y)
Checks if two dim objects are different.
Definition: dim.hpp:216
std::int32_t int32
32-bit signed integral type.
Definition: types.hpp:111
std::uint32_t uint32
32-bit unsigned integral type.
Definition: types.hpp:134
float float32
Single precision floating point type.
Definition: types.hpp:161
std::size_t size_type
Integral type used for allocation quantities.
Definition: types.hpp:94
static constexpr precision_reduction autodetect() noexcept
Returns a special encoding which instructs the algorithm to automatically detect the best precision...
Definition: types.hpp:303
The Ginkgo namespace.
Definition: abstract_factory.hpp:45
std::uint64_t uint64
64-bit unsigned integral type.
Definition: types.hpp:140
constexpr storage_type get_nonpreserving() const noexcept
Returns the number of non-preserving conversions in the encoding.
Definition: types.hpp:291
constexpr precision_reduction() noexcept
Creates a default precision_reduction encoding.
Definition: types.hpp:250
std::int8_t int8
8-bit signed integral type.
Definition: types.hpp:100
std::uint8_t uint8
8-bit unsigned integral type.
Definition: types.hpp:123
std::int64_t int64
64-bit signed integral type.
Definition: types.hpp:117
double full_precision
The most precise floating-point type.
Definition: types.hpp:173
static constexpr precision_reduction common(precision_reduction x, precision_reduction y) noexcept
Returns the common encoding of input encodings.
Definition: types.hpp:319
uint8 storage_type
The underlying datatype used to store the encoding.
Definition: types.hpp:233
std::int16_t int16
16-bit signed integral type.
Definition: types.hpp:105
half float16
Half precision floating point type.
Definition: types.hpp:155
constexpr storage_type get_preserving() const noexcept
Returns the number of preserving conversions in the encoding.
Definition: types.hpp:281