Skip to content

Commit f140910

Browse files
authored
Merge pull request #985 from NVIDIA/intrinsic-traits
use compiler intrinsics for some expensive type traits
2 parents a463e5d + 9281828 commit f140910

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

include/exec/any_sender_of.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ namespace exec {
362362
class __storage<_Vtable, _Allocator, _Copyable, _Alignment, _InlineSize>::__t
363363
: __if_c<_Copyable, __, __move_only> {
364364
static_assert(
365-
std::is_convertible_v<typename std::allocator_traits<_Allocator>::void_pointer, void*>);
365+
STDEXEC_IS_CONVERTIBLE_TO(typename std::allocator_traits<_Allocator>::void_pointer, void*));
366366

367367
static constexpr std::size_t __buffer_size = std::max(_InlineSize, sizeof(void*));
368368
static constexpr std::size_t __alignment = std::max(_Alignment, alignof(void*));

include/nvexec/stream/common.cuh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,12 @@ namespace nvexec {
357357
template <class S>
358358
concept stream_sender = //
359359
sender<S> && //
360-
std::is_base_of_v<stream_sender_base, __decay_t<S>>;
360+
STDEXEC_IS_BASE_OF(stream_sender_base, __decay_t<S>);
361361

362362
template <class R>
363363
concept stream_receiver = //
364364
receiver<R> && //
365-
std::is_base_of_v<stream_receiver_base, __decay_t<R>>;
365+
STDEXEC_IS_BASE_OF(stream_receiver_base, __decay_t<R>);
366366

367367
struct stream_op_state_base { };
368368

include/nvexec/stream/when_all.cuh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ namespace nvexec::STDEXEC_STREAM_DETAIL_NS {
235235

236236
template <class OpT>
237237
static void sync(OpT& op) noexcept {
238-
if constexpr (std::is_base_of_v<stream_op_state_base, OpT>) {
238+
if constexpr (STDEXEC_IS_BASE_OF(stream_op_state_base, OpT)) {
239239
if (op.stream_provider_.status_ == cudaSuccess) {
240240
op.stream_provider_.status_ = STDEXEC_DBG_ERR(cudaStreamSynchronize(op.get_stream()));
241241
}

include/stdexec/__detail/__config.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@
9595
#define STDEXEC_IS_BASE_OF(...) std::is_base_of_v<__VA_ARGS__>
9696
#endif
9797

98+
#if STDEXEC_HAS_BUILTIN(__is_convertible_to) || STDEXEC_MSVC()
99+
#define STDEXEC_IS_CONVERTIBLE_TO(...) __is_convertible_to(__VA_ARGS__)
100+
#elif STDEXEC_HAS_BUILTIN(__is_convertible)
101+
#define STDEXEC_IS_CONVERTIBLE_TO(...) __is_convertible(__VA_ARGS__)
102+
#else
103+
#define STDEXEC_IS_CONVERTIBLE_TO(...) std::is_convertible_v<__VA_ARGS__>
104+
#endif
105+
98106
// Before gcc-12, gcc really didn't like tuples or variants of immovable types
99107
#if STDEXEC_GCC() && (__GNUC__ < 12)
100108
#define STDEXEC_IMMOVABLE(_XP) _XP(_XP&&)

include/stdexec/concepts.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ namespace stdexec::__std_concepts {
5555
concept integral = std::is_integral_v<T>;
5656

5757
template <class _Ap, class _Bp>
58-
concept derived_from = //
59-
std::is_base_of_v<_Bp, _Ap> && //
60-
std::is_convertible_v<const volatile _Ap*, const volatile _Bp*>;
58+
concept derived_from = //
59+
STDEXEC_IS_BASE_OF(_Bp, _Ap) && //
60+
STDEXEC_IS_CONVERTIBLE_TO(const volatile _Ap*, const volatile _Bp*);
6161

6262
template <class _From, class _To>
63-
concept convertible_to = //
64-
std::is_convertible_v<_From, _To> && //
63+
concept convertible_to = //
64+
STDEXEC_IS_CONVERTIBLE_TO(_From, _To) && //
6565
requires(_From (&__fun)()) { static_cast<_To>(__fun()); };
6666

6767
template <class _Ty>

include/stdexec/execution.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2533,7 +2533,7 @@ namespace stdexec {
25332533
requires __decays_to<_Tp, _Tp>
25342534
{
25352535
static_assert(std::is_reference_v<__copy_cvref_t<_Up&&, _Tp>>);
2536-
static_assert(std::is_base_of_v<_Tp, __decay_t<_Up>>);
2536+
static_assert(STDEXEC_IS_BASE_OF(_Tp, __decay_t<_Up>));
25372537
return (__copy_cvref_t<_Up&&, _Tp>) (_Up&&) u;
25382538
}
25392539

0 commit comments

Comments
 (0)