hpx/threading_base/scheduler_base.hpp

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace threads
namespace policies

Functions

std::ostream &operator<<(std::ostream &os, scheduler_base const &scheduler)
struct scheduler_base
#include <scheduler_base.hpp>

The scheduler_base defines the interface to be implemented by all scheduler policies

Public Types

typedef std::mutex pu_mutex_type
using polling_function_ptr = detail::polling_status (*)()
using polling_work_count_function_ptr = std::size_t (*)()

Public Functions

HPX_NON_COPYABLE(scheduler_base)
scheduler_base(std::size_t num_threads, char const *description = "", thread_queue_init_parameters thread_queue_init = {}, scheduler_mode mode = scheduler_mode::nothing_special)
virtual ~scheduler_base()
threads::thread_pool_base *get_parent_pool() const
void set_parent_pool(threads::thread_pool_base *p)
std::size_t global_to_local_thread_index(std::size_t n)
std::size_t local_to_global_thread_index(std::size_t n)
char const *get_description() const
void idle_callback(std::size_t num_thread)
void do_some_work(std::size_t)

This function gets called by the thread-manager whenever new work has been added, allowing the scheduler to reactivate one or more of possibly idling OS threads

virtual void suspend(std::size_t num_thread)
virtual void resume(std::size_t num_thread)
std::size_t select_active_pu(std::unique_lock<pu_mutex_type> &l, std::size_t num_thread, bool allow_fallback = false)
std::atomic<hpx::state> &get_state(std::size_t num_thread)
std::atomic<hpx::state> const &get_state(std::size_t num_thread) const
void set_all_states(hpx::state s)
void set_all_states_at_least(hpx::state s)
bool has_reached_state(hpx::state s) const
bool is_state(hpx::state s) const
std::pair<hpx::state, hpx::state> get_minmax_state() const
scheduler_mode get_scheduler_mode() const
bool has_scheduler_mode(scheduler_mode mode) const
virtual void set_scheduler_mode(scheduler_mode mode)
void add_scheduler_mode(scheduler_mode mode)
void remove_scheduler_mode(scheduler_mode mode)
void add_remove_scheduler_mode(scheduler_mode to_add_mode, scheduler_mode to_remove_mode)
void update_scheduler_mode(scheduler_mode mode, bool set)
pu_mutex_type &get_pu_mutex(std::size_t num_thread)
std::size_t domain_from_local_thread_index(std::size_t n)
std::size_t num_domains(const std::size_t workers)
std::vector<std::size_t> domain_threads(std::size_t local_id, const std::vector<std::size_t> &ts, hpx::function<bool(std::size_t, std::size_t)> pred)
virtual std::int64_t get_queue_length(std::size_t num_thread = std::size_t(-1)) const = 0
virtual std::int64_t get_thread_count(thread_schedule_state state = thread_schedule_state::unknown, thread_priority priority = thread_priority::default_, std::size_t num_thread = std::size_t(-1), bool reset = false) const = 0
virtual bool is_core_idle(std::size_t num_thread) const = 0
std::int64_t get_background_thread_count()
void increment_background_thread_count()
void decrement_background_thread_count()
virtual bool enumerate_threads(hpx::function<bool(thread_id_type)> const &f, thread_schedule_state state = thread_schedule_state::unknown, ) const = 0
virtual void abort_all_suspended_threads() = 0
virtual bool cleanup_terminated(bool delete_all) = 0
virtual bool cleanup_terminated(std::size_t num_thread, bool delete_all) = 0
virtual void create_thread(thread_init_data &data, thread_id_ref_type *id, error_code &ec) = 0
virtual bool get_next_thread(std::size_t num_thread, bool running, threads::thread_id_ref_type &thrd, bool enable_stealing) = 0
virtual void schedule_thread(threads::thread_id_ref_type thrd, threads::thread_schedule_hint schedulehint, bool allow_fallback = false, thread_priority priority = thread_priority::normal) = 0
virtual void schedule_thread_last(threads::thread_id_ref_type thrd, threads::thread_schedule_hint schedulehint, bool allow_fallback = false, thread_priority priority = thread_priority::normal) = 0
virtual void destroy_thread(threads::thread_data *thrd) = 0
virtual bool wait_or_add_new(std::size_t num_thread, bool running, std::int64_t &idle_loop_count, bool enable_stealing, std::size_t &added) = 0
virtual void on_start_thread(std::size_t num_thread) = 0
virtual void on_stop_thread(std::size_t num_thread) = 0
virtual void on_error(std::size_t num_thread, std::exception_ptr const &e) = 0
virtual void reset_thread_distribution()
std::ptrdiff_t get_stack_size(threads::thread_stacksize stacksize) const
void set_mpi_polling_functions(polling_function_ptr mpi_func, polling_work_count_function_ptr mpi_work_count_func)
void clear_mpi_polling_function()
void set_cuda_polling_functions(polling_function_ptr cuda_func, polling_work_count_function_ptr cuda_work_count_func)
void clear_cuda_polling_function()
detail::polling_status custom_polling_function() const
std::size_t get_polling_work_count() const

Public Static Functions

static detail::polling_status null_polling_function()
static std::size_t null_polling_work_count_function()

Protected Attributes

util::cache_line_data<std::atomic<scheduler_mode>> mode_
std::vector<pu_mutex_type> suspend_mtxs_
std::vector<std::condition_variable> suspend_conds_
std::vector<pu_mutex_type> pu_mtxs_
std::vector<std::atomic<hpx::state>> states_
char const *description_
thread_queue_init_parameters thread_queue_init_
threads::thread_pool_base *parent_pool_
std::atomic<std::int64_t> background_thread_count_
std::atomic<polling_function_ptr> polling_function_mpi_
std::atomic<polling_function_ptr> polling_function_cuda_
std::atomic<polling_work_count_function_ptr> polling_work_count_function_mpi_
std::atomic<polling_work_count_function_ptr> polling_work_count_function_cuda_