Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/exec/__detail/__bit_cast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace exec {
requires(sizeof(_To) == sizeof(_From))
[[nodiscard]]
constexpr _To bit_cast(const _From& __from) noexcept {
# if STDEXEC_HAS_BUILTIN(__builtin_bit_cast) || (_MSC_VER >= 1926)
# if STDEXEC_HAS_BUILTIN(__builtin_bit_cast) || (STDEXEC_MSVC() && STDEXEC_MSVC_VERSION >= 19'26)
return __builtin_bit_cast(_To, __from);
# else
_To __to;
Expand Down
13 changes: 4 additions & 9 deletions include/exec/__detail/__numa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#pragma once

#include "../../stdexec/__detail/__config.hpp"
#include "../../stdexec/__detail/__meta.hpp"
#include "../scope.hpp" // IWYU pragma: keep

#include <algorithm> // IWYU pragma: keep
Expand All @@ -27,14 +26,10 @@
#include <thread>
#include <utility>

// Work around a bug in the NVHPC compilers prior to version 24.03
#if STDEXEC_NVHPC()
# if STDEXEC_NVHPC_VERSION() <= 2403
# define STDEXEC_NUMA_VTABLE_INLINE
# endif
#endif

#ifndef STDEXEC_NUMA_VTABLE_INLINE
// Work around a bug in the NVHPC compilers prior to version 24.3
#if STDEXEC_NVHPC() && STDEXEC_NVHPC_VERSION < 24'03
# define STDEXEC_NUMA_VTABLE_INLINE
#else
# define STDEXEC_NUMA_VTABLE_INLINE inline
#endif

Expand Down
32 changes: 28 additions & 4 deletions include/exec/task.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ namespace exec {
__sticky
};

struct __parent_promise_t { };

template <__scheduler_affinity _SchedulerAffinity = __scheduler_affinity::__sticky>
class __default_task_context_impl {
template <class _ParentPromise>
Expand All @@ -103,7 +101,7 @@ namespace exec {

public:
template <class _ParentPromise>
explicit __default_task_context_impl(__parent_promise_t, _ParentPromise& __parent) noexcept {
explicit __default_task_context_impl(_ParentPromise& __parent) noexcept {
if constexpr (_SchedulerAffinity == __scheduler_affinity::__sticky) {
if constexpr (__check_parent_promise_has_scheduler<_ParentPromise>()) {
__scheduler_ = get_scheduler(get_env(__parent));
Expand Down Expand Up @@ -281,6 +279,25 @@ namespace exec {
__variant_for<__void, std::exception_ptr> __data_{};
};

template <class _Sch>
struct __just_void {
using sender_concept = sender_t;
using completion_signatures = stdexec::completion_signatures<set_value_t()>;

template <class _Rcvr>
[[nodiscard]]
static constexpr auto connect(_Rcvr __rcvr) noexcept {
return stdexec::connect(just(), static_cast<_Rcvr&&>(__rcvr));
}

[[nodiscard]]
constexpr auto get_env() const noexcept {
return prop{get_completion_scheduler<set_value_t>, __sch_};
}

_Sch __sch_;
};

enum class disposition : unsigned {
stopped,
succeeded,
Expand Down Expand Up @@ -319,6 +336,8 @@ namespace exec {
}

private:
using __scheduler_t = __query_result_or_t<get_scheduler_t, _Context, inline_scheduler>;

struct __final_awaitable {
static constexpr auto await_ready() noexcept -> bool {
return false;
Expand Down Expand Up @@ -399,6 +418,11 @@ namespace exec {
}
#endif

template <__sender_adaptor_closure_for<__just_void<__scheduler_t>> _Closure>
auto await_transform(_Closure&& __closure) noexcept -> decltype(auto) {
return await_transform(static_cast<_Closure&&>(__closure)(__just_void<__scheduler_t>()));
}

template <class _Awaitable>
auto await_transform(_Awaitable&& __awaitable) noexcept -> decltype(auto) {
return with_awaitable_senders<__promise>::await_transform(
Expand Down Expand Up @@ -431,7 +455,7 @@ namespace exec {
auto await_suspend(__coro::coroutine_handle<_ParentPromise2> __parent) noexcept
-> __coro::coroutine_handle<> {
static_assert(__one_of<_ParentPromise, _ParentPromise2, void>);
__coro_.promise().__context_.emplace(__parent_promise_t(), __parent.promise());
__coro_.promise().__context_.emplace(__parent.promise());
__context_.emplace(*__coro_.promise().__context_, __parent.promise());
__coro_.promise().set_continuation(__parent);
if constexpr (requires { __coro_.promise().stop_requested() ? 0 : 1; }) {
Expand Down
4 changes: 2 additions & 2 deletions include/exec/timed_scheduler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace exec {
};

struct schedule_after_t : __schedule_after_base_t {
#if !STDEXEC_CLANG() || (__clang_major__ >= 16)
#if !STDEXEC_CLANG() || STDEXEC_CLANG_VERSION >= 16'00
using __schedule_after_base_t::operator();
#else
// clang prior to 16 is not able to find the correct overload in the
Expand Down Expand Up @@ -198,7 +198,7 @@ namespace exec {
};

struct schedule_at_t : __schedule_at_base_t {
#if !STDEXEC_CLANG() || (__clang_major__ >= 16)
#if !STDEXEC_CLANG() || STDEXEC_CLANG_VERSION >= 16'00
using __schedule_at_base_t::operator();
#else
// clang prior to 16 is not able to find the correct overload in the
Expand Down
73 changes: 37 additions & 36 deletions include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,37 @@
// macro name; nothing, otherwise.
#if defined(__NVCC__)
# define STDEXEC_NVCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_NVCC_VERSION (__CUDACC_VER_MAJOR__ * 100 + __CUDACC_VER_MINOR__)
#elif defined(__EDG__)
# define STDEXEC_EDG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_EDG_VERSION __EDG_VERSION__
# if defined(__NVCOMPILER)
# define STDEXEC_NVHPC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_NVHPC_VERSION (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__)
# endif
# if defined(__INTELLISENSE__)
# define STDEXEC_INTELLISENSE(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_MSVC_HEADERS(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# endif
#elif defined(__clang__)
# define STDEXEC_CLANG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
# if defined(_MSC_VER)
# define STDEXEC_CLANG_CL(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# endif
# if defined(__apple_build_version__)
# define STDEXEC_APPLE_CLANG(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
// Apple clang version is encoded as major * 1000000 + minor * 1000 + patch. We ignore the patch
// version here, as it is not relevant for the purposes of this library.
# define STDEXEC_APPLE_CLANG_VERSION (__apple_build_version__ / 1000)
# endif
#elif defined(__GNUC__)
# define STDEXEC_GCC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#elif defined(_MSC_VER)
# define STDEXEC_MSVC(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_MSVC_HEADERS(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
# define STDEXEC_MSVC_VERSION _MSC_VER
#endif

#ifndef STDEXEC_NVCC
Expand Down Expand Up @@ -103,10 +112,6 @@
# define STDEXEC_INTELLISENSE(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
#endif

#if STDEXEC_NVHPC()
# define STDEXEC_NVHPC_VERSION() (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__)
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(__CUDACC__) || STDEXEC_NVHPC()
# define STDEXEC_CUDA_COMPILATION(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
Expand Down Expand Up @@ -173,13 +178,25 @@ namespace __coro = std::experimental;

#if STDEXEC_NVHPC()
// NVBUG #4067067: NVHPC does not fully support [[no_unique_address]]
# define STDEXEC_ATTR_WHICH_3(_ATTR) /*nothing*/
# if STDEXEC_NVHPC_VERSION < 23'05
# define STDEXEC_ATTR_WHICH_3(_ATTR) /*nothing*/
# else
# define STDEXEC_ATTR_WHICH_3(_ATTR) [[no_unique_address]]
# endif
#elif STDEXEC_CLANG_CL()
// clang-cl does not support [[no_unique_address]]: https://reviews.llvm.org/D110485
# if STDEXEC_CLANG_VERSION < 18'01 // TODO: Find the version that started supporting [[msvc::no_unique_address]]
# define STDEXEC_ATTR_WHICH_3(_ATTR) /*nothing*/
# else
# define STDEXEC_ATTR_WHICH_3(_ATTR) [[msvc::no_unique_address]]
# endif
#elif STDEXEC_MSVC()
// MSVCBUG https://developercommunity.visualstudio.com/t/Incorrect-codegen-when-using-msvc::no_/10452874
# define STDEXEC_ATTR_WHICH_3(_ATTR) // [[msvc::no_unique_address]]
#elif STDEXEC_CLANG_CL()
// clang-cl does not support: https://reviews.llvm.org/D110485
# define STDEXEC_ATTR_WHICH_3(_ATTR) // [[msvc::no_unique_address]]
# if STDEXEC_MSVC_VERSION < 19'43
# define STDEXEC_ATTR_WHICH_3(_ATTR) /*nothing*/
# else
# define STDEXEC_ATTR_WHICH_3(_ATTR) [[msvc::no_unique_address]]
# endif
#else
# define STDEXEC_ATTR_WHICH_3(_ATTR) [[no_unique_address]]
#endif
Expand All @@ -190,7 +207,7 @@ namespace __coro = std::experimental;
#elif STDEXEC_CLANG()
# define STDEXEC_ATTR_WHICH_4(_ATTR) \
__attribute__((__always_inline__, __artificial__, __nodebug__)) inline
#elif defined(__GNUC__)
#elif STDEXEC_GCC()
# define STDEXEC_ATTR_WHICH_4(_ATTR) __attribute__((__always_inline__, __artificial__)) inline
#else
# define STDEXEC_ATTR_WHICH_4(_ATTR) /*nothing*/
Expand Down Expand Up @@ -272,7 +289,7 @@ namespace __coro = std::experimental;
# define STDEXEC_IS_TRIVIALLY_COPYABLE(...) std::is_trivially_copyable_v<__VA_ARGS__>
#endif

#if STDEXEC_HAS_BUILTIN(__is_base_of) || (_MSC_VER >= 1914)
#if STDEXEC_HAS_BUILTIN(__is_base_of) || (STDEXEC_MSVC_VERSION >= 19'14)
# define STDEXEC_IS_BASE_OF(...) __is_base_of(__VA_ARGS__)
#else
# define STDEXEC_IS_BASE_OF(...) std::is_base_of_v<__VA_ARGS__>
Expand Down Expand Up @@ -371,17 +388,19 @@ namespace stdexec {
#endif

// Before gcc-12, gcc really didn't like tuples or variants of immovable types
#if STDEXEC_GCC() && (__GNUC__ < 12)
#if STDEXEC_GCC() && (STDEXEC_GCC_VERSION < 12'00)
# define STDEXEC_IMMOVABLE(_XP) _XP(_XP&&)
#else
# define STDEXEC_IMMOVABLE(_XP) _XP(_XP&&) = delete
#endif

#if STDEXEC_GCC()
// BUG (gcc#98995): copy elision fails when initializing a [[no_unique_address]] field
// from a function returning an object of class type by value.
//
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98995
#if STDEXEC_GCC()
# define STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS
#elif STDEXEC_CLANG() && (__clang_major__ >= 15 && __clang_major__ < 19)
// See https://github.com/llvm/llvm-project/issues/93563
# define STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS
#else
# define STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS STDEXEC_ATTRIBUTE(no_unique_address)
Expand All @@ -401,7 +420,7 @@ namespace stdexec {
// Some compilers turn on pack indexing in pre-C++26 code. We want to use it if it is
// available. Pack indexing is disabled for clang < 20 because of:
// https://github.com/llvm/llvm-project/issues/116105
#if defined(__cpp_pack_indexing) && !STDEXEC_NVCC() && !(STDEXEC_CLANG() && __clang_major__ < 20)
#if defined(__cpp_pack_indexing) && !STDEXEC_NVCC() && !(STDEXEC_CLANG() && STDEXEC_CLANG_VERSION < 20'00)
# define STDEXEC_HAS_PACK_INDEXING() 1
#else // ^^^ has pack indexing ^^^ / vvv no pack indexing vvv
# define STDEXEC_HAS_PACK_INDEXING() 0
Expand All @@ -416,7 +435,7 @@ namespace stdexec {
// Before clang-16, clang did not like libstdc++'s ranges implementation
#if __has_include(<ranges>) && \
(defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L) && \
(!STDEXEC_CLANG() || __clang_major__ >= 16 || defined(_LIBCPP_VERSION))
(!STDEXEC_CLANG() || STDEXEC_CLANG_VERSION >= 16'00 || defined(_LIBCPP_VERSION))
# define STDEXEC_HAS_STD_RANGES() 1
#else
# define STDEXEC_HAS_STD_RANGES() 0
Expand Down Expand Up @@ -461,7 +480,7 @@ namespace stdexec {
}

// GCC 13 implements lexical friendship, but it is incomplete. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111018
#if STDEXEC_CLANG() // || (STDEXEC_GCC() && __GNUC__ >= 13)
#if STDEXEC_CLANG() // || (STDEXEC_GCC() && STDEXEC_GCC_VERSION >= 13'00)
# define STDEXEC_FRIENDSHIP_IS_LEXICAL() 1
#else
# define STDEXEC_FRIENDSHIP_IS_LEXICAL() 0
Expand All @@ -473,25 +492,7 @@ namespace stdexec {
# define STDEXEC_EXPLICIT_THIS(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
#endif

// Configure extra type checking
#define STDEXEC_TYPE_CHECKING_ZERO() 0
#define STDEXEC_TYPE_CHECKING_ONE() 1
#define STDEXEC_TYPE_CHECKING_TWO() 2

#define STDEXEC_PROBE_TYPE_CHECKING_ STDEXEC_TYPE_CHECKING_ONE
#define STDEXEC_PROBE_TYPE_CHECKING_0 STDEXEC_TYPE_CHECKING_ZERO
#define STDEXEC_PROBE_TYPE_CHECKING_1 STDEXEC_TYPE_CHECKING_ONE
#define STDEXEC_PROBE_TYPE_CHECKING_STDEXEC_ENABLE_EXTRA_TYPE_CHECKING STDEXEC_TYPE_CHECKING_TWO

#define STDEXEC_TYPE_CHECKING_WHICH3(...) STDEXEC_PROBE_TYPE_CHECKING_##__VA_ARGS__
#define STDEXEC_TYPE_CHECKING_WHICH2(...) STDEXEC_TYPE_CHECKING_WHICH3(__VA_ARGS__)
#define STDEXEC_TYPE_CHECKING_WHICH STDEXEC_TYPE_CHECKING_WHICH2(STDEXEC_ENABLE_EXTRA_TYPE_CHECKING)

#ifndef STDEXEC_ENABLE_EXTRA_TYPE_CHECKING
# define STDEXEC_ENABLE_EXTRA_TYPE_CHECKING() 0
#elif STDEXEC_TYPE_CHECKING_WHICH() == 2
// do nothing
#elif STDEXEC_TYPE_CHECKING_WHICH() == 0
#if STDEXEC_ENABLE_EXTRA_TYPE_CHECKING == 0
# undef STDEXEC_ENABLE_EXTRA_TYPE_CHECKING
# define STDEXEC_ENABLE_EXTRA_TYPE_CHECKING() 0
#else
Expand Down
2 changes: 1 addition & 1 deletion include/stdexec/__detail/__connect_awaitable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ namespace stdexec {
}

template <class _Awaitable, class _Receiver>
# if STDEXEC_GCC() && (__GNUC__ > 11)
# if STDEXEC_GCC() && (STDEXEC_GCC_VERSION >= 12'00)
__attribute__((__used__))
# endif
static auto __co_impl(_Awaitable __awaitable, _Receiver __rcvr) -> __operation_t<_Receiver> {
Expand Down
4 changes: 2 additions & 2 deletions include/stdexec/__detail/__cpo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@
# pragma deprecated(STDEXEC_CUSTOM)
#endif

#if STDEXEC_GCC() || (STDEXEC_CLANG() && __clang_major__ < 14)
#if STDEXEC_GCC() || (STDEXEC_CLANG() && STDEXEC_CLANG_VERSION < 14'00)
# define STDEXEC_CUSTOM \
_Pragma("GCC warning \"STDEXEC_CUSTOM is deprecated; use STDEXEC_MEMFN_DECL instead.\"") \
STDEXEC_MEMFN_DECL
#else
# define STDEXEC_CUSTOM STDEXEC_MEMFN_DECL
#endif

#if STDEXEC_CLANG() && __clang_major__ >= 14
#if STDEXEC_CLANG() && STDEXEC_CLANG_VERSION >= 14'00
# pragma clang deprecated(STDEXEC_CUSTOM, "use STDEXEC_MEMFN_DECL instead.")
#endif

Expand Down
Loading
Loading