Skip to content

Commit

Permalink
Try to reenable more builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Sep 27, 2024
1 parent ac70407 commit d3f48b7
Show file tree
Hide file tree
Showing 31 changed files with 327 additions and 303 deletions.
4 changes: 2 additions & 2 deletions cudax/include/cuda/experimental/__async/meta.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,13 @@ using __m_at = _Ts...[__v<_Np>];
template <size_t _Np, class... _Ts>
using __m_at_c = _Ts...[_Np];

#elif __has_builtin(__type_pack_element)
#elif defined(_CCCL_BUILTIN_TYPE_PACK_ELEMENT)

template <bool>
struct __m_at_
{
template <class _Np, class... _Ts>
using __f = __type_pack_element<__v<_Np>, _Ts...>;
using __f = _CCCL_BUILTIN_TYPE_PACK_ELEMENT(__v<_Np>, _Ts...);
};

template <class _Np, class... _Ts>
Expand Down
21 changes: 4 additions & 17 deletions cudax/include/cuda/experimental/__async/type_traits.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,13 @@

namespace cuda::experimental::__async
{
#if __has_builtin(__remove_reference)

template <class _Ty>
using __remove_ref_t = __remove_reference(_Ty);

#elif __has_builtin(__remove_reference_t)

template <class _Ty>
using __remove_ref_t = __remove_reference_t(_Ty);

#else

template <class _Ty>
using __remove_ref_t = _CUDA_VSTD::remove_reference_t<_Ty>;

#endif
using __remove_ref_t = _CUDA_VSTD::__libcpp_remove_reference_t<_Ty>;

//////////////////////////////////////////////////////////////////////////////////////////////////
// __decay_t: An efficient implementation for ::std::decay
#if __has_builtin(__decay)
#if defined(_CCCL_BUILTIN_DECAY)

template <class _Ty>
using __decay_t = __decay(_Ty);
Expand All @@ -59,7 +46,7 @@ using __decay_t = __decay(_Ty);
// template <class _Ty>
// using __decay_t = _CUDA_VSTD::decay_t<_Ty>;

#else
#else // ^^^ _CCCL_BUILTIN_DECAY ^^^ / vvv !_CCCL_BUILTIN_DECAY vvv

struct __decay_object
{
Expand Down Expand Up @@ -141,7 +128,7 @@ inline __decay_void __mdecay<void const>;
template <class _Ty>
using __decay_t = typename decltype(__mdecay<_Ty>)::template __f<_Ty>;

#endif
#endif // _CCCL_BUILTIN_DECAY

//////////////////////////////////////////////////////////////////////////////////////////////////
// __copy_cvref_t: For copying cvref from one type to another
Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__algorithm/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ template <class _Tp, class _Up>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 bool __constexpr_tail_overlap(_Tp* __first, _Up* __needle, _Tp* __last)
{
_LIBCUDACXX_UNUSED_VAR(__last);
#if __has_builtin(__builtin_constant_p) || defined(_CCCL_COMPILER_GCC)
#if defined(_CCCL_BUILTIN_CONSTANT_P)
NV_IF_ELSE_TARGET(NV_IS_HOST,
(return __builtin_constant_p(__first < __needle) && __first < __needle;),
(return _CCCL_BUILTIN_CONSTANT_P(__first < __needle) && __first < __needle;),
(return __constexpr_tail_overlap_fallback(__first, __needle, __last);))
#else
#else // ^^^ _CCCL_BUILTIN_CONSTANT_P ^^^ / vvv !_CCCL_BUILTIN_CONSTANT_P vvv
return __constexpr_tail_overlap_fallback(__first, __needle, __last);
#endif
#endif // !_CCCL_BUILTIN_CONSTANT_P
}

template <class _AlgPolicy,
Expand Down
286 changes: 175 additions & 111 deletions libcudacxx/include/cuda/std/__cccl/builtin.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__memory/addressof.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _LIBCUDACXX_BEGIN_NAMESPACE_STD
template <class _Tp>
_LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _LIBCUDACXX_NO_CFI _Tp* addressof(_Tp& __x) noexcept
{
return __builtin_addressof(__x);
return _CCCL_BUILTIN_ADDRESSOF(__x);
}

#else
Expand Down
16 changes: 8 additions & 8 deletions libcudacxx/include/cuda/std/__new/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,22 @@ template <class... _Args>
_LIBCUDACXX_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args)
{
// Those builtins are not usable on device and the tests crash when using them
#if 0 && __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
return __builtin_operator_new(__args...);
#else // ^^^ use builtin ^^^ / vvv no builtin
#if defined(_CCCL_BUILTIN_OPERATOR_NEW)
return _CCCL_BUILTIN_OPERATOR_NEW(__args...);
#else // ^^^ _CCCL_BUILTIN_OPERATOR_NEW ^^^ / vvv !_CCCL_BUILTIN_OPERATOR_NEW vvv
return ::operator new(__args...);
#endif // !__builtin_operator_new || !__builtin_operator_delete
#endif // !_CCCL_BUILTIN_OPERATOR_NEW
}

template <class... _Args>
_LIBCUDACXX_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args)
{
// Those builtins are not usable on device and the tests crash when using them
#if 0 && __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
__builtin_operator_delete(__args...);
#else // ^^^ use builtin ^^^ / vvv no builtin
#if defined(_CCCL_BUILTIN_OPERATOR_DELETE)
_CCCL_BUILTIN_OPERATOR_DELETE(__args...);
#else // ^^^ _CCCL_BUILTIN_OPERATOR_DELETE ^^^ / vvv !_CCCL_BUILTIN_OPERATOR_DELETE vvv
::operator delete(__args...);
#endif // !__builtin_operator_new || !__builtin_operator_delete
#endif // !_CCCL_BUILTIN_OPERATOR_DELETE
}

