Merge pull request #5593 from multitalentloes/fix_macro_todo

reolve gpuistl macro todo
This commit is contained in:
Arne Morten Kvarving 2024-09-10 20:10:30 +02:00 committed by GitHub
commit 7fb5260e53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,7 @@
#include <opm/common/ErrorMacros.hpp> #include <opm/common/ErrorMacros.hpp>
#include <opm/common/utility/gpuDecorators.hpp>
#include <opm/simulators/linalg/gpuistl/detail/safe_conversion.hpp> #include <opm/simulators/linalg/gpuistl/detail/safe_conversion.hpp>
#include <stdexcept> #include <stdexcept>
@ -30,13 +31,6 @@
#include <fmt/core.h> #include <fmt/core.h>
// TODO: remove this line and instead include gpuDecorators.hpp from OPM common when it gets added
#if defined(__CUDA_ARCH__) || (defined(__HIP_DEVICE_COMPILE__) && __HIP_DEVICE_COMPILE__ > 0)
#define OPM_IS_INSIDE_DEVICE_FUNCTION_TEMPORARY 1
#else
#define OPM_IS_INSIDE_DEVICE_FUNCTION_TEMPORARY 0
#endif
namespace Opm::gpuistl namespace Opm::gpuistl
{ {
@ -371,7 +365,7 @@ private:
/// @param size The value to compare with the size of this view /// @param size The value to compare with the size of this view
__host__ __device__ void assertSameSize(size_t size) const __host__ __device__ void assertSameSize(size_t size) const
{ {
#if OPM_IS_INSIDE_DEVICE_FUNCTION_TEMPORARY #if OPM_IS_INSIDE_DEVICE_FUNCTION
// TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times // TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times
assert(size == m_numberOfElements && "Views did not have the same size"); assert(size == m_numberOfElements && "Views did not have the same size");
#else #else
@ -385,7 +379,7 @@ private:
/// @brief Helper function to assert that the view has at least one element /// @brief Helper function to assert that the view has at least one element
__host__ __device__ void assertHasElements() const __host__ __device__ void assertHasElements() const
{ {
#if OPM_IS_INSIDE_DEVICE_FUNCTION_TEMPORARY #if OPM_IS_INSIDE_DEVICE_FUNCTION
// TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times // TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times
assert(m_numberOfElements > 0 && "View has 0 elements"); assert(m_numberOfElements > 0 && "View has 0 elements");
#else #else
@ -398,7 +392,7 @@ private:
/// @brief Helper function to determine if an index is within the range of valid indexes in the view /// @brief Helper function to determine if an index is within the range of valid indexes in the view
__host__ __device__ void assertInRange(size_t idx) const __host__ __device__ void assertInRange(size_t idx) const
{ {
#if OPM_IS_INSIDE_DEVICE_FUNCTION_TEMPORARY #if OPM_IS_INSIDE_DEVICE_FUNCTION
// TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times // TODO: find a better way to handle exceptions in kernels, this will possibly be printed many times
assert(idx < m_numberOfElements && "The index provided was not in the range [0, buffersize-1]"); assert(idx < m_numberOfElements && "The index provided was not in the range [0, buffersize-1]");
#else #else