19#ifndef OPM_CUISTL_SAFE_CONVERSION_HPP
20#define OPM_CUISTL_SAFE_CONVERSION_HPP
25#include <fmt/format.h>
27#include <opm/common/ErrorMacros.hpp>
29#include <cuda_runtime.h>
55 std::is_signed_v<int>,
56 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
58 !std::is_signed_v<std::size_t>,
59 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
62 sizeof(
int) <=
sizeof(std::size_t),
63 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
66 if (s > std::size_t(std::numeric_limits<int>::max())) {
68 fmt::format(
"Trying to convert {} to int, but it is out of range. Maximum possible int: {}. ",
70 std::numeric_limits<int>::max()));
89 std::is_signed_v<int>,
90 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
92 !std::is_signed_v<std::size_t>,
93 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
96 sizeof(
int) <=
sizeof(std::size_t),
97 "Weird architecture or my understanding of the standard is flawed. Better have a look at this function.");
99#if defined(__CUDA_ARCH__) || defined(__HIP_DEVICE_COMPILE__)
103 OPM_THROW(std::invalid_argument, fmt::format(
"Trying to convert the negative number {} to size_t.", i));
107 return std::size_t(i);
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition autotuner.hpp:29
int to_int(std::size_t s)
to_int converts a (on most relevant platforms) 64 bits unsigned size_t to a signed 32 bits signed int
Definition safe_conversion.hpp:52
__host__ __device__ std::size_t to_size_t(int i)
to_size_t converts a (on most relevant platforms) a 32 bit signed int to a 64 bits unsigned int
Definition safe_conversion.hpp:86
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242