_LIBCUDACXX_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align)
Expand Down
2 changes: 1 addition & 1 deletion libcudacxx/include/cuda/std/__new/launder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _CCCL_NODISCARD _LIBCUDACXX_HIDE_FROM_ABI _CCCL_CONSTEXPR_CXX14 _Tp* launder(_Tp
return _CCCL_BUILTIN_LAUNDER(__p);
#else
return __p;
#endif // defined(_CCCL_BUILTIN_LAUNDER)
#endif // _CCCL_BUILTIN_LAUNDER
}

_LIBCUDACXX_END_NAMESPACE_STD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_ADD_LVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_LVALUE_REFERENCE_FALLBACK)
#if defined(_CCCL_BUILTIN_ADD_LVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_LVALUE_REFERENCE_FALLBACK)

template <class _Tp>
using __add_lvalue_reference_t = _LIBCUDACXX_ADD_LVALUE_REFERENCE(_Tp);
using __add_lvalue_reference_t = _CCCL_BUILTIN_ADD_LVALUE_REFERENCE(_Tp);

#else
#else // ^^^ _CCCL_BUILTIN_ADD_LVALUE_REFERENCE ^^^ / vvv !_CCCL_BUILTIN_ADD_LVALUE_REFERENCE vvv

template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
struct __add_lvalue_reference_impl
Expand All @@ -45,7 +45,7 @@ struct __add_lvalue_reference_impl<_Tp, true>
template <class _Tp>
using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type;

#endif // defined(_LIBCUDACXX_ADD_LVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_LVALUE_REFERENCE_FALLBACK)
#endif // !_CCCL_BUILTIN_ADD_LVALUE_REFERENCE

template <class _Tp>
struct add_lvalue_reference
Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__type_traits/add_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_ADD_POINTER) && !defined(_LIBCUDACXX_USE_ADD_POINTER_FALLBACK)
#if defined(_CCCL_BUILTIN_ADD_POINTER) && !defined(_LIBCUDACXX_USE_ADD_POINTER_FALLBACK)

template <class _Tp>
using __add_pointer_t = _LIBCUDACXX_ADD_POINTER(_Tp);
using __add_pointer_t = _CCCL_BUILTIN_ADD_POINTER(_Tp);

#else
#else // ^^^ _CCCL_BUILTIN_ADD_POINTER ^^^ / vvv !_CCCL_BUILTIN_ADD_POINTER vvv
template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>
struct __add_pointer_impl
{
Expand All @@ -48,7 +48,7 @@ struct __add_pointer_impl<_Tp, false>
template <class _Tp>
using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;

#endif // defined(_LIBCUDACXX_ADD_POINTER) && !defined(_LIBCUDACXX_USE_ADD_POINTER_FALLBACK)
#endif // !_CCCL_BUILTIN_ADD_POINTER

template <class _Tp>
struct add_pointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_ADD_RVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_RVALUE_REFERENCE_FALLBACK)
#if defined(_CCCL_BUILTIN_ADD_RVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_RVALUE_REFERENCE_FALLBACK)

template <class _Tp>
using __add_rvalue_reference_t = _LIBCUDACXX_ADD_RVALUE_REFERENCE(_Tp);
using __add_rvalue_reference_t = _CCCL_BUILTIN_ADD_RVALUE_REFERENCE(_Tp);

