Skip to content
Open
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/nvexec/stream/upon_error.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ namespace nv::execution::_strm
static_cast<Self&&>(self).sndr_,
static_cast<Receiver&&>(rcvr),
[&](_strm::opstate_base<Receiver>& stream_provider) -> receiver_t<Receiver>
{ return receiver_t<Receiver>(self.fun_, stream_provider); });
{ return receiver_t<Receiver>(static_cast<Self&&>(self).fun_, stream_provider); });
}
STDEXEC_EXPLICIT_THIS_END(connect)

Expand Down
31 changes: 31 additions & 0 deletions test/nvexec/upon_error.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <stdexec/execution.hpp>
#include <test_common/catch2.hpp>

#include <type_traits>

#include "common.cuh"
#include "nvexec/stream_context.cuh"

Expand All @@ -11,6 +13,23 @@ using nvexec::is_on_gpu;
namespace
{

struct move_only_error_handler
{
move_only_error_handler() = default;
move_only_error_handler(move_only_error_handler const &) = delete;

STDEXEC_ATTRIBUTE(host, device)
move_only_error_handler(move_only_error_handler &&) = default;

STDEXEC_ATTRIBUTE(host, device) auto operator()(int error) const -> int
{
return error;
}
};

static_assert(std::is_trivially_copyable_v<move_only_error_handler>);
static_assert(!std::is_copy_constructible_v<move_only_error_handler>);

TEST_CASE("nvexec upon_error returns a sender", "[cuda][stream][adaptors][upon_error]")
{
nvexec::stream_context stream_ctx{};
Expand All @@ -21,6 +40,18 @@ namespace
(void) snd;
}

TEST_CASE("nvexec upon_error supports move-only function objects",
"[cuda][stream][adaptors][upon_error]")
{
nvexec::stream_context stream_ctx{};

auto snd = ex::just_error(42) | ex::continues_on(stream_ctx.get_scheduler())
| ex::upon_error(move_only_error_handler{});
auto const [result] = STDEXEC::sync_wait(std::move(snd)).value();

REQUIRE(result == 42);
}

TEST_CASE("nvexec upon_error executes on GPU", "[cuda][stream][adaptors][upon_error]")
{
nvexec::stream_context stream_ctx{};
Expand Down
Loading