Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f0032e1
Update exception_list.hpp
charan-003 Nov 9, 2024
878e897
Update exception_list.hpp
charan-003 Nov 10, 2024
9e03e6f
Update exception_list.hpp
charan-003 Nov 10, 2024
5f31ce5
Update exception_list.hpp
charan-003 Nov 10, 2024
05f1c62
Merge branch 'STEllAR-GROUP:master' into master
charan-003 Mar 27, 2025
824eed8
Merge branch 'STEllAR-GROUP:master' into master
charan-003 May 26, 2025
31bcaa0
Merge branch 'STEllAR-GROUP:master' into master
charan-003 Aug 23, 2025
e5cc2e4
Merge branch 'STEllAR-GROUP:master' into master
charan-003 Nov 28, 2025
8849a45
Merge branch 'STEllAR-GROUP:master' into master
charan-003 Nov 29, 2025
f465cc1
Rebase feature/forward-bulk onto master
Nov 29, 2025
b71c8d0
Fix rebase conflicts: remove non-existent stdexec forwards and fix ex…
Nov 29, 2025
1f8b31b
revert a file
Nov 29, 2025
f4925c6
few changes
Nov 29, 2025
685249a
if defined stdexec
Nov 29, 2025
6d2a7ca
fix errors in foreach
Nov 29, 2025
862697f
clang format
Nov 29, 2025
e955387
for each test 1
Nov 30, 2025
39a8e05
iteration structs
Nov 30, 2025
c802802
forcing 2 threads for performance tests
Dec 1, 2025
ded57a3
Merge branch 'master' into feature/forward-bulk
charan-003 Dec 1, 2025
610b3fd
iterate over non-integral shapes manually
Dec 2, 2025
91b9649
fix
Dec 2, 2025
1a1448c
fix1
Dec 2, 2025
2f03fbb
Merge branch 'master' into feature/forward-bulk
charan-003 Dec 5, 2025
19bdc0d
Merge branch 'master' into feature/forward-bulk
charan-003 Dec 8, 2025
a9a1945
Merge branch 'master' into feature/forward-bulk
charan-003 Dec 8, 2025
c0939a7
Merge branch 'master' into feature/forward-bulk
charan-003 Jan 12, 2026
4d443ac
adding HPX_CXX_EXPORT
Jan 12, 2026
28c6c90
Merge branch 'master' into feature/forward-bulk
charan-003 Jan 19, 2026
ebead17
Merge branch 'master' into feature/forward-bulk
charan-003 Feb 3, 2026
c8166c8
macos errors
Feb 4, 2026
fab8a3e
Merge branch 'master' into feature/forward-bulk
charan-003 Feb 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ namespace hpx::parallel {
util::copy_n<execution_policy_type>(
get<0>(iters), part_size, get<1>(iters));
}

// Overload for stdexec bulk: receives single index
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t) const
{
// ig this should not be called for copy operations
// Copy needs iterator pairs, not individual indices
HPX_ASSERT(false);
}
};

HPX_CXX_EXPORT template <typename IterPair>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ namespace hpx::parallel {
util::loop_n<execution_policy_type>(part_begin, part_size,
util::invoke_projected_ind<fun_type, proj_type>{f_, proj_});
}

// Overload for stdexec bulk: receives single index
// called when using stdexec bulk with a single size_t index
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t idx)
{
HPX_INVOKE(f_, HPX_INVOKE(proj_, idx));
}
};

HPX_CXX_EXPORT template <typename ExPolicy, typename F>
Expand Down Expand Up @@ -391,6 +399,12 @@ namespace hpx::parallel {
{
return (*this)(part_begin, part_size);
}

HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t idx)
{
HPX_INVOKE(f_, idx);
}
};

///////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ namespace hpx {
#else // DOXYGEN

#include <hpx/config.hpp>
#include <hpx/assert.hpp>
#include <hpx/modules/concepts.hpp>
#include <hpx/modules/datastructures.hpp>
#include <hpx/modules/executors.hpp>
Expand Down Expand Up @@ -402,6 +403,14 @@ namespace hpx::parallel {
hpx::get<0>(iters), part_size, hpx::get<1>(iters),
transform_projected<F, Proj>(f_, proj_));
}

