Skip to content

Commit

Permalink
Fix 'nvc++ -stdpar'
Browse files Browse the repository at this point in the history
NVC++ stdpar mode enables CUDA support but does not define the macro
`__CUDACC__`.  Any code in CCCL (which is used by NVC++ stdpar under the
covers) needs to check for either `__CUDACC__` or `_NVHPC_CUDA` being
set.

NVIDIA#1199 only checks for `__CUDACC__`
when defining `_CCCL_HOST` and `_CCCL_DEVICE` and some other macros.
This change completely broke `nvc++ -stdpar` because all functions
became unannotated host functions.

Fix this by changing several files in
libcudacxx/include/cuda/std/detail/libcxx/include to check for either
`__CUDACC__` or `_NVHPC_CUDA`.
  • Loading branch information
dkolsen-pgi committed Dec 16, 2023
1 parent a931e9a commit 97ada72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#ifndef __CCCL_EXECUTION_SPACE_H
#define __CCCL_EXECUTION_SPACE_H

#ifdef __CUDACC__
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
# define _CCCL_HOST __host__
# define _CCCL_DEVICE __device__
# define _CCCL_HOST_DEVICE __host__ __device__
# define _CCCL_FORCEINLINE __forceinline__
#else // ^^^ __CUDACC__ ^^^ / vvv !__CUDACC__
#else // ^^^ __CUDACC__ || _NVHPC_CUDA ^^^ / vvv !__CUDACC__ && !_NVHPC_CUDA
# define _CCCL_HOST
# define _CCCL_DEVICE
# define _CCCL_HOST_DEVICE
# define _CCCL_FORCEINLINE
#endif // !__CUDACC__
#endif // !__CUDACC__ && !_NVHPC_CUDA

#if !defined(_CCCL_EXEC_CHECK_DISABLE)
# if defined(_CCCL_COMPILER_NVRTC) || defined(_CCCL_CUDA_COMPILER_NVHPC) || defined(_CCCL_CUDA_COMPILER_CLANG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
#endif // !_CCCL_COMPILER_CLANG && !_CCCL_COMPILER_GCC

// Enable us to selectively silence cuda compiler warnings
#if defined(__CUDACC__)
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
# if !defined(_CCCL_CUDA_COMPILER_CLANG)
# define _CCCL_NV_DIAG_SUPPRESS(_WARNING)
# define _CCCL_NV_DIAG_DEFAULT(_WARNING)
Expand Down Expand Up @@ -160,7 +160,7 @@
# define _CCCL_NV_DIAG_DEFAULT(_WARNING) _Pragma(_CCCL_TOSTRING(diag_default _WARNING))
# endif // !_CCCL_COMPILER_MSVC
# endif // !__NVCC_DIAG_PRAGMA_SUPPORT__
#else // ^^^ __CUDACC__ ^^^ / vvv !__CUDACC__ vvv
#else // ^^^ __CUDACC__ || _NVHPC_CUDA ^^^ / vvv !__CUDACC__ && !_NVHPC_CUDA vvv
# define _CCCL_NV_DIAG_SUPPRESS(_WARNING)
# define _CCCL_NV_DIAG_DEFAULT(_WARNING)
#endif // other compilers
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/detail/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
# define _LIBCUDACXX_COMPILER_CLANG_CUDA
#endif

#ifdef __CUDACC__
#if defined(__CUDACC__) || defined(_NVHPC_CUDA)
# define _LIBCUDACXX_CUDACC
# define _LIBCUDACXX_CUDACC_VER_MAJOR __CUDACC_VER_MAJOR__
# define _LIBCUDACXX_CUDACC_VER_MINOR __CUDACC_VER_MINOR__
Expand Down

0 comments on commit 97ada72

Please sign in to comment.