Skip to content
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions libcudacxx/include/nv/target
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,45 @@
// CUDA C++ development with NVC++, NVCC, and supported host compilers.
// These interfaces are not guaranteed to be stable.

// If compiling with nvrtc and there is another <nv/target> in the include path and comes from newer cccl, we skip the
// builtin header and use the newer <nv/target> instead.
#if !defined(__NV_TARGET_H) && !defined(_NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER)
# if defined(__CUDACC_RTC__) && __has_include(<cuda/std/__cccl/version.h>) && __has_include(<nv/target>)
// Include just the cccl version header, if we would include the whole <cuda/__cccl_config>, we would include
// <nv/target> as well as current workarounds for missing nvrtc nv target macros.
# include <cuda/std/__cccl/version.h>
// nvrtc major version is 10 less than the cccl version.
# if (CCCL_MAJOR_VERSION > (__CUDACC_VER_MAJOR__ - 10)) \
|| (CCCL_MAJOR_VERSION == (__CUDACC_VER_MAJOR__ - 10) && CCCL_MINOR_VERSION > __CUDACC_VER_MINOR__)
// _NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER forces this prologue for nvrtc to be skipped.
# define _NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER
# include <nv/target>
# undef _NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER
# endif // ^^^ use <nv/target> include ^^^
# endif // nvrtc && cccl in include path
#endif // !__NV_TARGET_H && !_NV_TARGET_SKIPPING_NVRTC_BUILTIN_HEADER

#ifndef __NV_TARGET_H
#define __NV_TARGET_H
# define __NV_TARGET_H

#if defined(__NVCC__) || defined(__CUDACC_RTC__)
# define _NV_COMPILER_NVCC
#elif defined(__NVCOMPILER) && __cplusplus >= 201103L
# define _NV_COMPILER_NVCXX
#elif defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
# if defined(__NVCC__) || defined(__CUDACC_RTC__)
# define _NV_COMPILER_NVCC
# elif defined(__NVCOMPILER) && __cplusplus >= 201103L
# define _NV_COMPILER_NVCXX
# elif defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__)
// clang compiling CUDA code, device mode.
# define _NV_COMPILER_CLANG_CUDA
#endif
# define _NV_COMPILER_CLANG_CUDA
# endif

// Hide `if target` support from NVRTC and C
// Some toolkit headers use <nv/target> in true C contexts
#if !defined(__CUDACC_RTC__) && defined(__cplusplus)
# if !defined(__CUDACC_RTC__) && defined(__cplusplus)

# if defined(_NV_COMPILER_NVCXX)
# define _NV_BITSET_ATTRIBUTE [[nv::__target_bitset]]
# else
# define _NV_BITSET_ATTRIBUTE
# endif
# if defined(_NV_COMPILER_NVCXX)
# define _NV_BITSET_ATTRIBUTE [[nv::__target_bitset]]
# else
# define _NV_BITSET_ATTRIBUTE
# endif

namespace nv::target
{
Expand Down Expand Up @@ -234,8 +252,8 @@ using detail::is_exactly;
using detail::provides;
} // namespace nv::target

#endif // C++ && !defined(__CUDACC_RTC__)
# endif // C++ && !defined(__CUDACC_RTC__)

#include <nv/detail/__target_macros>
# include <nv/detail/__target_macros>

#endif // __NV_TARGET_H
Loading