Skip to content

Commit bdde14c

Browse files
Do not invoke bulk_chunked for zero shape (NVIDIA#2210)
* Fix bulk_chunked zero shape * Format bulk chunked changes
1 parent caef563 commit bdde14c

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

include/stdexec/__detail/__bulk.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ namespace STDEXEC
281281

282282
STDEXEC_TRY
283283
{
284-
__state.__data_.__fun_(__shape_t(), __shape_t(__state.__data_.__shape_), __args...);
284+
if (__shape_t{} < __state.__data_.__shape_)
285+
{
286+
__state.__data_.__fun_(__shape_t(), __shape_t(__state.__data_.__shape_), __args...);
287+
}
285288
STDEXEC::set_value(static_cast<_State&&>(__state).__rcvr_,
286289
static_cast<_Args&&>(__args)...);
287290
}

test/stdexec/algos/adaptors/test_bulk.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,26 @@ namespace
701701
ex::start(op);
702702
}
703703

704+
TEST_CASE("bulk_chunked function is not called with a zero shape", "[adaptors][bulk]")
705+
{
706+
int called{};
707+
708+
auto snd = ex::just() | ex::bulk_chunked(ex::seq, 0, [&called](int, int) { called++; });
709+
ex::sync_wait(std::move(snd));
710+
711+
CHECK(called == 0);
712+
}
713+
714+
TEST_CASE("bulk_chunked function is not called with a negative shape", "[adaptors][bulk]")
715+
{
716+
int called{};
717+
718+
auto snd = ex::just() | ex::bulk_chunked(ex::seq, -1, [&called](int, int) { called++; });
719+
ex::sync_wait(std::move(snd));
720+
721+
CHECK(called == 0);
722+
}
723+
704724
TEST_CASE("bulk_unchunked function in not called on stop", "[adaptors][bulk]")
705725
{
706726
constexpr int n = 2;

0 commit comments

Comments
 (0)