Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/library/include/chplx/begin.hpp b/library/include/chplx/begin.hpp
- index 95ec4a5a..456b50cc 100644
- --- a/library/include/chplx/begin.hpp
- +++ b/library/include/chplx/begin.hpp
- @@ -20,20 +20,20 @@
- namespace chplx {
- template <typename F, typename... Args>
- - void begin(hpx::source_location const& location, F&& f, Args&&... args)
- + requires(!std::is_same_v<std::decay_t<F>, hpx::source_location>)
- + void begin(F&& f, Args&&... args)
- {
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- hpx::parallel::execution::post(hpx::execution::par.executor(),
- + std::forward<F>(f),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...);
- +#else
- + px::parallel::execution::post(hpx::execution::par.executor(),
- hpx::annotated_function(
- std::forward<F>(f), detail::generate_annotation(location)),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...);
- - }
- -
- - template <typename F, typename... Args>
- - requires(!std::is_same_v<std::decay_t<F>, hpx::source_location>)
- - void begin(F&& f, Args&&... args)
- - {
- - begin(HPX_CURRENT_SOURCE_LOCATION(), std::forward<F>(f),
- - std::forward<Args>(args)...);
- +#endif
- }
- } // namespace chplx
- diff --git a/library/include/chplx/cobegin.hpp b/library/include/chplx/cobegin.hpp
- index 82a6d1f9..e393fdfc 100644
- --- a/library/include/chplx/cobegin.hpp
- +++ b/library/include/chplx/cobegin.hpp
- @@ -34,7 +34,15 @@ namespace chplx {
- requires(!std::is_same_v<std::decay_t<F>, hpx::source_location>)
- void cobegin(F&& f, Fs&&... fs)
- {
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + auto exec = hpx::execution::par.executor();
- + hpx::experimental::task_group g;
- + g.run(exec, std::forward<F>(f));
- + (g.run(exec, std::forward<F>(fs)), ...);
- + g.wait();
- +#else
- cobegin(HPX_CURRENT_SOURCE_LOCATION(), std::forward<F>(f),
- std::forward<Fs>(fs)...);
- +#endif
- }
- } // namespace chplx
- diff --git a/library/include/chplx/coforall_loop.hpp b/library/include/chplx/coforall_loop.hpp
- index a07130b0..2ca238f7 100644
- --- a/library/include/chplx/coforall_loop.hpp
- +++ b/library/include/chplx/coforall_loop.hpp
- @@ -77,20 +77,28 @@ namespace chplx {
- void coforall(hpx::source_location const& location, Tuple<Ts...>& t, F&& f,
- Args&&... args)
- {
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + detail::coforall(t, std::forward<F>(f), std::forward<Args>(args)...);
- +#else
- detail::coforall(t,
- hpx::annotated_function(
- std::forward<F>(f), detail::generate_annotation(location)),
- std::forward<Args>(args)...);
- +#endif
- }
- template <typename... Ts, typename F, typename... Args>
- void coforall(hpx::source_location const& location, Tuple<Ts...> const& t,
- F&& f, Args&&... args)
- {
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + detail::coforall(t, std::forward<F>(f), std::forward<Args>(args)...);
- +#else
- detail::coforall(t,
- hpx::annotated_function(
- std::forward<F>(f), detail::generate_annotation(location)),
- std::forward<Args>(args)...);
- +#endif
- }
- //-----------------------------------------------------------------------------
- @@ -103,6 +111,17 @@ namespace chplx {
- auto policy =
- hpx::parallel::util::adapt_sharing_mode(hpx::execution::par,
- hpx::threads::thread_sharing_hint::do_not_combine_tasks);
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + hpx::wait_all(hpx::parallel::execution::bulk_async_execute(
- + policy.executor(),
- + [&](std::size_t idx, auto&&... fargs) {
- + return f(r.orderToIndex(idx),
- + std::forward<decltype(args)>(fargs)...);
- + },
- + r.size(),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...));
- +#else
- auto wrapped =
- hpx::annotated_function(f, detail::generate_annotation(location));
- @@ -115,6 +134,7 @@ namespace chplx {
- r.size(),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...));
- +#endif
- }
- //-----------------------------------------------------------------------------
- @@ -126,6 +146,18 @@ namespace chplx {
- auto policy =
- hpx::parallel::util::adapt_sharing_mode(hpx::execution::par,
- hpx::threads::thread_sharing_hint::do_not_combine_tasks);
- +
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + hpx::wait_all(hpx::parallel::execution::bulk_async_execute(
- + policy.executor(),
- + [&](std::size_t idx, auto&&... fargs) {
- + return f(d.orderToIndex(idx),
- + std::forward<decltype(args)>(fargs)...);
- + },
- + d.size(),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...));
- +#else
- auto wrapped =
- hpx::annotated_function(f, detail::generate_annotation(location));
- @@ -138,6 +170,7 @@ namespace chplx {
- d.size(),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...));
- +#endif
- }
- //-----------------------------------------------------------------------------
- @@ -149,6 +182,17 @@ namespace chplx {
- auto policy =
- hpx::parallel::util::adapt_sharing_mode(hpx::execution::par,
- hpx::threads::thread_sharing_hint::do_not_combine_tasks);
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + hpx::wait_all(hpx::parallel::execution::bulk_async_execute(
- + policy.executor(),
- + [&](std::size_t idx, auto&&... fargs) {
- + return f(d.orderToIndex(idx),
- + std::forward<decltype(args)>(fargs)...);
- + },
- + d.size(),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...));
- +#else
- auto wrapped =
- hpx::annotated_function(f, detail::generate_annotation(location));
- @@ -161,6 +205,7 @@ namespace chplx {
- d.size(),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...));
- +#endif
- }
- //-----------------------------------------------------------------------------
- @@ -172,6 +217,18 @@ namespace chplx {
- auto policy =
- hpx::parallel::util::adapt_sharing_mode(hpx::execution::par,
- hpx::threads::thread_sharing_hint::do_not_combine_tasks);
- +
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + hpx::wait_all(hpx::parallel::execution::bulk_async_execute(
- + policy.executor(),
- + [&](std::size_t idx, auto&&... fargs) {
- + return f(zr.orderToIndex(idx),
- + std::forward<decltype(args)>(fargs)...);
- + },
- + zr.size(),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...));
- +#else
- auto wrapped =
- hpx::annotated_function(f, detail::generate_annotation(location));
- @@ -184,6 +241,7 @@ namespace chplx {
- zr.size(),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...));
- +#endif
- }
- //-----------------------------------------------------------------------------
- @@ -195,6 +253,16 @@ namespace chplx {
- auto policy =
- hpx::parallel::util::adapt_sharing_mode(hpx::execution::par,
- hpx::threads::thread_sharing_hint::do_not_combine_tasks);
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + hpx::wait_all(hpx::parallel::execution::bulk_async_execute(
- + policy.executor(),
- + [&](std::size_t idx, auto&&... fargs) {
- + return f(a[idx], std::forward<decltype(args)>(fargs)...);
- + },
- + a.size(),
- + detail::task_intent<std::decay_t<Args>>::call(
- + std::forward<Args>(args))...));
- +#else
- auto wrapped =
- hpx::annotated_function(f, detail::generate_annotation(location));
- @@ -206,6 +274,7 @@ namespace chplx {
- a.size(),
- detail::task_intent<std::decay_t<Args>>::call(
- std::forward<Args>(args))...));
- +#endif
- }
- template <typename Target, typename F, typename... Args>
- diff --git a/library/src/detail/generate_annotation.cpp b/library/src/detail/generate_annotation.cpp
- index e07ac7a1..de44db84 100644
- --- a/library/src/detail/generate_annotation.cpp
- +++ b/library/src/detail/generate_annotation.cpp
- @@ -16,9 +16,13 @@ namespace chplx::detail {
- std::string generate_annotation(hpx::source_location const& location)
- {
- #if defined(HPX_HAVE_THREAD_DESCRIPTION)
- +#if defined(CHPLX_NO_SOURCE_LOCATION)
- + return {};
- +#else
- std::filesystem::path p(location.file_name());
- return hpx::util::format("%s(%d): %s", p.filename(), location.line(),
- location.function_name());
- +#endif
- #else
- return {};
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement