-
-
Notifications
You must be signed in to change notification settings - Fork 491
parallel_scheduler for P2079 Section 4.1 User Facing API (ref #6601) #6655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
charan-003
wants to merge
84
commits into
STEllAR-GROUP:master
Choose a base branch
from
charan-003:p2079-section-4.1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
84 commits
Select commit
Hold shift + click to select a range
8b6714d
docs: Fix spelling in example dictionary
af52bcf
Updated config
51f8347
Revert "docs: Fix spelling in example dictionary"
4f6b1d3
Updated Config
bfa3444
Updated to check for all files
de86694
Update README.rst
hkaiser 60b6256
parallel_scheduler for P2079 Section 4.1 User Facing API (ref #6601)
658835f
Fix formatting, resolve bulk_t include, and add test
ed18115
Fix include path to use hpx/execution/algorithms/bulk.hpp
3c11b9b
Update thread_pool_scheduler.hpp
charan-003 0bc8d53
Add null check and runtime init to parallel_scheduler to debug Circle…
02ececd
Refactor: move parallel_scheduler to separate header
345a957
Fix CircleCI errors: add parallel_scheduler.hpp to CMakeLists, apply …
8e161d1
Update parallel_scheduler.hpp includes
bbd6708
Fixed inspect and test.headers
45d6340
Update parallel_scheduler.hpp
df9130c
Update parallel_scheduler.hpp
9c31037
Update parallel_scheduler.hpp
23a00dd
use east const, make get_thread_pool constexpr, improve bulk concurre…
e9582eb
Add p2079 parallel_scheduler implementation to HPX
cb1383b
Fixed Clang_format
54b6648
Fixed Clang_format
b906b22
Fixed Clang format
9639ec5
Fixed Clang format
6ac6d57
Update parallel_scheduler.hpp
charan-003 b6b49c3
Fixed Clang format by disabling
e27a582
Implemented parallel_scheduler with HPX async:
6beec67
fix circular desp
ae7c560
/
ea447ab
Implement P2079R7 parallel_scheduler in HPX using wrapper
131de3b
Implement P2079R7 parallel_scheduler in HPX using wrapper
f20e1ec
fixing circular deps
c18a13c
fixed cmakelist models
4625086
added missing includes
9825fd6
formating the file
5ef544f
emoving the forward declaration of hpx::get_num_worker_threads()
fc6ab4c
fix format
fd3085b
Update code to rely on STDEXEC
4359d16
Add HPX_WITH_STDEXEC=ON
d0ad0dc
use STDEXEC
523902f
Add conditional stdexec support in parallel_scheduler.hpp
69ab80e
apply clang format
55b691e
Update
4eed5ba
exceptions removed
94403fc
revert guided_pool_executor.hpp
a7569b5
Merge branch 'STEllAR-GROUP:master' into p2079-section-4.1
charan-003 8752188
update thread_pool_scheduler implementing p2079
d2a017f
update thread_pool_scheduler implementing p2079
7d23ec2
update thread_pool_scheduler implementing p2079
cf3e025
git push origin p2079-section-4.1added bulk_unchunked functionality t…
fcd4100
test unchunked
cc07053
fixing parallel_scheduler
b80264f
fixing inplace_stop_token
92f0d64
User-Supplied Function Interface
158fc54
fix queue_depth error
47eb7a4
fixed thrad_pool_scheduler
530e6ea
files mismatched
5e32ee2
files mismatched
911ed88
change
276d215
missing includes
ac53aed
implemented user_facing_api in thread_pool_scheduler
8fab595
implemented user_facing_api in thread_pool_scheduler
667a4ba
fixing errors in thread_pool_scheduler
ef753c1
fixing compilation errors in thread_pool_scheduler
9c97818
implemented user_facing_api in thread_pool_scheduler
e77fdef
user facing api in HPX
df1b71c
user facing api in HPX
9b7fc2b
fix user facing api in HPX
bdd71b3
fixing test errors
90fc6cf
fixing test errors
25478f2
fixing errors
77ccc80
fixing errors
8bc5e66
fixing errors
56d0bc8
fixing errors
78c0e4e
fixing errors
d0a80b7
fixing errors
97c7a75
fixing errors in test file
b911100
fixing errors in test file
4e5c18c
adding getter function
25416ac
adding getter function
charan-003 d29c834
using launch_policy
charan-003 873d706
using launch_policy_1
charan-003 7025dfd
implementation of bulk_chunk_1
charan-003 161dfde
Merge remote-tracking branch 'upstream/master' into p2079-section-4.1
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
270 changes: 270 additions & 0 deletions
270
libs/core/executors/include/hpx/executors/parallel_scheduler.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,270 @@ | ||
| // Copyright (c) 2025 Sai Charan Arvapally | ||
| // | ||
| // SPDX-License-Identifier: BSL-1.0 | ||
| // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <hpx/async_base/launch_policy.hpp> | ||
| #include <hpx/execution_base/stdexec_forward.hpp> | ||
| #include <hpx/executors/thread_pool_scheduler.hpp> | ||
| #include <hpx/executors/thread_pool_scheduler_bulk.hpp> // Added for P2079R10 compliance: include bulk_t | ||
| #include <hpx/threading_base/detail/get_default_pool.hpp> | ||
| #include <exception> | ||
| #include <memory> | ||
|
|
||
| #if !defined(HPX_HAVE_STDEXEC) | ||
| #include <hpx/execution/queries/get_stop_token.hpp> | ||
| #include <hpx/synchronization/stop_token.hpp> | ||
| #endif | ||
|
|
||
| namespace hpx::execution::experimental { | ||
|
|
||
| // Added for P2079R10 compliance: bulk_chunked_t tag | ||
| struct bulk_chunked_t | ||
| { | ||
| }; | ||
|
|
||
| namespace detail { | ||
| // Singleton-like shared thread pool for parallel_scheduler | ||
| inline hpx::threads::thread_pool_base* get_default_parallel_pool() | ||
| { | ||
| // clang-format off | ||
| static hpx::threads::thread_pool_base* default_pool = | ||
| hpx::threads::detail::get_self_or_default_pool(); | ||
| // clang-format on | ||
| return default_pool; | ||
| } | ||
| } // namespace detail | ||
|
|
||
| // Forward declarations | ||
| class parallel_scheduler; | ||
| struct parallel_scheduler_sender; | ||
|
|
||
| // P2079R10 parallel_scheduler implementation | ||
| class parallel_scheduler | ||
| { | ||
| public: | ||
| // Deleted default constructor | ||
| parallel_scheduler() = delete; | ||
|
|
||
| // Constructor from thread_pool_policy_scheduler | ||
| explicit parallel_scheduler( | ||
| thread_pool_policy_scheduler<hpx::launch> sched) noexcept | ||
| : scheduler_(sched) | ||
| { | ||
| } | ||
|
|
||
| // Copy constructor | ||
| parallel_scheduler(parallel_scheduler const& other) noexcept | ||
| : scheduler_(other.scheduler_) | ||
| { | ||
| } | ||
|
|
||
| // Move constructor | ||
| parallel_scheduler(parallel_scheduler&& other) noexcept | ||
| : scheduler_(HPX_MOVE(other.scheduler_)) | ||
| { | ||
| } | ||
|
|
||
| // Copy assignment | ||
| parallel_scheduler& operator=(parallel_scheduler const& other) noexcept | ||
| { | ||
| if (this != &other) | ||
| { | ||
| scheduler_ = other.scheduler_; | ||
| } | ||
| return *this; | ||
| } | ||
|
|
||
| // Move assignment | ||
| parallel_scheduler& operator=(parallel_scheduler&& other) noexcept | ||
| { | ||
| if (this != &other) | ||
| { | ||
| scheduler_ = HPX_MOVE(other.scheduler_); | ||
| } | ||
| return *this; | ||
| } | ||
|
|
||
| // Equality comparison | ||
| friend constexpr bool operator==(parallel_scheduler const& lhs, | ||
| parallel_scheduler const& rhs) noexcept | ||
| { | ||
| return lhs.scheduler_ == rhs.scheduler_; | ||
| } | ||
|
|
||
| // Query for forward progress guarantee | ||
| friend constexpr forward_progress_guarantee tag_invoke( | ||
| get_forward_progress_guarantee_t, | ||
| [[maybe_unused]] parallel_scheduler const&) noexcept | ||
| { | ||
| return forward_progress_guarantee::parallel; | ||
| } | ||
|
|
||
| // Schedule method returning a sender | ||
| friend parallel_scheduler_sender tag_invoke( | ||
| schedule_t, parallel_scheduler const& sched) noexcept; | ||
|
|
||
| // Support get_completion_scheduler for scheduler concept | ||
| template <typename CPO> | ||
| friend auto tag_invoke(get_completion_scheduler_t<CPO>, | ||
| [[maybe_unused]] parallel_scheduler const& sched) noexcept | ||
| -> std::enable_if_t<hpx::meta::value<hpx::meta::one_of<CPO, | ||
| set_value_t, set_stopped_t>>, | ||
| parallel_scheduler const&> | ||
| { | ||
| return sched; | ||
| } | ||
|
|
||
| // Friend declaration to allow parallel_scheduler_sender access | ||
| friend struct parallel_scheduler_sender; | ||
|
|
||
| // Public getter for the underlying scheduler | ||
| thread_pool_policy_scheduler<hpx::launch> const& | ||
| get_underlying_scheduler() const noexcept | ||
| { | ||
| return scheduler_; | ||
| } | ||
|
|
||
| private: | ||
| thread_pool_policy_scheduler<hpx::launch> scheduler_; | ||
| }; | ||
|
|
||
| // Sender for parallel_scheduler | ||
| struct parallel_scheduler_sender | ||
| { | ||
| parallel_scheduler scheduler; | ||
| #if defined(HPX_HAVE_STDEXEC) | ||
| using sender_concept = hpx::execution::experimental::sender_t; | ||
| using completion_signatures = | ||
| hpx::execution::experimental::completion_signatures< | ||
| hpx::execution::experimental::set_value_t(), | ||
| hpx::execution::experimental::set_error_t(std::exception_ptr), | ||
| hpx::execution::experimental::set_stopped_t()>; | ||
|
|
||
| template <typename Env> | ||
| friend auto tag_invoke( | ||
| hpx::execution::experimental::get_completion_signatures_t, | ||
| parallel_scheduler_sender const&, Env) noexcept | ||
| -> completion_signatures; | ||
| #else | ||
| // Fallback types when stdexec is not available | ||
| using sender_concept = void; // Minimal fallback to allow compilation | ||
| struct completion_signatures | ||
| { | ||
| }; // Empty struct as placeholder | ||
| #endif | ||
|
|
||
| template <typename Receiver> | ||
| friend auto tag_invoke( | ||
| connect_t, parallel_scheduler_sender const& s, Receiver&& receiver) | ||
| { | ||
| // clang-format off | ||
| return thread_pool_policy_scheduler<hpx::launch>:: | ||
| operation_state< | ||
| thread_pool_policy_scheduler<hpx::launch>, | ||
| Receiver>{ | ||
| s.scheduler.get_underlying_scheduler(), | ||
| HPX_FORWARD(Receiver, receiver)}; | ||
| // clang-format on | ||
| } | ||
|
|
||
| template <typename Receiver> | ||
| friend auto tag_invoke( | ||
| connect_t, parallel_scheduler_sender&& s, Receiver&& receiver) | ||
| { | ||
| // clang-format off | ||
| return thread_pool_policy_scheduler<hpx::launch>:: | ||
| operation_state< | ||
| thread_pool_policy_scheduler<hpx::launch>, | ||
| Receiver>{ | ||
| s.scheduler.get_underlying_scheduler(), | ||
| HPX_FORWARD(Receiver, receiver)}; | ||
| // clang-format on | ||
| } | ||
|
|
||
| template <typename Receiver> | ||
| friend auto tag_invoke( | ||
| connect_t, parallel_scheduler_sender& s, Receiver&& receiver) | ||
| { | ||
| // clang-format off | ||
| return thread_pool_policy_scheduler<hpx::launch>:: | ||
| operation_state< | ||
| thread_pool_policy_scheduler<hpx::launch>, | ||
| Receiver>{ | ||
| s.scheduler.get_underlying_scheduler(), | ||
| HPX_FORWARD(Receiver, receiver)}; | ||
| // clang-format on | ||
| } | ||
|
|
||
| struct env | ||
| { | ||
| parallel_scheduler const& sched; | ||
| template <typename CPO> | ||
| friend auto tag_invoke( | ||
| hpx::execution::experimental::get_completion_scheduler_t<CPO>, | ||
| env const& e) noexcept | ||
| -> std::enable_if_t<hpx::meta::value<hpx::meta::one_of<CPO, | ||
| set_value_t, set_stopped_t>>, | ||
| parallel_scheduler const&> | ||
| { | ||
| return e.sched; | ||
| } | ||
| }; | ||
|
|
||
| friend env tag_invoke(hpx::execution::experimental::get_env_t, | ||
| parallel_scheduler_sender const& s) noexcept | ||
| { | ||
| return {s.scheduler}; | ||
| } | ||
| }; | ||
|
|
||
| // Define schedule_t tag_invoke after parallel_scheduler_sender | ||
| inline parallel_scheduler_sender tag_invoke( | ||
| schedule_t, parallel_scheduler const& sched) noexcept | ||
| { | ||
| return {sched}; | ||
| } | ||
|
|
||
| // Added for P2079R10 compliance: bulk_chunked customization | ||
| template <typename Sender, typename Policy, typename Shape, typename F> | ||
| auto tag_invoke(bulk_chunked_t, parallel_scheduler scheduler, | ||
| Sender&& sender, Shape const& shape, F&& f) | ||
| { | ||
| return tag_invoke(bulk_t{}, scheduler.get_underlying_scheduler(), | ||
| HPX_FORWARD(Sender, sender), shape, HPX_FORWARD(F, f)); | ||
| } | ||
|
|
||
| // Stream output operator for parallel_scheduler | ||
| inline std::ostream& operator<<(std::ostream& os, const parallel_scheduler&) | ||
| { | ||
| return os << "parallel_scheduler"; | ||
| } | ||
|
|
||
| // P2079R10 get_parallel_scheduler function | ||
| inline parallel_scheduler get_parallel_scheduler() | ||
| { | ||
| // Use the default thread pool with async policy for parallel execution | ||
| auto pool = detail::get_default_parallel_pool(); | ||
| if (!pool) | ||
| { | ||
| // clang-format off | ||
| std::terminate(); // As per P2079R10, terminate if backend is unavailable | ||
| // clang-format on | ||
| } | ||
| return parallel_scheduler(thread_pool_policy_scheduler<hpx::launch>( | ||
| pool, hpx::launch::async)); | ||
| } | ||
|
|
||
| } // namespace hpx::execution::experimental | ||
|
|
||
| namespace hpx::execution::experimental::system_context_replaceability { | ||
| struct receiver_proxy; | ||
| struct bulk_item_receiver_proxy; | ||
| struct parallel_scheduler_backend; | ||
|
|
||
| std::shared_ptr<parallel_scheduler_backend> | ||
| query_parallel_scheduler_backend(); | ||
| } // namespace hpx::execution::experimental::system_context_replaceability | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.