#else
#else // ^^^ _CCCL_BUILTIN_ADD_RVALUE_REFERENCE ^^^ / vvv !_CCCL_BUILTIN_ADD_RVALUE_REFERENCE vvv

template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
struct __add_rvalue_reference_impl
Expand All @@ -45,7 +45,7 @@ struct __add_rvalue_reference_impl<_Tp, true>
template <class _Tp>
using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type;

#endif // defined(_LIBCUDACXX_ADD_RVALUE_REFERENCE) && !defined(_LIBCUDACXX_USE_ADD_RVALUE_REFERENCE_FALLBACK)
#endif // _CCCL_BUILTIN_ADD_RVALUE_REFERENCE

template <class _Tp>
struct add_rvalue_reference
Expand Down
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__type_traits/extent.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_ARRAY_EXTENT) && !defined(_LIBCUDACXX_USE_ARRAY_EXTENT_FALLBACK)
#if defined(_CCCL_BUILTIN_ARRAY_EXTENT) && !defined(_LIBCUDACXX_USE_ARRAY_EXTENT_FALLBACK)

template <class _Tp, size_t _Dim = 0>
struct _CCCL_TYPE_VISIBILITY_DEFAULT extent : integral_constant<size_t, _LIBCUDACXX_ARRAY_EXTENT(_Tp, _Dim)>
struct _CCCL_TYPE_VISIBILITY_DEFAULT extent : integral_constant<size_t, _CCCL_BUILTIN_ARRAY_EXTENT(_Tp, _Dim)>
{};

# if _CCCL_STD_VER > 2011 && !defined(_LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp, unsigned _Ip = 0>
_LIBCUDACXX_INLINE_VAR constexpr size_t extent_v = _LIBCUDACXX_ARRAY_EXTENT(_Tp, _Ip);
_LIBCUDACXX_INLINE_VAR constexpr size_t extent_v = _CCCL_BUILTIN_ARRAY_EXTENT(_Tp, _Ip);
# endif

#else
#else // ^^^ _CCCL_BUILTIN_ARRAY_EXTENT ^^^ / vvv !_CCCL_BUILTIN_ARRAY_EXTENT vvv

template <class _Tp, unsigned _Ip = 0>
struct _CCCL_TYPE_VISIBILITY_DEFAULT extent : public integral_constant<size_t, 0>
Expand All @@ -61,7 +61,7 @@ template <class _Tp, unsigned _Ip = 0>
_LIBCUDACXX_INLINE_VAR constexpr size_t extent_v = extent<_Tp, _Ip>::value;
# endif

#endif // defined(_LIBCUDACXX_ARRAY_EXTENT) && !defined(_LIBCUDACXX_USE_ARRAY_EXTENT_FALLBACK)
#endif // !_CCCL_BUILTIN_ARRAY_EXTENT

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__type_traits/is_compound.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_IS_COMPOUND) && !defined(_LIBCUDACXX_USE_IS_COMPOUND_FALLBACK)
#if defined(_CCCL_BUILTIN_IS_COMPOUND) && !defined(_LIBCUDACXX_USE_IS_COMPOUND_FALLBACK)

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_compound : public integral_constant<bool, _LIBCUDACXX_IS_COMPOUND(_Tp)>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_compound : public integral_constant<bool, _CCCL_BUILTIN_IS_COMPOUND(_Tp)>
{};

# if _CCCL_STD_VER > 2011 && !defined(_LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_compound_v = _LIBCUDACXX_IS_COMPOUND(_Tp);
_LIBCUDACXX_INLINE_VAR constexpr bool is_compound_v = _CCCL_BUILTIN_IS_COMPOUND(_Tp);
# endif

#else
#else // ^^^ _CCCL_BUILTIN_IS_COMPOUND ^^^ / vvv !_CCCL_BUILTIN_IS_COMPOUND vvv

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value>
Expand All @@ -47,7 +47,7 @@ template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_compound_v = is_compound<_Tp>::value;
# endif

#endif // defined(_LIBCUDACXX_IS_COMPOUND) && !defined(_LIBCUDACXX_USE_IS_COMPOUND_FALLBACK)
#endif // !_CCCL_BUILTIN_IS_COMPOUND

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__type_traits/is_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_IS_CONST) && !defined(_LIBCUDACXX_USE_IS_CONST_FALLBACK)
#if defined(_CCCL_BUILTIN_IS_CONST) && !defined(_LIBCUDACXX_USE_IS_CONST_FALLBACK)

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_const : public integral_constant<bool, _LIBCUDACXX_IS_CONST(_Tp)>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_const : public integral_constant<bool, _CCCL_BUILTIN_IS_CONST(_Tp)>
{};

