Skip to content
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

Expose more configuration options as environment variables #1380

Merged
merged 7 commits into from
Jan 10, 2025
2 changes: 1 addition & 1 deletion .gitlab/scripts/run_performance_benchmarks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pika_targets=(
)
pika_test_options=(
"--pika:ini=pika.thread_queue.init_threads_count=100 \
--pika:queuing=local-priority \
--pika:scheduler=local-priority \
--repetitions=100 \
--tasks=500000"

Expand Down
2 changes: 1 addition & 1 deletion .jenkins/cscs-perftests/launch_perftests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -ex
pika_targets=("task_overhead_report_test")
pika_test_options=(
"--pika:ini=pika.thread_queue.init_threads_count=100 \
--pika:queuing=local-priority --pika:threads=4 \
--pika:scheduler=local-priority --pika:threads=4 \
--repetitions=100 --tasks=500000")

# Build binaries for performance tests
Expand Down
8 changes: 7 additions & 1 deletion cmake/pika_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ function(pika_add_test category name)
elseif(${name}_THREADS EQUAL -2)
set(${name}_THREADS "cores")
set(run_serial TRUE)
elseif(${name}_THREADS EQUAL -3)
set(${name}_THREADS "default")
set(run_serial TRUE)
endif()
endif()
msimberg marked this conversation as resolved.
Show resolved Hide resolved

set(args "--pika:threads=${${name}_THREADS}")
set(args)
if(NOT ${name}_THREADS STREQUAL "default")
set(args ${args} "--pika:threads=${${name}_THREADS}")
endif()
if(PIKA_WITH_TESTS_DEBUG_LOG)
set(args ${args} "--pika:log-destination=${PIKA_WITH_TESTS_DEBUG_LOG_DESTINATION}")
set(args ${args} "--pika:log-level=0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace pika::detail {
std::size_t num_cores_;
std::size_t pu_step_;
std::size_t pu_offset_;
std::string queuing_;
std::string scheduler_;
std::string affinity_domain_;
std::string affinity_bind_;
std::size_t numa_sensitive_;
Expand Down
43 changes: 24 additions & 19 deletions libs/pika/command_line_handling/src/command_line_handling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace pika::detail {
std::ostringstream strm;

// default scheduler used for this run
strm << " {scheduler}: " << cfg.queuing_ << "\n";
strm << " {scheduler}: " << cfg.scheduler_ << "\n";

// amount of threads and cores configured for this run
strm << " {os-threads}: " << cfg.num_threads_ << "\n";
Expand Down Expand Up @@ -101,12 +101,9 @@ namespace pika::detail {

///////////////////////////////////////////////////////////////////////
std::string handle_process_mask(detail::manage_config& cfgmap,
pika::program_options::variables_map& vm, bool use_process_mask)
pika::program_options::variables_map& vm, std::string default_, bool use_process_mask)
{
std::string mask_string = cfgmap.get_value<std::string>("pika.process_mask", "");

char const* mask_env = std::getenv("PIKA_PROCESS_MASK");
if (nullptr != mask_env) { mask_string = mask_env; }
std::string mask_string = cfgmap.get_value<std::string>("pika.process_mask", default_);

if (vm.count("pika:process-mask"))
{
Expand Down Expand Up @@ -135,11 +132,11 @@ namespace pika::detail {
return mask_string;
}

std::string handle_queuing(detail::manage_config& cfgmap,
std::string handle_scheduler(detail::manage_config& cfgmap,
pika::program_options::variables_map& vm, std::string const& default_)
{
// command line options is used preferred
if (vm.count("pika:queuing")) return vm["pika:queuing"].as<std::string>();
if (vm.count("pika:scheduler")) return vm["pika:scheduler"].as<std::string>();

// use either cfgmap value or default
return cfgmap.get_value<std::string>("pika.scheduler", default_);
Expand Down Expand Up @@ -439,13 +436,15 @@ namespace pika::detail {
#if defined(__APPLE__)
false;
#else
!((cfgmap.get_value<int>("pika.ignore_process_mask", 0) > 0) ||
!((cfgmap.get_value<int>("pika.ignore_process_mask",
pika::detail::get_entry_as<int>(rtcfg_, "pika.ignore_process_mask", 0)) > 0) ||
(vm.count("pika:ignore-process-mask") > 0));
#endif

ini_config.emplace_back("pika.ignore_process_mask!=" + std::to_string(!use_process_mask_));

process_mask_ = handle_process_mask(cfgmap, vm, use_process_mask_);
process_mask_ = handle_process_mask(
cfgmap, vm, rtcfg_.get_entry("pika.process_mask", ""), use_process_mask_);
ini_config.emplace_back("pika.process_mask!=" + process_mask_);
if (!process_mask_.empty())
{
Expand All @@ -454,15 +453,18 @@ namespace pika::detail {
}

// handle setting related to schedulers
queuing_ = detail::handle_queuing(cfgmap, vm, "local-priority-fifo");
ini_config.emplace_back("pika.scheduler=" + queuing_);
scheduler_ = detail::handle_scheduler(
cfgmap, vm, rtcfg_.get_entry("pika.scheduler", "local-priority-fifo"));
ini_config.emplace_back("pika.scheduler=" + scheduler_);

affinity_domain_ = detail::handle_affinity(cfgmap, vm, "pu");
affinity_domain_ =
detail::handle_affinity(cfgmap, vm, rtcfg_.get_entry("pika.affinity", "pu"));
ini_config.emplace_back("pika.affinity=" + affinity_domain_);

check_affinity_domain();

affinity_bind_ = detail::handle_affinity_bind(cfgmap, vm, "");
affinity_bind_ =
detail::handle_affinity_bind(cfgmap, vm, rtcfg_.get_entry("pika.bind", ""));
if (!affinity_bind_.empty())
{
#if defined(__APPLE__)
Expand All @@ -479,7 +481,8 @@ namespace pika::detail {
#endif
}

pu_step_ = detail::handle_pu_step(cfgmap, vm, 1);
pu_step_ = detail::handle_pu_step(
cfgmap, vm, pika::detail::get_entry_as<std::size_t>(rtcfg_, "pika.pu_step", 1));
#if defined(__APPLE__)
if (pu_step_ != 1)
{
Expand All @@ -494,7 +497,8 @@ namespace pika::detail {

check_pu_step();

pu_offset_ = detail::handle_pu_offset(cfgmap, vm, std::size_t(-1));
pu_offset_ = detail::handle_pu_offset(cfgmap, vm,
pika::detail::get_entry_as<std::size_t>(rtcfg_, "pika.pu_offset", std::size_t(-1)));

// NOLINTNEXTLINE(bugprone-branch-clone)
if (pu_offset_ != std::size_t(-1))
Expand All @@ -514,7 +518,8 @@ namespace pika::detail {

check_pu_offset();

numa_sensitive_ = detail::handle_numa_sensitive(cfgmap, vm, affinity_bind_.empty() ? 0 : 1);
numa_sensitive_ = detail::handle_numa_sensitive(
cfgmap, vm, pika::detail::get_entry_as<std::size_t>(rtcfg_, "pika.numa_sensitive", 0));
ini_config.emplace_back("pika.numa_sensitive=" + std::to_string(numa_sensitive_));

// default affinity mode is now 'balanced' (only if no pu-step or
Expand Down Expand Up @@ -552,11 +557,11 @@ namespace pika::detail {
"(--pika:threads)");
}

if (!(queuing_ == "local-priority" || queuing_ == "abp-priority"))
if (!(scheduler_ == "local-priority" || scheduler_ == "abp-priority"))
{
throw pika::detail::command_line_error(
"Invalid command line option --pika:high-priority-threads, valid for "
"--pika:queuing=local-priority and --pika:queuing=abp-priority only");
"--pika:scheduler=local-priority and --pika:scheduler=abp-priority only");
}

ini_config.emplace_back("pika.thread_queue.high_priority_queues!=" +
Expand Down
24 changes: 12 additions & 12 deletions libs/pika/command_line_handling/src/parse_command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,21 @@ namespace pika::detail {
("pika:pu-offset", value<std::size_t>(),
"the first processing unit this instance of pika should be "
"run on (default: 0), valid for "
"--pika:queuing=local, --pika:queuing=abp-priority, "
"--pika:queuing=static, --pika:queuing=static-priority, "
"and --pika:queuing=local-priority only")
"--pika:scheduler=local, --pika:scheduler=abp-priority, "
"--pika:scheduler=static, --pika:scheduler=static-priority, "
"and --pika:scheduler=local-priority only")
("pika:pu-step", value<std::size_t>(),
"the step between used processing unit numbers for this "
"instance of pika (default: 1), valid for "
"--pika:queuing=local, --pika:queuing=abp-priority, "
"--pika:queuing=static, --pika:queuing=static-priority "
"and --pika:queuing=local-priority only")
"--pika:scheduler=local, --pika:scheduler=abp-priority, "
"--pika:scheduler=static, --pika:scheduler=static-priority "
"and --pika:scheduler=local-priority only")
("pika:affinity", value<std::string>(),
"the affinity domain the OS threads will be confined to, "
"possible values: pu, core, numa, machine (default: pu), valid for "
"--pika:queuing=local, --pika:queuing=abp-priority, "
"--pika:queuing=static, --pika:queuing=static-priority "
" and --pika:queuing=local-priority only")
"--pika:scheduler=local, --pika:scheduler=abp-priority, "
"--pika:scheduler=static, --pika:scheduler=static-priority "
" and --pika:scheduler=local-priority only")
("pika:bind", value<std::vector<std::string> >()->composing(),
"the detailed affinity description for the OS threads, see "
"the documentation for a detailed description of possible "
Expand All @@ -322,7 +322,7 @@ namespace pika::detail {
"the number of cores to utilize for the pika "
"runtime (default: 'all', i.e. the number of cores is based on "
"the number of total cores in the system)")
("pika:queuing", value<std::string>(),
("pika:scheduler", value<std::string>(),
"the queue scheduling policy to use, options are "
"'local', 'local-priority-fifo','local-priority-lifo', "
"'abp-priority-fifo', 'abp-priority-lifo', 'static', and "
Expand All @@ -331,8 +331,8 @@ namespace pika::detail {
("pika:high-priority-threads", value<std::size_t>(),
"the number of operating system threads maintaining a high "
"priority queue (default: number of OS threads), valid for "
"--pika:queuing=local-priority,--pika:queuing=static-priority, "
" and --pika:queuing=abp-priority only)")
"--pika:scheduler=local-priority,--pika:scheduler=static-priority, "
" and --pika:scheduler=abp-priority only)")
("pika:numa-sensitive", value<std::size_t>()->implicit_value(0),
"makes the local-priority scheduler NUMA sensitive ("
"allowed values: 0 - no NUMA sensitivity, 1 - allow only for "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void init_resource_partitioner_handler(
if (pool_threads > 0)
{
// we use unspecified as the scheduler type and it will be set according to
// the --pika:queuing=xxx option or default.
// the --pika:scheduler=xxx option or default.
auto deft = ::pika::threads::scheduler_mode::default_mode;
rp.create_thread_pool(pool_name, pika::resource::scheduling_policy::shared_priority, deft);
// add N pus to network pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void init_resource_partitioner_handler(
if (pool_threads > 0)
{
// we use unspecified as the scheduler type and it will be set according to
// the --pika:queuing=xxx option or default.
// the --pika:scheduler=xxx option or default.
auto deft = ::pika::threads::scheduler_mode::default_mode;
rp.create_thread_pool(pool_name, pika::resource::scheduling_policy::shared_priority, deft);
// add N pus to network pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ namespace pika::resource::detail {
else
{
throw pika::detail::command_line_error(
"Bad value for command line option --pika:queuing");
"Bad value for command line option --pika:scheduler");
}

// set this scheduler on the pools that do not have a specified scheduler yet
Expand Down
Loading
Loading