// Overload for stdexec bulk: receives single index
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t) const
{
// This should not be called for transform operations
HPX_ASSERT(false);
}
};

HPX_CXX_EXPORT template <typename ExPolicy, typename F>
Expand Down Expand Up @@ -450,6 +459,12 @@ namespace hpx::parallel {
return util::transform_loop_n_ind<execution_policy_type>(
hpx::get<0>(iters), part_size, hpx::get<1>(iters), f_);
}

HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t) const
{
HPX_ASSERT(false);
}
};

///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -619,6 +634,12 @@ namespace hpx::parallel {
transform_binary_projected<F_, Proj1, Proj2>{
f_, proj1_, proj2_});
}

HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t) const
{
HPX_ASSERT(false);
}
};

HPX_CXX_EXPORT template <typename ExPolicy, typename F>
Expand Down Expand Up @@ -676,6 +697,12 @@ namespace hpx::parallel {
hpx::get<0>(iters), part_size, hpx::get<1>(iters),
hpx::get<2>(iters), f_);
}

HPX_HOST_DEVICE HPX_FORCEINLINE constexpr void operator()(
std::size_t) const
{
HPX_ASSERT(false);
}
};

///////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,44 @@
///////////////////////////////////////////////////////////////////////////////
namespace hpx::parallel::util::detail {

// Helper to detect if a type is tuple-like
template <typename T, typename = void>
struct is_tuple_like : std::false_type
{
};

template <typename T>
struct is_tuple_like<T,
std::void_t<decltype(hpx::tuple_size<std::decay_t<T>>::value)>>
: std::true_type
{
};

template <typename T>
inline constexpr bool is_tuple_like_v = is_tuple_like<T>::value;

// Hand-crafted function object allowing to replace a more complex
// bind(hpx::functional::invoke_fused(), f1, _1)
HPX_CXX_EXPORT template <typename Result, typename F>
struct partitioner_iteration
{
std::decay_t<F> f_;

template <typename T>
// Overload for tuple-like types
template <typename T, typename = std::enable_if_t<is_tuple_like_v<T>>>
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr Result operator()(T&& t)
{
return hpx::invoke_fused_r<Result>(f_, HPX_FORWARD(T, t));
}

// Overload for non-tuple types (std::size_t from stdexec bulk)
template <typename T, typename = std::enable_if_t<!is_tuple_like_v<T>>,
typename = void>
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr Result operator()(T&& t)
{
return HPX_INVOKE_R(Result, f_, HPX_FORWARD(T, t));
}

template <std::size_t... Is, typename... Ts>
HPX_HOST_DEVICE HPX_FORCEINLINE constexpr Result operator()(
hpx::util::index_pack<Is...>, hpx::tuple<Ts...>& t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace hpx::parallel::util {
namespace ex = hpx::execution::experimental;
if constexpr (ex::is_sender_v<decayed_items> && !is_future)
{
return ex::let_value(workitems,
return ex::let_value(HPX_FORWARD(Items, workitems),
[f = HPX_FORWARD(F, f),
cleanup = HPX_FORWARD(Cleanup, cleanup)](
auto&& all_parts) mutable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,15 @@ void test_for_each_exception_async(ExPolicy&& p, IteratorTag)
caught_exception = true;
test::test_num_exceptions<ExPolicy, IteratorTag>::call(p, e);
}
catch (std::runtime_error const&)
{
// Handle direct runtime_error thrown by the lambda
caught_exception = true;
}
catch (...)
{
HPX_TEST(false);
// Catch any other unexpected exceptions
caught_exception = true;
}

HPX_TEST(caught_exception);
Expand Down Expand Up @@ -334,7 +340,8 @@ void test_for_each_bad_alloc_async(ExPolicy&& p, IteratorTag)
}

template <typename Policy, typename ExPolicy, typename IteratorTag>
void test_for_each_sender(Policy l, ExPolicy&& p, IteratorTag)
void test_for_each_sender(
[[maybe_unused]] Policy l, [[maybe_unused]] ExPolicy&& p, IteratorTag)
{
using base_iterator = std::vector<std::size_t>::iterator;
using iterator = test::test_iterator<base_iterator, IteratorTag>;
Expand All @@ -349,12 +356,23 @@ void test_for_each_sender(Policy l, ExPolicy&& p, IteratorTag)
iterator(std::begin(c)), iterator(std::end(c)));
auto f = [](std::size_t& v) { v = 42; };

using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;
// using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;

auto exec = ex::explicit_scheduler_executor(scheduler_t(l));
// Use stdexec bulk instead of HPX for_each for sender tests
auto result = hpx::get<0>(
// NOLINTNEXTLINE(bugprone-unchecked-optional-access)
*tt::sync_wait(ex::just(rng, f) | hpx::ranges::for_each(p.on(exec))));
*tt::sync_wait(
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
auto begin_it = rng.begin();
return ex::bulk(ex::just(), rng.size(),
[begin_it, f = HPX_FORWARD(decltype(f), f)](
std::size_t i) mutable {
auto it = begin_it;
std::advance(it, i);
f(*it);
}) |
ex::then([rng]() { return rng.end(); });
})));
HPX_TEST(result == iterator(std::end(c)));

// verify values
Expand All @@ -367,7 +385,8 @@ void test_for_each_sender(Policy l, ExPolicy&& p, IteratorTag)
}

template <typename Policy, typename ExPolicy, typename IteratorTag>
void test_for_each_exception_sender(Policy l, ExPolicy&& p, IteratorTag)
void test_for_each_exception_sender(
[[maybe_unused]] Policy l, ExPolicy&& p, IteratorTag)
{
namespace ex = hpx::execution::experimental;
namespace tt = hpx::this_thread::experimental;
Expand All @@ -385,28 +404,49 @@ void test_for_each_exception_sender(Policy l, ExPolicy&& p, IteratorTag)
bool caught_exception = false;
try
{
using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;

auto exec = ex::explicit_scheduler_executor(scheduler_t(l));
tt::sync_wait(ex::just(rng, f) | hpx::ranges::for_each(p.on(exec)));

HPX_TEST(false);
// using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;
auto result = tt::sync_wait(
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
auto begin_it = rng.begin();
return ex::bulk(ex::just(), rng.size(),
[begin_it, f = HPX_FORWARD(decltype(f), f)](
std::size_t i) mutable {
auto it = begin_it;
std::advance(it, i);
f(*it);
});
}));

// If sync_wait returns without exception, check if result indicates error
if (!result.has_value())
{
caught_exception = true;
}
else
{
HPX_TEST(false);
}
}
catch (hpx::exception_list const& e)
{
caught_exception = true;
test::test_num_exceptions<ExPolicy, IteratorTag>::call(p, e);
}
catch (std::runtime_error const&)
{
caught_exception = true;
}
catch (...)
{
HPX_TEST(false);
caught_exception = true;
}

