Skip to content

Commit

Permalink
add ifdefs to enable NVHPC as device compiler (#3801)
Browse files Browse the repository at this point in the history
## Summary
This works around limitations in the NVHPC device compiler by disabling
`int128` support and avoiding a static local device variable. This
enables experimental use of NVHPC 24.3+ as the unified host and device
compiler for CUDA.

## Additional background
#3591
  • Loading branch information
BenWibking authored Mar 14, 2024
1 parent 5c849fd commit 201e6a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Src/Base/AMReX_Algorithm.H
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ int clz (T x) noexcept;
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
int clz_generic (std::uint8_t x) noexcept
{
#if !defined(__NVCOMPILER)
static constexpr int clz_lookup[16] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
#else
constexpr int clz_lookup[16] = { 4, 3, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
#endif
auto upper = x >> 4;
auto lower = x & 0xF;
return upper ? clz_lookup[upper] : 4 + clz_lookup[lower];
Expand Down
2 changes: 1 addition & 1 deletion Src/Base/AMReX_INT.H
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace amrex {
}
#endif

#if (defined(__x86_64) || defined (__aarch64__)) && !defined(_WIN32) && (defined(__GNUC__) || defined(__clang__))
#if (defined(__x86_64) || defined (__aarch64__)) && !defined(_WIN32) && (defined(__GNUC__) || defined(__clang__)) && !defined(__NVCOMPILER)

#define AMREX_INT128_SUPPORTED 1

Expand Down

0 comments on commit 201e6a9

Please sign in to comment.