Skip to content
Draft
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
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ doc:
./bin/mk-doc.py docs/*.mds
doxygen docs/Doxyfile

LLVM_VERSION=22.1.0
DEV_DIR=build/dev-$(shell uname -s)
TESTCASE = *
DEV_TEST_OPTION=-DBEMAN_EXECUTION_TEST_CASE=$(TESTCASE)

dev-config:
PATH=/opt/llvm-$(LLVM_VERSION)/bin:$$PATH CXX=clang++ cmake -B $(DEV_DIR) -G Ninja -DBEMAN_EXECUTION_BUILD_EXAMPLES=OFF -DBEMAN_EXECUTION_INSTALL_CONFIG_FILE_PACKAGE=OFF $(DEV_TEST_OPTION)

dev-build: dev-config
PATH=/opt/llvm-$(LLVM_VERSION)/bin:$$PATH CXX=clang++ cmake --build $(DEV_DIR)

dev-test: dev-build
PATH=/opt/llvm-$(LLVM_VERSION)/bin:$$PATH CXX=clang++ ctest --test-dir $(DEV_DIR) -R beman.execution.$(TESTCASE).test

dev: dev-test


# $(SANITIZERS):
# $(MAKE) SANITIZER=$@

Expand Down
22 changes: 9 additions & 13 deletions include/beman/execution/detail/affine_on.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import std;
import beman.execution.detail.basic_sender;
import beman.execution.detail.completion_signatures;
import beman.execution.detail.completion_signatures_of_t;
import beman.execution.detail.continues_on;
import beman.execution.detail.env;
import beman.execution.detail.forward_like;
import beman.execution.detail.fwd_env;
import beman.execution.detail.get_completion_signatures;
import beman.execution.detail.get_domain_early;
import beman.execution.detail.get_scheduler;
import beman.execution.detail.get_stop_token;
import beman.execution.detail.make_sender;
Expand All @@ -38,20 +38,19 @@ import beman.execution.detail.sender_has_affine_on;
import beman.execution.detail.set_value;
import beman.execution.detail.store_receiver;
import beman.execution.detail.tag_of_t;
import beman.execution.detail.transform_sender;
import beman.execution.detail.unstoppable;
import beman.execution.detail.write_env;
#else
#include <beman/execution/detail/completion_signatures_of_t.hpp>
#include <beman/execution/detail/continues_on.hpp>
#include <beman/execution/detail/env.hpp>
#include <beman/execution/detail/forward_like.hpp>
#include <beman/execution/detail/fwd_env.hpp>
#include <beman/execution/detail/get_domain_early.hpp>
#include <beman/execution/detail/get_scheduler.hpp>
#include <beman/execution/detail/get_stop_token.hpp>
#include <beman/execution/detail/make_sender.hpp>
#include <beman/execution/detail/never_stop_token.hpp>
#include <beman/execution/detail/prop.hpp>
#include <beman/execution/detail/schedule_from.hpp>
#include <beman/execution/detail/scheduler.hpp>
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/sender_adaptor_closure.hpp>
Expand All @@ -60,7 +59,6 @@ import beman.execution.detail.write_env;
#include <beman/execution/detail/set_value.hpp>
#include <beman/execution/detail/store_receiver.hpp>
#include <beman/execution/detail/tag_of_t.hpp>
#include <beman/execution/detail/transform_sender.hpp>
#include <beman/execution/detail/unstoppable.hpp>
#include <beman/execution/detail/write_env.hpp>
#endif
Expand Down Expand Up @@ -100,10 +98,8 @@ struct affine_on_t : ::beman::execution::sender_adaptor_closure<affine_on_t> {
*/
template <::beman::execution::sender Sender>
auto operator()(Sender&& sender) const {
return ::beman::execution::transform_sender(
::beman::execution::detail::get_domain_early(sender),
::beman::execution::detail::make_sender(
*this, ::beman::execution::env<>{}, ::std::forward<Sender>(sender)));
return ::beman::execution::detail::make_sender(
*this, ::beman::execution::env<>{}, ::std::forward<Sender>(sender));
}