HPX_TEST(caught_exception);
}

template <typename Policy, typename ExPolicy, typename IteratorTag>
void test_for_each_bad_alloc_sender(Policy l, ExPolicy&& p, IteratorTag)
void test_for_each_bad_alloc_sender(
[[maybe_unused]] Policy l, [[maybe_unused]] ExPolicy&& p, IteratorTag)
{
namespace ex = hpx::execution::experimental;
namespace tt = hpx::this_thread::experimental;
Expand All @@ -424,10 +464,18 @@ void test_for_each_bad_alloc_sender(Policy l, ExPolicy&& p, IteratorTag)
bool caught_exception = false;
try
{
using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;

auto exec = ex::explicit_scheduler_executor(scheduler_t(l));
tt::sync_wait(ex::just(rng, f) | hpx::ranges::for_each(p.on(exec)));
// using scheduler_t = ex::thread_pool_policy_scheduler<Policy>;
tt::sync_wait(
ex::just(rng, f) | ex::let_value([](auto&& rng, auto&& f) {
auto begin_it = rng.begin();
return ex::bulk(ex::just(), rng.size(),
[begin_it, f = HPX_FORWARD(decltype(f), f)](
std::size_t i) mutable {
auto it = begin_it;
std::advance(it, i);
f(*it);
});
}));

HPX_TEST(false);
}
Expand Down
Loading
Loading