# if _CCCL_STD_VER > 2011 && !defined(_LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_const_v = _LIBCUDACXX_IS_CONST(_Tp);
_LIBCUDACXX_INLINE_VAR constexpr bool is_const_v = _CCCL_BUILTIN_IS_CONST(_Tp);
# endif

#else
#else // ^^^ _CCCL_BUILTIN_IS_CONST ^^^ / vvv !_CCCL_BUILTIN_IS_CONST vvv

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_const : public false_type
Expand All @@ -49,7 +49,7 @@ template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_const_v = is_const<_Tp>::value;
# endif

#endif // defined(_LIBCUDACXX_IS_CONST) && !defined(_LIBCUDACXX_USE_IS_CONST_FALLBACK)
#endif // !_CCCL_BUILTIN_IS_CONST

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__type_traits/is_fundamental.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_IS_FUNDAMENTAL) && !defined(_LIBCUDACXX_USE_IS_FUNDAMENTAL_FALLBACK)
#if defined(_CCCL_BUILTIN_IS_FUNDAMENTAL) && !defined(_LIBCUDACXX_USE_IS_FUNDAMENTAL_FALLBACK)

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_fundamental : public integral_constant<bool, _LIBCUDACXX_IS_FUNDAMENTAL(_Tp)>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_fundamental : public integral_constant<bool, _CCCL_BUILTIN_IS_FUNDAMENTAL(_Tp)>
{};

# if _CCCL_STD_VER > 2011 && !defined(_LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_fundamental_v = _LIBCUDACXX_IS_FUNDAMENTAL(_Tp);
_LIBCUDACXX_INLINE_VAR constexpr bool is_fundamental_v = _CCCL_BUILTIN_IS_FUNDAMENTAL(_Tp);
# endif

#else
#else // ^^^ _CCCL_BUILTIN_IS_FUNDAMENTAL ^^^ / vvv !_CCCL_BUILTIN_IS_FUNDAMENTAL vvv

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_fundamental
Expand All @@ -50,7 +50,7 @@ template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_fundamental_v = is_fundamental<_Tp>::value;
# endif

#endif // defined(_LIBCUDACXX_IS_FUNDAMENTAL) && !defined(_LIBCUDACXX_USE_IS_FUNDAMENTAL_FALLBACK)
#endif // !_CCCL_BUILTIN_IS_FUNDAMENTAL

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
10 changes: 5 additions & 5 deletions libcudacxx/include/cuda/std/__type_traits/is_integral.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@

_LIBCUDACXX_BEGIN_NAMESPACE_STD

#if defined(_LIBCUDACXX_IS_INTEGRAL) && !defined(_LIBCUDACXX_USE_IS_INTEGRAL_FALLBACK)
#if defined(_CCCL_BUILTIN_IS_INTEGRAL) && !defined(_LIBCUDACXX_USE_IS_INTEGRAL_FALLBACK)

template <class _Tp>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_integral : public integral_constant<bool, _LIBCUDACXX_IS_INTEGRAL(_Tp)>
struct _CCCL_TYPE_VISIBILITY_DEFAULT is_integral : public integral_constant<bool, _CCCL_BUILTIN_IS_INTEGRAL(_Tp)>
{};

# if _CCCL_STD_VER > 2011 && !defined(_LIBCUDACXX_HAS_NO_VARIABLE_TEMPLATES)
template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_integral_v = _LIBCUDACXX_IS_INTEGRAL(_Tp);
_LIBCUDACXX_INLINE_VAR constexpr bool is_integral_v = _CCCL_BUILTIN_IS_INTEGRAL(_Tp);
# endif

#else
#else // ^^^ _CCCL_BUILTIN_IS_INTEGRAL ^^^ / vvv !_CCCL_BUILTIN_IS_INTEGRAL vvv

template <class _Tp>
struct __libcpp_is_integral : public false_type
Expand Down Expand Up @@ -112,7 +112,7 @@ template <class _Tp>
_LIBCUDACXX_INLINE_VAR constexpr bool is_integral_v = is_integral<_Tp>::value;
# endif

#endif // defined(_LIBCUDACXX_IS_INTEGRAL) && !defined(_LIBCUDACXX_USE_IS_INTEGRAL_FALLBACK)
#endif // !_CCCL_BUILTIN_IS_INTEGRAL

_LIBCUDACXX_END_NAMESPACE_STD

Expand Down
Loading

0 comments on commit d3f48b7

Please sign in to comment.