Skip to content

Commit

Permalink
Replace _LIBCUDACXX_CPO_ACCESSIBILITY with _CCCL_GLOBAL_CONSTANT
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Jul 30, 2024
1 parent 59d7a4b commit e4d1d1f
Show file tree
Hide file tree
Showing 31 changed files with 83 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct grid_level
using allowed_above = allowed_levels<>;
using allowed_below = allowed_levels<block_level, cluster_level>;
};
_LIBCUDACXX_CPO_ACCESSIBILITY grid_level grid;
_CCCL_GLOBAL_CONSTANT grid_level grid;

/**
* @brief Type representing the cluster level in CUDA thread hierarchy
Expand All @@ -158,7 +158,7 @@ struct cluster_level
using allowed_above = allowed_levels<grid_level>;
using allowed_below = allowed_levels<block_level>;
};
_LIBCUDACXX_CPO_ACCESSIBILITY cluster_level cluster;
_CCCL_GLOBAL_CONSTANT cluster_level cluster;

/**
* @brief Type representing the block level in CUDA thread hierarchy
Expand All @@ -176,7 +176,7 @@ struct block_level
using allowed_above = allowed_levels<grid_level, cluster_level>;
using allowed_below = allowed_levels<thread_level>;
};
_LIBCUDACXX_CPO_ACCESSIBILITY block_level block;
_CCCL_GLOBAL_CONSTANT block_level block;

/**
* @brief Type representing the thread level in CUDA thread hierarchy
Expand All @@ -194,7 +194,7 @@ struct thread_level
using allowed_above = allowed_levels<block_level>;
using allowed_below = allowed_levels<>;
};
_LIBCUDACXX_CPO_ACCESSIBILITY thread_level thread;
_CCCL_GLOBAL_CONSTANT thread_level thread;

template <typename Level>
constexpr bool is_core_cuda_hierarchy_level =
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/__memory_resource/get_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto get_property = __get_property::__fn{};
_CCCL_GLOBAL_CONSTANT auto get_property = __get_property::__fn{};
} // namespace __cpo

_LIBCUDACXX_END_NAMESPACE_CUDA
Expand Down
21 changes: 21 additions & 0 deletions libcudacxx/include/cuda/std/__cccl/dialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,25 @@
# define _CCCL_TRAIT(__TRAIT, ...) __TRAIT<__VA_ARGS__>::value
#endif // _CCCL_STD_VER <= 2014

// In nvcc prior to 11.3 global variables could not be marked constexpr
#if defined(_CCCL_CUDACC_BELOW_11_3)
# define _CCCL_CONSTEXPR_GLOBAL const
#else // ^^^ _CCCL_CUDACC_BELOW_11_3 ^^^ / vvv !_CCCL_CUDACC_BELOW_11_3 vvv
# define _CCCL_CONSTEXPR_GLOBAL constexpr
#endif // !_CCCL_CUDACC_BELOW_11_3

// Inline variables are only available from C++17 onwards
#if _CCCL_STD_VER >= 2017 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L)
# define _CCCL_INLINE_VAR inline
#else // ^^^ C++14 ^^^ / vvv C++17 vvv
# define _CCCL_INLINE_VAR
#endif // _CCCL_STD_VER <= 2014

// We need to treat host and device separately
#if defined(__CUDA_ARCH__)
# define _CCCL_GLOBAL_CONSTANT _CCCL_DEVICE _CCCL_CONSTEXPR_GLOBAL
#else // ^^^ __CUDA_ARCH__ ^^^ / vvv !__CUDA_ARCH__ vvv
# define _CCCL_GLOBAL_CONSTANT _CCCL_INLINE_VAR constexpr
#endif // __CUDA_ARCH__

#endif // __CCCL_DIALECT_H
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__concepts/swappable.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto swap = __swap::__fn{};
_CCCL_GLOBAL_CONSTANT auto swap = __swap::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__expected/unexpect.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct unexpect_t
explicit unexpect_t() = default;
};

_LIBCUDACXX_CPO_ACCESSIBILITY unexpect_t unexpect{};
_CCCL_GLOBAL_CONSTANT unexpect_t unexpect{};

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__iterator/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto begin = __begin::__fn{};
_CCCL_GLOBAL_CONSTANT auto begin = __begin::__fn{};
} // namespace __cpo

namespace __end
Expand Down Expand Up @@ -84,7 +84,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto end = __end::__fn{};
_CCCL_GLOBAL_CONSTANT auto end = __end::__fn{};
} // namespace __cpo

#if _CCCL_STD_VER >= 2014
Expand All @@ -104,7 +104,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto cbegin = __cbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto cbegin = __cbegin::__fn{};
} // namespace __cpo

namespace __cend
Expand All @@ -122,7 +122,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto cend = __cend::__fn{};
_CCCL_GLOBAL_CONSTANT auto cend = __cend::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2014
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/advance.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto advance = __advance::__fn{};
_CCCL_GLOBAL_CONSTANT auto advance = __advance::__fn{};
} // namespace __cpo

_LIBCUDACXX_END_NAMESPACE_RANGES
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto distance = __distance::__fn{};
_CCCL_GLOBAL_CONSTANT auto distance = __distance::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/iter_move.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct __fn
_LIBCUDACXX_END_NAMESPACE_CPO
inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto iter_move = __iter_move::__fn{};
_CCCL_GLOBAL_CONSTANT auto iter_move = __iter_move::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/iter_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto iter_swap = __iter_swap::__fn{};
_CCCL_GLOBAL_CONSTANT auto iter_swap = __iter_swap::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/next.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto next = __next::__fn{};
_CCCL_GLOBAL_CONSTANT auto next = __next::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__iterator/prev.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto prev = __prev::__fn{};
_CCCL_GLOBAL_CONSTANT auto prev = __prev::__fn{};
} // namespace __cpo
_LIBCUDACXX_END_NAMESPACE_RANGES

Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__iterator/reverse_access.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto rbegin = __rbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto rbegin = __rbegin::__fn{};
} // namespace __cpo

namespace __rend
Expand Down Expand Up @@ -104,7 +104,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto rend = __rend::__fn{};
_CCCL_GLOBAL_CONSTANT auto rend = __rend::__fn{};
} // namespace __cpo

namespace __crbegin
Expand All @@ -122,7 +122,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto crbegin = __crbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto crbegin = __crbegin::__fn{};
} // namespace __cpo

namespace __crend
Expand All @@ -140,7 +140,7 @@ struct __fn

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto crend = __crend::__fn{};
_CCCL_GLOBAL_CONSTANT auto crend = __crend::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2014
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct unreachable_sentinel_t : __unreachable_sentinel_detail::__unreachable_bas

_LIBCUDACXX_END_NAMESPACE_RANGES_ABI

_LIBCUDACXX_CPO_ACCESSIBILITY unreachable_sentinel_t unreachable_sentinel{};
_CCCL_GLOBAL_CONSTANT unreachable_sentinel_t unreachable_sentinel{};
_LIBCUDACXX_END_NAMESPACE_STD

#endif // _CCCL_STD_VER > 2014
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ namespace __detail

struct __construct_psa_from_dynamic_exts_values_tag_t
{};
_LIBCUDACXX_CPO_ACCESSIBILITY __construct_psa_from_dynamic_exts_values_tag_t
__construct_psa_from_dynamic_exts_values_tag;
_CCCL_GLOBAL_CONSTANT __construct_psa_from_dynamic_exts_values_tag_t __construct_psa_from_dynamic_exts_values_tag;

struct __construct_psa_from_all_exts_values_tag_t
{};
_LIBCUDACXX_CPO_ACCESSIBILITY __construct_psa_from_all_exts_values_tag_t __construct_psa_from_all_exts_values_tag;
_CCCL_GLOBAL_CONSTANT __construct_psa_from_all_exts_values_tag_t __construct_psa_from_all_exts_values_tag;

struct __construct_psa_from_all_exts_array_tag_t
{};
Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__ranges/access.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto begin = __begin::__fn{};
_CCCL_GLOBAL_CONSTANT auto begin = __begin::__fn{};
} // namespace __cpo

// [range.range]
Expand Down Expand Up @@ -213,7 +213,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto end = __end::__fn{};
_CCCL_GLOBAL_CONSTANT auto end = __end::__fn{};
} // namespace __cpo

// [range.access.cbegin]
Expand Down Expand Up @@ -243,7 +243,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto cbegin = __cbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto cbegin = __cbegin::__fn{};
} // namespace __cpo

// [range.access.cend]
Expand Down Expand Up @@ -273,7 +273,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto cend = __cend::__fn{};
_CCCL_GLOBAL_CONSTANT auto cend = __cend::__fn{};
} // namespace __cpo
#endif // _CCCL_STD_VER > 2014 && !_CCCL_COMPILER_MSVC_2017

Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto data = __data::__fn{};
_CCCL_GLOBAL_CONSTANT auto data = __data::__fn{};
} // namespace __cpo

// [range.prim.cdata]
Expand Down Expand Up @@ -127,7 +127,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto cdata = __cdata::__fn{};
_CCCL_GLOBAL_CONSTANT auto cdata = __cdata::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER_MSVC_2017
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__ranges/empty.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto empty = __empty::__fn{};
_CCCL_GLOBAL_CONSTANT auto empty = __empty::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER_MSVC_2017
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/rbegin.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto rbegin = __rbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto rbegin = __rbegin::__fn{};
} // namespace __cpo

// [range.access.crbegin]
Expand Down Expand Up @@ -160,7 +160,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto crbegin = __crbegin::__fn{};
_CCCL_GLOBAL_CONSTANT auto crbegin = __crbegin::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && && !_CCCL_COMPILER_MSVC_2017
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/rend.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto rend = __rend::__fn{};
_CCCL_GLOBAL_CONSTANT auto rend = __rend::__fn{};
} // namespace __cpo

// [range.access.crend]
Expand Down Expand Up @@ -167,7 +167,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto crend = __crend::__fn{};
_CCCL_GLOBAL_CONSTANT auto crend = __crend::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER_MSVC_2017
Expand Down
4 changes: 2 additions & 2 deletions libcudacxx/include/cuda/std/__ranges/size.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto size = __size::__fn{};
_CCCL_GLOBAL_CONSTANT auto size = __size::__fn{};
} // namespace __cpo

// [range.prim.ssize]
Expand Down Expand Up @@ -198,7 +198,7 @@ _LIBCUDACXX_END_NAMESPACE_CPO

inline namespace __cpo
{
_LIBCUDACXX_CPO_ACCESSIBILITY auto ssize = __ssize::__fn{};
_CCCL_GLOBAL_CONSTANT auto ssize = __ssize::__fn{};
} // namespace __cpo

#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER_MSVC_2017
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__utility/in_place.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct _LIBCUDACXX_TYPE_VIS in_place_t
{
explicit in_place_t() = default;
};
_LIBCUDACXX_CPO_ACCESSIBILITY in_place_t in_place{};
_CCCL_GLOBAL_CONSTANT in_place_t in_place{};

template <class _Tp>
struct _LIBCUDACXX_TEMPLATE_VIS in_place_type_t
Expand Down
13 changes: 0 additions & 13 deletions libcudacxx/include/cuda/std/detail/libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -1743,19 +1743,6 @@ __sanitizer_annotate_contiguous_container(const void*, const void*, const void*,
# define _LIBCUDACXX_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
# endif

# if (defined(__CUDACC_VER_MAJOR__) && __CUDACC_VER_MAJOR__ <= 11) \
&& (defined(__CUDACC_VER_MINOR__) && __CUDACC_VER_MINOR__ <= 2)
# define _LIBCUDACXX_CONSTEXPR_GLOBAL const
# else
# define _LIBCUDACXX_CONSTEXPR_GLOBAL constexpr
# endif

# if defined(__CUDA_ARCH__)
# define _LIBCUDACXX_CPO_ACCESSIBILITY _CCCL_DEVICE _LIBCUDACXX_CONSTEXPR_GLOBAL
# else
# define _LIBCUDACXX_CPO_ACCESSIBILITY _LIBCUDACXX_INLINE_VAR constexpr
# endif

// Older nvcc do not handle the constraint of `construct_at` in earlier std modes
// So to preserve our performance optimization we default to the unconstrained
// `__construct_at` and only in C++20 use `construct_at`
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/detail/libcxx/include/optional
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct nullopt_t
_LIBCUDACXX_INLINE_VISIBILITY constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {}
};

_LIBCUDACXX_CPO_ACCESSIBILITY nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};
_CCCL_GLOBAL_CONSTANT nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}};

struct __optional_construct_from_invoke_tag
{};
Expand Down
Loading

0 comments on commit e4d1d1f

Please sign in to comment.