Skip to content

Commit

Permalink
Work around NVHPC 23.x issues
Browse files Browse the repository at this point in the history
Works around long double usage in device code being treated stricter,
and now needing a workaround similar to NVCC for implementation of
traits and constants.
  • Loading branch information
crtrott committed May 5, 2023
1 parent ea134de commit 60b982a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/unit_test/TestMathematicalConstants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct TestMathematicalConstants {

KOKKOS_FUNCTION void use_on_device() const {
#if defined(KOKKOS_COMPILER_NVCC) || defined(KOKKOS_ENABLE_OPENMPTARGET) || \
defined(KOKKOS_ENABLE_OPENACC)
defined(KOKKOS_ENABLE_OPENACC) || defined(KOKKOS_COMPILER_NVHPC)
take_by_value(Trait::value);
#else
(void)take_address_of(Trait::value);
Expand Down
10 changes: 9 additions & 1 deletion core/unit_test/TestNumericTraits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ struct extrema {

DEFINE_EXTREMA(float, -FLT_MAX, FLT_MAX);
DEFINE_EXTREMA(double, -DBL_MAX, DBL_MAX);

// FIXME_NVHPC: with 23.3 using long double in KOKKOS_FUNCTION is hard error
#if !defined(KOKKOS_ENABLE_CUDA) && !defined(KOKKOS_COMPILER_NVHPC)
DEFINE_EXTREMA(long double, -LDBL_MAX, LDBL_MAX);
#else
static long double min(long double) { return -LDBL_MAX; }
static long double max(long double) { return LDBL_MAX; }
#endif

#undef DEFINE_EXTREMA
};
Expand Down Expand Up @@ -163,7 +170,8 @@ struct TestNumericTraits {
}

KOKKOS_FUNCTION void use_on_device() const {
#if defined(KOKKOS_COMPILER_NVCC) || defined(KOKKOS_ENABLE_OPENMPTARGET)
#if defined(KOKKOS_COMPILER_NVCC) || defined(KOKKOS_COMPILER_NVHPC) || \
defined(KOKKOS_ENABLE_OPENMPTARGET) || defined(KOKKOS_ENABLE_OPENACC)
take_by_value(trait<T>::value);
#else
(void)take_address_of(trait<T>::value);
Expand Down

0 comments on commit 60b982a

Please sign in to comment.