/**
Expand Down Expand Up @@ -136,7 +132,7 @@ struct affine_on_t : ::beman::execution::sender_adaptor_closure<affine_on_t> {
{ ::beman::execution::get_scheduler(env) } -> ::beman::execution::scheduler;
{ ::beman::execution::schedule(::beman::execution::get_scheduler(env)) } -> ::beman::execution::sender;
}
static auto transform_sender(Sender&& sender, const Env& ev) {
static auto transform_sender(::beman::execution::set_value_t, Sender&& sender, const Env& ev) {
static_assert(requires {
{
::beman::execution::get_completion_signatures<decltype(::beman::execution::unstoppable(
Expand All @@ -158,9 +154,9 @@ struct affine_on_t : ::beman::execution::sender_adaptor_closure<affine_on_t> {
return ::beman::execution::detail::store_receiver(
::beman::execution::detail::forward_like<Sender>(child),
[]<typename Child>(Child&& child, const auto& ev) {
return ::beman::execution::unstoppable(::beman::execution::schedule_from(
::beman::execution::get_scheduler(ev),
::beman::execution::write_env(::std::forward<Child>(child), ev)));
return ::beman::execution::unstoppable(::beman::execution::continues_on(
::beman::execution::write_env(::std::forward<Child>(child), ev),
::beman::execution::get_scheduler(ev)));
});
}
}
Expand Down
12 changes: 2 additions & 10 deletions include/beman/execution/detail/associate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import beman.execution.detail.completion_signatures_for;
import beman.execution.detail.default_impls;
import beman.execution.detail.env;
import beman.execution.detail.forward_like;
import beman.execution.detail.get_domain_early;
import beman.execution.detail.impls_for;
import beman.execution.detail.make_sender;
import beman.execution.detail.nothrow_callable;
Expand All @@ -32,19 +31,16 @@ import beman.execution.detail.sender_adaptor_closure;
import beman.execution.detail.set_stopped;
import beman.execution.detail.set_value;
import beman.execution.detail.start;
import beman.execution.detail.transform_sender;
import beman.execution.detail.valid_completion_signatures;
#else
#include <beman/execution/detail/connect.hpp>
#include <beman/execution/detail/default_impls.hpp>
#include <beman/execution/detail/get_domain_early.hpp>
#include <beman/execution/detail/impls_for.hpp>
#include <beman/execution/detail/make_sender.hpp>
#include <beman/execution/detail/nothrow_callable.hpp>
#include <beman/execution/detail/scope_token.hpp>
#include <beman/execution/detail/sender.hpp>
#include <beman/execution/detail/sender_adaptor.hpp>
#include <beman/execution/detail/transform_sender.hpp>
#endif

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -108,12 +104,8 @@ associate_data(Token, Sender&&) -> associate_data<Token, Sender>;
struct associate_t {
template <::beman::execution::sender Sender, ::beman::execution::scope_token Token>
auto operator()(Sender&& sender, Token token) const {
auto domain(::beman::execution::detail::get_domain_early(sender));
return ::beman::execution::transform_sender(
domain,
::beman::execution::detail::make_sender(
*this,
::beman::execution::detail::associate_data(::std::move(token), ::std::forward<Sender>(sender))));
return ::beman::execution::detail::make_sender(
*this, ::beman::execution::detail::associate_data(::std::move(token), ::std::forward<Sender>(sender)));
}

template <::beman::execution::scope_token Token>
Expand Down
6 changes: 2 additions & 4 deletions include/beman/execution/detail/atomic_intrusive_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ class atomic_intrusive_stack<Next> {
auto stack = ::beman::execution::detail::intrusive_stack<Next>{};
void* ptr = head_.exchange(this);
if (ptr == this) {
return stack;
return {};
}
auto item = static_cast<Item*>(ptr);
stack.head_ = item;
return stack;
return ::beman::execution::detail::intrusive_stack<Next>{static_cast<Item*>(ptr)};
}

private:
Expand Down
9 changes: 3 additions & 6 deletions include/beman/execution/detail/basic_receiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ template <typename Sender, typename Receiver, typename Index>
this->complete(Index(),
this->op->state,
this->op->receiver,
::beman::execution::set_value_t(),
::beman::execution::set_value,
::std::forward<Args>(args)...);
}

Expand All @@ -81,11 +81,8 @@ template <typename Sender, typename Receiver, typename Index>
requires ::beman::execution::detail::
callable<decltype(complete), Index, state_t&, Receiver&, ::beman::execution::set_error_t, Error>
{
this->complete(Index(),
this->op->state,
this->op->receiver,
::beman::execution::set_error_t(),
::std::forward<Error>(error));
this->complete(
Index(), this->op->state, this->op->receiver, ::beman::execution::set_error, ::std::forward<Error>(error));
}

auto set_stopped() && noexcept -> void
Expand Down
32 changes: 12 additions & 20 deletions include/beman/execution/detail/bulk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import beman.execution.detail.completion_signatures_of_t;
import beman.execution.detail.default_impls;
import beman.execution.detail.execution_policy;
import beman.execution.detail.forward_like;
import beman.execution.detail.get_domain_early;
import beman.execution.detail.make_sender;
import beman.execution.detail.meta.combine;
import beman.execution.detail.meta.unique;
Expand All @@ -31,15 +30,13 @@ import beman.execution.detail.sender_adaptor_closure;
import beman.execution.detail.sender_for;
import beman.execution.detail.set_error;
import beman.execution.detail.set_value;
import beman.execution.detail.transform_sender;
#else
#include <beman/execution/detail/basic_sender.hpp>
#include <beman/execution/detail/completion_signatures.hpp>
#include <beman/execution/detail/completion_signatures_of_t.hpp>
#include <beman/execution/detail/default_impls.hpp>
#include <beman/execution/detail/execution_policy.hpp>
#include <beman/execution/detail/forward_like.hpp>
#include <beman/execution/detail/get_domain_early.hpp>
#include <beman/execution/detail/make_sender.hpp>
#include <beman/execution/detail/meta_combine.hpp>
#include <beman/execution/detail/meta_unique.hpp>
Expand All @@ -49,7 +46,6 @@ import beman.execution.detail.transform_sender;
#include <beman/execution/detail/sender_for.hpp>
#include <beman/execution/detail/set_error.hpp>
#include <beman/execution/detail/set_value.hpp>
#include <beman/execution/detail/transform_sender.hpp>
#endif

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -120,13 +116,11 @@ struct bulk_algo_t : ::beman::execution::sender_adaptor_closure<bulk_algo_t<IsCh
::beman::execution::is_execution_policy_v<::std::remove_cvref_t<Policy>> && ::std::integral<Shape> &&
::std::copy_constructible<::std::decay_t<F>>)
auto operator()(Sender&& sndr, Policy&& policy, Shape shape, F&& f) const {
return ::beman::execution::transform_sender(
::beman::execution::detail::get_domain_early(sndr),
::beman::execution::detail::make_sender(
*this,
::beman::execution::detail::product_type<::std::remove_cvref_t<Policy>, Shape, ::std::decay_t<F>>{
::std::forward<Policy>(policy), shape, ::std::forward<F>(f)},
::std::forward<Sender>(sndr)));
return ::beman::execution::detail::make_sender(
*this,
::beman::execution::detail::product_type<::std::remove_cvref_t<Policy>, Shape, ::std::decay_t<F>>{
::std::forward<Policy>(policy), shape, ::std::forward<F>(f)},
::std::forward<Sender>(sndr));
}

private:
Expand Down Expand Up @@ -210,17 +204,15 @@ struct bulk_t : ::beman::execution::sender_adaptor_closure<bulk_t> {
::beman::execution::is_execution_policy_v<::std::remove_cvref_t<Policy>> && ::std::integral<Shape> &&
::std::copy_constructible<::std::decay_t<F>>)
auto operator()(Sender&& sndr, Policy&& policy, Shape shape, F&& f) const {
return ::beman::execution::transform_sender(
::beman::execution::detail::get_domain_early(sndr),
::beman::execution::detail::make_sender(
*this,
::beman::execution::detail::product_type<::std::remove_cvref_t<Policy>, Shape, ::std::decay_t<F>>{
::std::forward<Policy>(policy), shape, ::std::forward<F>(f)},
::std::forward<Sender>(sndr)));
return ::beman::execution::detail::make_sender(
*this,
::beman::execution::detail::product_type<::std::remove_cvref_t<Policy>, Shape, ::std::decay_t<F>>{
::std::forward<Policy>(policy), shape, ::std::forward<F>(f)},
::std::forward<Sender>(sndr));
}

template <::beman::execution::detail::sender_for<bulk_t> Sender, typename... Env>
auto transform_sender(Sender&& sndr, Env&&...) const {
template <::beman::execution::detail::sender_for<bulk_t> Sender, typename Env>
auto transform_sender(::beman::execution::set_value_t, Sender&& sndr, const Env&) const {
auto data = ::beman::execution::detail::forward_like<Sender>(sndr.template get<1>());
auto child = ::beman::execution::detail::forward_like<Sender>(sndr.template get<2>());

Expand Down
47 changes: 47 additions & 0 deletions include/beman/execution/detail/common_domain.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// include/beman/execution/detail/common_domain.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_COMMON_DOMAIN
#define INCLUDED_BEMAN_EXECUTION_DETAIL_COMMON_DOMAIN

#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <concepts>
#include <type_traits>
#endif
#ifdef BEMAN_HAS_MODULES
import beman.execution.detail.indeterminate_domain;
#else
#include <beman/execution/detail/indeterminate_domain.hpp>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution::detail {

template <typename... Domains>
struct common_domain_impl {
using type = ::beman::execution::indeterminate_domain<Domains...>;
};

template <typename... Domains>
requires requires { typename ::std::common_type_t<Domains...>; }
struct common_domain_impl<Domains...> {
using type = ::std::common_type_t<Domains...>;
};

template <typename... Domains>
using common_domain_t = typename common_domain_impl<::std::decay_t<Domains>...>::type;

template <typename... Domains>
constexpr auto common_domain(Domains&&...) noexcept {
return common_domain_t<Domains...>{};
}

} // namespace beman::execution::detail

// ----------------------------------------------------------------------------

#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_COMMON_DOMAIN
44 changes: 44 additions & 0 deletions include/beman/execution/detail/compl_domain.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// include/beman/execution/detail/compl_domain.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_COMPL_DOMAIN
#define INCLUDED_BEMAN_EXECUTION_DETAIL_COMPL_DOMAIN

#include <beman/execution/detail/common.hpp>
#ifdef BEMAN_HAS_IMPORT_STD
import std;
#else
#include <type_traits>
#endif
#ifdef BEMAN_HAS_MODULES
import beman.execution.detail.default_domain;
import beman.execution.detail.get_completion_domain;
import beman.execution.detail.get_env;
#else
#include <beman/execution/detail/default_domain.hpp>
#include <beman/execution/detail/get_completion_domain.hpp>
#include <beman/execution/detail/get_env.hpp>
#endif

// ----------------------------------------------------------------------------

namespace beman::execution::detail {
template <typename Tag = void, typename Sndr, typename... Envs>
constexpr auto compl_domain(const Sndr& sndr, const Envs&... envs) noexcept {
if constexpr (requires {
::beman::execution::get_completion_domain<Tag>(::beman::execution::get_env(sndr), envs...);
}) {
return ::beman::execution::get_completion_domain<Tag>(::beman::execution::get_env(sndr), envs...);
} else {
return ::beman::execution::default_domain();
}
}

template <typename Tag, typename Sndr, typename... Envs>
using compl_domain_of_t =
decltype(::beman::execution::detail::compl_domain<Tag>(::std::declval<Sndr>(), ::std::declval<const Envs&>()...));
} // namespace beman::execution::detail

// ----------------------------------------------------------------------------

#endif // INCLUDED_BEMAN_EXECUTION_DETAIL_COMPL_DOMAIN
Loading
Loading