@@ -92,6 +92,21 @@ S distributed_folding_map(ForwardIt first, ForwardIt last, MapF&& map_kernel,
9292 using itr_traits = distributed_iterator_traits<ForwardIt>;
9393 auto localities = itr_traits::localities (first, last);
9494 auto res = init_sol;
95+ #ifdef HAVE_HPX
96+ for (auto locality = localities.begin (), end = localities.end ();
97+ locality != end; ++locality) {
98+ auto d_args = std::make_tuple (shad::rt::lambda_wrapper<std::decay_t <MapF>>(
99+ std::forward<MapF>(map_kernel)),
100+ first, last, res, args...);
101+ rt::executeAtWithRet (
102+ locality,
103+ [](const typeof (d_args)& d_args, S* result) {
104+ *result = apply_from<1 >(::std::get<0 >(d_args),
105+ ::std::forward<typeof (d_args)>(d_args));
106+ },
107+ d_args, &res);
108+ }
109+ #else
95110 for (auto locality = localities.begin (), end = localities.end ();
96111 locality != end; ++locality) {
97112 auto d_args = std::make_tuple (map_kernel, first, last, res, args...);
@@ -103,6 +118,7 @@ S distributed_folding_map(ForwardIt first, ForwardIt last, MapF&& map_kernel,
103118 },
104119 d_args, &res);
105120 }
121+ #endif
106122 return res;
107123}
108124
@@ -112,6 +128,21 @@ void distributed_folding_map_void(ForwardIt first, ForwardIt last,
112128 MapF&& map_kernel, Args&&... args) {
113129 using itr_traits = distributed_iterator_traits<ForwardIt>;
114130 auto localities = itr_traits::localities (first, last);
131+ #ifdef HAVE_HPX
132+ for (auto locality = localities.begin (), end = localities.end ();
133+ locality != end; ++locality) {
134+ auto d_args = std::make_tuple (shad::rt::lambda_wrapper<std::decay_t <MapF>>(
135+ std::forward<MapF>(map_kernel)),
136+ first, last, args...);
137+ rt::executeAt (
138+ locality,
139+ [](const typeof (d_args)& d_args) {
140+ apply_from<1 >(::std::get<0 >(d_args),
141+ ::std::forward<typeof (d_args)>(d_args));
142+ },
143+ d_args);
144+ }
145+ #else
115146 for (auto locality = localities.begin (), end = localities.end ();
116147 locality != end; ++locality) {
117148 auto d_args = std::make_tuple (map_kernel, first, last, args...);
@@ -123,6 +154,7 @@ void distributed_folding_map_void(ForwardIt first, ForwardIt last,
123154 },
124155 d_args);
125156 }
157+ #endif
126158}
127159
128160// distributed_folding_map variant testing for early termination
@@ -134,6 +166,22 @@ S distributed_folding_map_early_termination(ForwardIt first, ForwardIt last,
134166 using itr_traits = distributed_iterator_traits<ForwardIt>;
135167 auto localities = itr_traits::localities (first, last);
136168 auto res = init_sol;
169+ #ifdef HAVE_HPX
170+ for (auto locality = localities.begin (), end = localities.end ();
171+ locality != end; ++locality) {
172+ auto d_args = std::make_tuple (shad::rt::lambda_wrapper<std::decay_t <MapF>>(
173+ std::forward<MapF>(map_kernel)),
174+ first, last, res, args...);
175+ rt::executeAtWithRet (
176+ locality,
177+ [](const typeof (d_args)& d_args, S* result) {
178+ *result = apply_from<1 >(::std::get<0 >(d_args),
179+ ::std::forward<typeof (d_args)>(d_args));
180+ },
181+ d_args, &res);
182+ if (halt (res)) return res;
183+ }
184+ #else
137185 for (auto locality = localities.begin (), end = localities.end ();
138186 locality != end; ++locality) {
139187 auto d_args = std::make_tuple (map_kernel, first, last, res, args...);
@@ -146,6 +194,8 @@ S distributed_folding_map_early_termination(ForwardIt first, ForwardIt last,
146194 d_args, &res);
147195 if (halt (res)) return res;
148196 }
197+ #endif
198+
149199 return res;
150200}
151201
@@ -205,7 +255,13 @@ distributed_map_init(
205255 auto localities = itr_traits::localities (first, last);
206256 size_t i = 0 ;
207257 rt::Handle h;
258+ #ifdef HAVE_HPX
259+ auto d_args = std::make_tuple (shad::rt::lambda_wrapper<std::decay_t <MapF>>(
260+ std::forward<MapF>(map_kernel)),
261+ first, last, args...);
262+ #else
208263 auto d_args = std::make_tuple (map_kernel, first, last, args...);
264+ #endif
209265 optional_vector<mapped_t > opt_res (localities.size (), init);
210266 for (auto locality = localities.begin (), end = localities.end ();
211267 locality != end; ++locality, ++i) {
@@ -255,7 +311,13 @@ void distributed_map_void(ForwardIt first, ForwardIt last, MapF&& map_kernel,
255311 auto localities = itr_traits::localities (first, last);
256312 size_t i = 0 ;
257313 rt::Handle h;
314+ #ifdef HAVE_HPX
315+ auto d_args = std::make_tuple (shad::rt::lambda_wrapper<std::decay_t <MapF>>(
316+ std::forward<MapF>(map_kernel)),
317+ first, last, args...);
318+ #else
258319 auto d_args = std::make_tuple (map_kernel, first, last, args...);
320+ #endif
259321 for (auto locality = localities.begin (), end = localities.end ();
260322 locality != end; ++locality, ++i) {
261323 rt::asyncExecuteAt (
@@ -301,7 +363,15 @@ local_map_init(
301363 std::vector<mapped_t > map_res (parts.size (), init);
302364
303365 if (parts.size ()) {
366+ #ifdef HAVE_HPX
367+ auto map_args =
368+ std::make_tuple (parts.data (),
369+ shad::rt::lambda_wrapper<std::decay_t <MapF>>(
370+ std::forward<MapF>(map_kernel)),
371+ map_res.data ());
372+ #else
304373 auto map_args = std::make_tuple (parts.data (), map_kernel, map_res.data ());
374+ #endif
305375 shad::rt::forEachAt (
306376 rt::thisLocality (),
307377 [](const typeof (map_args)& map_args, size_t iter) {
@@ -339,7 +409,13 @@ void local_map_void(ForwardIt first, ForwardIt last, MapF&& map_kernel) {
339409 first, last, rt::impl::getConcurrency ());
340410
341411 if (parts.size ()) {
412+ #ifdef HAVE_HPX
413+ auto map_args = std::make_tuple (
414+ parts.data (), shad::rt::lambda_wrapper<std::decay_t <MapF>>(
415+ std::forward<MapF>(map_kernel)));
416+ #else
342417 auto map_args = std::make_tuple (parts.data (), map_kernel);
418+ #endif
343419 shad::rt::forEachAt (
344420 rt::thisLocality (),
345421 [](const typeof (map_args)& map_args, size_t iter) {
@@ -361,7 +437,15 @@ void local_map_void_offset(ForwardIt first, ForwardIt last, MapF&& map_kernel) {
361437 first, last, rt::impl::getConcurrency ());
362438
363439 if (parts.size ()) {
440+ #ifdef HAVE_HPX
441+ auto map_args =
442+ std::make_tuple (parts.data (),
443+ shad::rt::lambda_wrapper<std::decay_t <MapF>>(
444+ std::forward<MapF>(map_kernel)),
445+ first);
446+ #else
364447 auto map_args = std::make_tuple (parts.data (), map_kernel, first);
448+ #endif
365449 shad::rt::forEachAt (
366450 rt::thisLocality (),
367451 [](const typeof (map_args)& map_args, size_t iter) {
0 commit comments