Skip to content

Commit

Permalink
Work around compiler bug with nvhpc
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Oct 4, 2024
1 parent e8f099d commit 2914051
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
17 changes: 17 additions & 0 deletions libcudacxx/include/cuda/__memory_resource/get_property.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ _LIBCUDACXX_INLINE_VAR constexpr bool has_property<
_CUDA_VSTD::void_t<decltype(get_property(_CUDA_VSTD::declval<const _Resource&>(), _CUDA_VSTD::declval<_Property>()))>> =
true;

# if defined(_CCCL_COMPILER_NVHPC) // NVHPC has issues accepting this at compile time if it is in a variable template
template <class _Resource, class _Property, class = void>
struct __has_property_impl
{
static constexpr bool value = false;
};

template <class _Resource, class _Property>
struct __has_property_impl<
_Resource,
_Property,
_CUDA_VSTD::void_t<decltype(get_property(_CUDA_VSTD::declval<const _Resource&>(), _CUDA_VSTD::declval<_Property>()))>>
{
static constexpr bool value = true;
};
# endif // _CCCL_COMPILER_NVHPC

template <class _Property>
using __property_value_t = typename _Property::value_type;

Expand Down
8 changes: 8 additions & 0 deletions libcudacxx/include/cuda/__memory_resource/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,23 @@ _LIBCUDACXX_CONCEPT async_resource = _LIBCUDACXX_FRAGMENT(__async_resource_, _Re
//! @tparam _Properties
template <class _Resource, class... _Properties>
_LIBCUDACXX_CONCEPT resource_with =
# if defined(_CCCL_COMPILER_NVHPC)
resource<_Resource> && _CUDA_VSTD::__fold_and<__has_property_impl<_Resource, _Properties>::value...>;
# else // ^^^ _CCCL_COMPILER_NVHPC ^^^ / vvv !_CCCL_COMPILER_NVHPC vvv
resource<_Resource> && _CUDA_VSTD::__fold_and<has_property<_Resource, _Properties>...>;
# endif // !_CCCL_COMPILER_NVHPC

//! @brief The \c async_resource_with concept verifies that a type Resource satisfies the `async_resource`
//! concept and also satisfies all the provided Properties
//! @tparam _Resource
//! @tparam _Properties
template <class _Resource, class... _Properties>
_LIBCUDACXX_CONCEPT async_resource_with =
# if defined(_CCCL_COMPILER_NVHPC)
async_resource<_Resource> && _CUDA_VSTD::__fold_and<__has_property_impl<_Resource, _Properties>::value...>;
# else // ^^^ _CCCL_COMPILER_NVHPC ^^^ / vvv !_CCCL_COMPILER_NVHPC vvv
async_resource<_Resource> && _CUDA_VSTD::__fold_and<has_property<_Resource, _Properties>...>;
# endif // !_CCCL_COMPILER_NVHPC

template <bool _Convertible>
struct __different_resource__
Expand Down

0 comments on commit 2914051

Please sign in to comment.