Skip to content

Commit 91b9649

Browse files
author
Sai Charan
committed
fix
1 parent 610b3fd commit 91b9649

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

libs/core/executors/include/hpx/executors/scheduler_executor.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,23 @@ namespace hpx::execution::experimental {
270270
hpx::parallel::execution::bulk_sync_execute_t,
271271
scheduler_executor const& exec, F&& f, S const& shape, Ts&&... ts)
272272
{
273-
// For non-integral shapes (e.g., iterator ranges with tuples),
274-
// we need to iterate over the shape elements and call the function
275-
// with each element. stdexec's bulk() only accepts integral shapes.
273+
#if defined(HPX_HAVE_STDEXEC)
274+
// stdexec's bulk() handles non-integral shapes correctly
275+
hpx::this_thread::experimental::sync_wait(
276+
bulk(schedule(exec.sched_), hpx::util::size(shape),
277+
hpx::bind_back(HPX_FORWARD(F, f), HPX_FORWARD(Ts, ts)...)));
278+
#else
279+
// HPX's bulk() converts integer to counting_shape which only
280+
// provides indices. For non-integral shapes (e.g., iterator ranges
281+
// with tuples), we need to iterate over shape elements manually.
276282
hpx::this_thread::experimental::sync_wait(then(schedule(exec.sched_),
277283
[&f, &shape, &ts...]() {
278284
for (auto const& elem : shape)
279285
{
280286
HPX_INVOKE(f, elem, ts...);
281287
}
282288
}));
289+
#endif
283290
}
284291

285292
// clang-format off

0 commit comments

Comments
 (0)