Skip to content

Commit

Permalink
Move cccl global logic into a __cccl_config
Browse files Browse the repository at this point in the history
We just reused the libcu++ config, but going forward we want to move more common parts into a unified config.
  • Loading branch information
miscco committed Oct 11, 2023
1 parent b7e6717 commit 1dd8286
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cub/cub/config.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#pragma once

// For `_CCCL_IMPLICIT_SYSTEM_HEADER`
#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down
2 changes: 1 addition & 1 deletion cub/cub/detail/detect_cuda_runtime.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#pragma once

// We cannot use `cub/config.cuh` here due to circular dependencies
#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down
2 changes: 1 addition & 1 deletion cub/cub/util_compiler.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#pragma once

// For `_CCCL_IMPLICIT_SYSTEM_HEADER`
#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down
2 changes: 1 addition & 1 deletion cub/cub/util_cpp_dialect.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#pragma once

#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down
2 changes: 1 addition & 1 deletion cub/cub/version.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#pragma once

// For `_CCCL_IMPLICIT_SYSTEM_HEADER`
#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down
16 changes: 16 additions & 0 deletions libcudacxx/include/cuda/__cccl_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//

#ifndef _CUDA__CCCL_CONFIG
#define _CUDA__CCCL_CONFIG

#include "std/detail/libcxx/include/__cccl_config"

#endif // _CUDA__CCCL_CONFIG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(files
__bsd_locale_defaults.h
__bsd_locale_fallbacks.h
__errc
__cccl_config
__concepts/__concept_macros.h
__concepts/_One_of.h
__concepts/arithmetic.h
Expand Down
55 changes: 55 additions & 0 deletions libcudacxx/include/cuda/std/detail/libcxx/include/__cccl_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// Part of libcu++, the C++ Standard Library for your entire system,
// under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//

#ifndef __CCCL_CONFIG
#define __CCCL_CONFIG

// Determine the host compiler
#if defined(__NVCOMPILER)
# define _CCCL_COMPILER_NVHPC
#elif defined(__clang__)
# define _CCCL_COMPILER_CLANG
#elif defined(__GNUC__)
# define _CCCL_COMPILER_GCC
#elif defined(_MSC_VER)
# define _CCCL_COMPILER_MSVC
#elif defined(__IBMCPP__)
# define _CCCL_COMPILER_IBM
#elif defined(__CUDACC_RTC__)
# define _CCCL_COMPILER_NVRTC
#endif

// Ensure cccl headers are treated as system headers when possible
#if defined(_CCCL_NO_SYSTEM_HEADER)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_CCCL_COMPILER_MSVC) \
&& defined(_LIBCUDACXX_DISABLE_PRAGMA_MSVC_WARNING)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_CCCL_COMPILER_NVRTC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_LIBCUDACXX_DISABLE_PRAGMA_GCC_SYSTEM_HEADER)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#else
# if defined(_CCCL_COMPILER_GCC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("GCC system_header")
# elif defined(_CCCL_COMPILER_CLANG)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("clang system_header")
# elif defined(_CCCL_COMPILER_MSVC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER __pragma(system_header)
# elif defined(_CCCL_COMPILER_NVHPC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("GCC system_header")
# else
# define _CCCL_IMPLICIT_SYSTEM_HEADER
# endif
#endif

_CCCL_IMPLICIT_SYSTEM_HEADER

#endif // __CCCL_CONFIG
30 changes: 4 additions & 26 deletions libcudacxx/include/cuda/std/detail/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#ifndef _LIBCUDACXX_CONFIG
#define _LIBCUDACXX_CONFIG

#include "__cccl_config"

_CCCL_IMPLICIT_SYSTEM_HEADER

#if defined(__NVCOMPILER)
# define _LIBCUDACXX_COMPILER_NVHPC
#elif defined(__clang__)
Expand Down Expand Up @@ -83,32 +87,6 @@
# endif // !_LIBCUDACXX_DISABLE_PRAGMA_MSVC_WARNING
#endif // _LIBCUDACXX_COMPILER_MSVC

// allow disabling use as system header for testing
#if defined(_CCCL_NO_SYSTEM_HEADER)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_LIBCUDACXX_COMPILER_MSVC) \
&& defined(_LIBCUDACXX_DISABLE_PRAGMA_MSVC_WARNING)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_LIBCUDACXX_COMPILER_NVRTC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#elif defined(_LIBCUDACXX_DISABLE_PRAGMA_GCC_SYSTEM_HEADER)
# define _CCCL_IMPLICIT_SYSTEM_HEADER
#else
# if defined(_LIBCUDACXX_COMPILER_GCC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("GCC system_header")
# elif defined(_LIBCUDACXX_COMPILER_CLANG)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("clang system_header")
# elif defined(_LIBCUDACXX_COMPILER_MSVC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER __pragma(system_header)
# elif defined(_LIBCUDACXX_COMPILER_NVHPC)
# define _CCCL_IMPLICIT_SYSTEM_HEADER _Pragma("GCC system_header")
# else
# define _CCCL_IMPLICIT_SYSTEM_HEADER
# endif
#endif

_CCCL_IMPLICIT_SYSTEM_HEADER

#ifdef __cplusplus

// __config may be included in `extern "C"` contexts, switch back to include <nv/target>
Expand Down
2 changes: 1 addition & 1 deletion thrust/thrust/detail/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#pragma once

// Include libcu++ config to get _CCCL_IMPLICIT_SYSTEM_HEADER
#include <cuda/std/detail/__config>
#include <cuda/__cccl_config>

_CCCL_IMPLICIT_SYSTEM_HEADER

Expand Down

0 comments on commit 1dd8286

Please sign in to comment.