Skip to content

Commit

Permalink
Merge pull request #6106 from crtrott/fix-nvhpc-compilation
Browse files Browse the repository at this point in the history
Fix nvhpc 23.x Compilation
  • Loading branch information
dalg24 committed May 10, 2023
2 parents f15b5ab + 531b01d commit fb0c1b8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
21 changes: 18 additions & 3 deletions core/unit_test/TestJoinBackwardCompatibility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
// unimplemented reduction features
namespace {

// FIXME_NVHPC 23.3 errors out when using enums here
// NVC++-F-0000-Internal compiler error. process_acc_put_dinit: unexpected
// datatype 5339
#ifndef KOKKOS_COMPILER_NVHPC
enum MyErrorCode {
no_error = 0b000,
error_operator_plus_equal = 0b001,
error_operator_plus_equal_volatile = 0b010,
error_join_volatile = 0b100,
expected_join_volatile = 0b1000

};

KOKKOS_FUNCTION constexpr MyErrorCode operator|(MyErrorCode lhs,
Expand All @@ -36,6 +39,17 @@ KOKKOS_FUNCTION constexpr MyErrorCode operator|(MyErrorCode lhs,
static_cast<int>(rhs));
}

#else

using MyErrorCode = unsigned;
constexpr MyErrorCode no_error = 0b000;
constexpr MyErrorCode error_operator_plus_equal = 0b001;
constexpr MyErrorCode error_operator_plus_equal_volatile = 0b010;
constexpr MyErrorCode error_join_volatile = 0b100;
constexpr MyErrorCode expected_join_volatile = 0b1000;

#endif

static_assert((no_error | error_operator_plus_equal_volatile) ==
error_operator_plus_equal_volatile,
"");
Expand Down Expand Up @@ -130,8 +144,9 @@ void test_join_backward_compatibility() {
}

TEST(TEST_CATEGORY, join_backward_compatibility) {
#if defined(KOKKOS_ENABLE_CUDA) && \
defined(KOKKOS_COMPILER_NVHPC) // FIXME_NVHPC
#if defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_NVHPC) && \
KOKKOS_COMPILER_NVHPC < \
230300 // FIXME_NVHPC test passes with workaround in 23.3
GTEST_SKIP() << "FIXME wrong result";
#endif
test_join_backward_compatibility();
Expand Down
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
9 changes: 7 additions & 2 deletions tpls/desul/include/desul/atomics/cuda/CUDA_asm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
namespace desul {
namespace Impl {
// Choose the variant of atomics we are using later
// The __isGlobal intrinsic was only introduced in CUDA 11.2
// It also stopped working in NVC++ 23.1 - it works in 22.11
// this is a bug in NVHPC, not treating CUDA intrinsics correctly
// FIXME_NVHPC
#if !defined(DESUL_IMPL_ATOMIC_CUDA_PTX_PREDICATE) && \
!defined(DESUL_IMPL_ATOMIC_CUDA_PTX_ISGLOBAL)
#if (__CUDACC_VER_MAJOR__ > 11) || \
((__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ > 1))
#if ((__CUDACC_VER_MAJOR__ > 11) || \
((__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ > 1))) && \
(!defined(__NVCOMPILER) || __NVCOMPILER_MAJOR__ < 23)
#define DESUL_IMPL_ATOMIC_CUDA_PTX_ISGLOBAL
#else
#define DESUL_IMPL_ATOMIC_CUDA_PTX_PREDICATE
Expand Down

0 comments on commit fb0c1b8

Please sign in to comment.