diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a0c3c63378db1aaddf28b97220cc635a8c985ba3..4b6bbfce0133ee2f9e0840649f761a38be03c0a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,6 +50,14 @@ variables: CC: clang CXX: clang++ +.emper-ws-scheduling: + variables: + EMPER_DEFAULT_SCHEDULING_STRATEGY: "work_stealing" + +.emper-laws-scheduling: + variables: + EMPER_DEFAULT_SCHEDULING_STRATEGY: "locality_aware_work_stealing" + .emper-worker-no-sleep: variables: EMPER_WORKER_SLEEP: 'false' @@ -157,3 +165,13 @@ test-clang-sanitizer-undefined: # - .test # - .clang # - .sanitizer-address + +test-laws: + extends: + - .test + - .emper-laws-scheduling + +test-laws-release: + extends: + - test-laws + - .release-build diff --git a/emper/Runtime.cpp b/emper/Runtime.cpp index 964cd248ea46f19c2f3c369dab521cb8dda2352c..5f8c2755c9cb11f94e5a0a3b621560810182b839 100644 --- a/emper/Runtime.cpp +++ b/emper/Runtime.cpp @@ -23,7 +23,14 @@ #include "RuntimeStrategyStats.hpp" // for RuntimeStrategyStats #include "emper-config.h" // IWYU pragma: keep #include "lib/DebugUtil.hpp" + +#ifdef EMPER_DEFAULT_SCHEDULING_STRATEGY_WORK_STEALING #include "strategies/ws/WsStrategy.hpp" // for WsStrategy, WsStrategy::INST... +#elif defined EMPER_DEFAULT_SCHEDULING_STRATEGY_LOCALITY_AWARE_WORK_STEALING +#include "strategies/laws/LawsStrategy.hpp" +#else +#error "Unknown default scheduling strategy" +#endif #ifdef EMPER_LIBURCU #include <urcu.h> // for rcu_register_thread @@ -38,7 +45,16 @@ std::mutex Runtime::currentRuntimeMutex; Runtime* Runtime::currentRuntime; -RuntimeStrategy& Runtime::DEFAULT_STRATEGY = WsStrategy::INSTANCE; + +RuntimeStrategy& Runtime::DEFAULT_STRATEGY = +#ifdef EMPER_DEFAULT_SCHEDULING_STRATEGY_WORK_STEALING + WsStrategy::INSTANCE +#elif defined EMPER_DEFAULT_SCHEDULING_STRATEGY_LOCALITY_AWARE_WORK_STEALING + LawsStrategy::INSTANCE +#else +#error "Unknown default scheduling strategy" +#endif + ; Runtime::Runtime(workerid_t workerCount, RuntimeStrategy& strategy, unsigned int seed) : workerCount(workerCount), diff --git a/meson.build b/meson.build index 171758036d0a285302bff33208ac97c19e1ed110..06b758c81de2729449ecd9d7d692df4d50d81348 100644 --- a/meson.build +++ b/meson.build @@ -31,6 +31,9 @@ conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue')) conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue')) conf_data.set('EMPER_STATS', get_option('stats')) +default_scheduling_strategy = get_option('default_scheduling_strategy') +conf_data.set('EMPER_DEFAULT_SCHEDULING_STRATEGY_' + default_scheduling_strategy.to_upper(), true) + log_level = get_option('log_level') if log_level == 'automatic' # output only error messages in release builds diff --git a/meson_options.txt b/meson_options.txt index 7f506e649b4d3f3b6c763fc6688cbc9ddf386bbb..1eb8a30428ebed0ea14dbb824a7fad1b52c09095 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -40,3 +40,12 @@ option( value: false, description: 'Collect stats and print them at the end of the execution' ) +option( + 'default_scheduling_strategy', + type: 'combo', + choices: [ + 'work_stealing', + 'locality_aware_work_stealing', + ], + value: 'work_stealing', +)