@@ -69,9 +69,18 @@ namespace hpx::parallel::util::detail {
6969 auto && shape =
7070 detail::get_bulk_iteration_shape_idx (policy, first, count);
7171
72- return execution::bulk_async_execute (policy.executor (),
73- partitioner_iteration<Result, F>{HPX_FORWARD (F, f)},
74- reshape (HPX_MOVE (shape)));
72+ if constexpr (hpx::is_async_execution_policy_v<ExPolicy>)
73+ {
74+ return execution::bulk_async_execute (policy.executor (),
75+ partitioner_iteration<Result, F>{HPX_FORWARD (F, f)},
76+ reshape (HPX_MOVE (shape)));
77+ }
78+ else
79+ {
80+ return execution::bulk_sync_execute (policy.executor (),
81+ partitioner_iteration<Result, F>{HPX_FORWARD (F, f)},
82+ reshape (HPX_MOVE (shape)));
83+ }
7584 }
7685 else
7786 {
@@ -101,8 +110,8 @@ namespace hpx::parallel::util::detail {
101110
102111 template <typename ExPolicy_, typename FwdIter, typename F1,
103112 typename F2, typename ReShape = hpx::identity>
104- static decltype ( auto ) call(ExPolicy_&& policy, FwdIter first,
105- std:: size_t count, F1&& f1, F2&& f2, ReShape&& reshape = ReShape{})
113+ static auto call (ExPolicy_&& policy, FwdIter first, std:: size_t count ,
114+ F1&& f1, F2&& f2, ReShape&& reshape = ReShape{})
106115 {
107116 // inform parameter traits
108117 using scoped_executor_parameters =
@@ -115,14 +124,28 @@ namespace hpx::parallel::util::detail {
115124 FwdIter last = parallel::detail::next (first, count);
116125 try
117126 {
118- auto && items = detail::foreach_partition<Result>(
119- HPX_FORWARD (ExPolicy_, policy), first, count,
120- HPX_FORWARD (F1, f1), HPX_FORWARD (ReShape, reshape));
127+ if constexpr (std::is_void_v<decltype (foreach_partition<Result>(
128+ policy, first, count, f1, reshape))>)
129+ {
130+ detail::foreach_partition<Result>(
131+ HPX_FORWARD (ExPolicy_, policy), first, count,
132+ HPX_FORWARD (F1, f1), HPX_FORWARD (ReShape, reshape));
121133
122- scoped_params.mark_end_of_scheduling ();
134+ scoped_params.mark_end_of_scheduling ();
123135
124- return reduce (
125- HPX_MOVE (items), HPX_FORWARD (F2, f2), HPX_MOVE (last));
136+ return HPX_INVOKE (f2, HPX_MOVE (last));
137+ }
138+ else
139+ {
140+ auto && items = foreach_partition<Result>(
141+ HPX_FORWARD (ExPolicy_, policy), first, count,
142+ HPX_FORWARD (F1, f1), HPX_FORWARD (ReShape, reshape));
143+
144+ scoped_params.mark_end_of_scheduling ();
145+
146+ return reduce (
147+ HPX_MOVE (items), HPX_FORWARD (F2, f2), HPX_MOVE (last));
148+ }
126149 }
127150 catch (...)
128151 {
0 commit comments