Repository navigation
Add Rules policy parameter and tuned variant for local_workrequesting_scheduler #8229
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
Open
shivansh023023
wants to merge
2
commits into
TheHPXProject:master
Choose a base branch
from
shivansh023023:feat/workrequesting-scheduler-tuner
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.
+260
−13
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
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
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
103 changes: 103 additions & 0 deletions
103
libs/core/schedulers/include/hpx/schedulers/local_workrequesting_tuned_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,103 @@ | ||
| // Copyright (c) 2026 Hartmut Kaiser | ||
| // | ||
| // 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) | ||
|
|
||
| /// \file local_workrequesting_tuned_scheduler.hpp | ||
| /// \brief The local workrequesting scheduler with tunable rules | ||
| /// (local-workrequesting-tuned-fifo). | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <hpx/config.hpp> | ||
|
|
||
| #if defined(HPX_HAVE_WORK_REQUESTING_SCHEDULERS) | ||
|
|
||
| #include <hpx/modules/threading_base.hpp> | ||
| #include <hpx/schedulers/local_workrequesting_scheduler.hpp> | ||
| #include <hpx/schedulers/lockfree_queue_backends.hpp> | ||
|
|
||
| #include <memory> | ||
| #include <mutex> | ||
| #include <string_view> | ||
|
|
||
| #include <hpx/config/warnings_prefix.hpp> | ||
|
|
||
| namespace hpx::threads::policies { | ||
|
|
||
| /// The local workrequesting scheduler with tunable rules | ||
| /// (local-workrequesting-tuned-fifo). It places, queues, and requests | ||
| /// tasks as the local workrequesting scheduler does, while taking the rules | ||
| /// that control idle backoff behavior from scheduling_policy. The numbers | ||
| /// and switches of these rules are tunable settings (see | ||
| /// scheduler_tuning_parameters), which the tuner selected with | ||
| /// hpx.scheduler_tuner may change while the scheduler runs. | ||
| HPX_CXX_CORE_EXPORT template <typename Mutex = std::mutex, | ||
| typename PendingQueuing = lockfree_fifo, | ||
| typename StagedQueuing = concurrentqueue_fifo, | ||
| typename TerminatedQueuing = | ||
| default_local_workrequesting_scheduler_terminated_queue> | ||
| class local_workrequesting_tuned_scheduler final | ||
| : public local_workrequesting_scheduler<Mutex, PendingQueuing, | ||
| StagedQueuing, TerminatedQueuing, tuned_scheduling_rules> | ||
| { | ||
| public: | ||
| using base_type = local_workrequesting_scheduler<Mutex, PendingQueuing, | ||
| StagedQueuing, TerminatedQueuing, tuned_scheduling_rules>; | ||
|
|
||
| // the parameters of the local workrequesting scheduler, and the | ||
| // values the settings of the rules start with | ||
| struct init_parameter : base_type::init_parameter_type | ||
| { | ||
| init_parameter(base_type::init_parameter_type const& init, | ||
| scheduling_policy_init_parameters const& policy_init = | ||
| scheduling_policy_init_parameters{}) noexcept | ||
| : base_type::init_parameter_type(init) | ||
| , policy_init_(policy_init) | ||
| { | ||
| } | ||
|
|
||
| scheduling_policy_init_parameters policy_init_; | ||
| }; | ||
| using init_parameter_type = init_parameter; | ||
|
|
||
| explicit local_workrequesting_tuned_scheduler( | ||
| init_parameter_type const& init, | ||
| bool const deferred_initialization = true) | ||
| : base_type(init, deferred_initialization) | ||
| { | ||
| this->rules_.register_parameters( | ||
| this->thread_queue_init_, init.policy_init_); | ||
| this->rules_.set_tuner(create_scheduler_tuner("static")); | ||
| } | ||
|
|
||
| static constexpr std::string_view get_scheduler_name() noexcept | ||
| { | ||
| return "local_workrequesting_tuned_scheduler"; | ||
| } | ||
|
|
||
| /// Replace the tuner that decides the values of the tunable settings | ||
| /// (see hpx.scheduler_tuner). Called before the workers start. | ||
| void set_tuner(std::unique_ptr<scheduler_tuner> tuner) | ||
| { | ||
| this->rules_.set_tuner(HPX_MOVE(tuner)); | ||
| } | ||
|
|
||
| /// The tunable settings of the rules of this scheduler. | ||
| [[nodiscard]] scheduler_tuning_parameters& | ||
| get_tuning_parameters() noexcept | ||
| { | ||
| return this->rules_.parameters(); | ||
| } | ||
| [[nodiscard]] scheduler_tuning_parameters const& get_tuning_parameters() | ||
| const noexcept | ||
| { | ||
| return this->rules_.parameters(); | ||
| } | ||
| }; | ||
| } // namespace hpx::threads::policies | ||
|
|
||
| #include <hpx/config/warnings_suffix.hpp> | ||
|
|
||
| #endif |
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
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.
Uh oh!
There was an error while loading. Please reload this page.