Skip to content
Snippets Groups Projects
Commit 3785a5d9 authored by Florian Schmaus's avatar Florian Schmaus
Browse files

Merge branch 'wakeup-strategy-enum' into 'master'

Worker wakeup strategy enum

See merge request !62
parents 4a5a37dd 7ab252ce
No related branches found
No related tags found
1 merge request!62Worker wakeup strategy enum
Pipeline #55592 failed
......@@ -105,6 +105,10 @@ variables:
variables:
BUILDTYPE: debug
.worker-wakeup-strategy-all:
variables:
EMPER_WORKER_WAKEUP_STRATEGY: "all"
test-gcc:
extends:
- .test
......@@ -175,3 +179,8 @@ test-laws-release:
extends:
- test-laws
- .release-build
test-worker-wakeup-strategy-all:
extends:
- .test
- .worker-wakeup-strategy-all
......@@ -23,14 +23,14 @@ static const bool WORKER_SLEEP =
false
#endif
;
enum class WorkerWakeupStrategy { one, all };
enum class WorkerWakeupStrategy {
one,
all,
};
static const enum WorkerWakeupStrategy WORKER_WAKEUP_STRATEGY =
#ifdef EMPER_WORKER_WAKEUP_ALL
WorkerWakeupStrategy::all
#else
WorkerWakeupStrategy::one
#endif
;
WorkerWakeupStrategy::EMPER_WORKER_WAKEUP_STRATEGY;
static const bool LIBURCU =
#ifdef EMPER_LIBURCU
......
......@@ -7,8 +7,8 @@
#include <atomic> // for atomic, memory_order_relaxed
#include <cassert> // for assert
#include <condition_variable> // for condition_variable
#include <cstddef> // for size_t
#include <cstdint> // for intptr_t
#include <cstdlib> // for abort
#include <functional> // for function
#include <mutex> // for mutex, lock_guard, unique_lock
#include <random>
......@@ -90,9 +90,12 @@ class Runtime : public Logger<LogSubsystem::RUNTI> {
if constexpr (emper::WORKER_WAKEUP_STRATEGY == emper::WorkerWakeupStrategy::all) {
sleepingWorkers.store(0, std::memory_order_relaxed);
workerSleepConditionVariable.notify_all();
} else {
} else if (emper::WORKER_WAKEUP_STRATEGY == emper::WorkerWakeupStrategy::one) {
sleepingWorkers.fetch_sub(1, std::memory_order_relaxed);
workerSleepConditionVariable.notify_one();
} else {
// Unknown worker wakeup strategy.
abort();
}
}
......
......@@ -11,11 +11,11 @@ class Worker {
private:
static thread_local Worker* currentWorker;
const workerid_t workerId;
ALIGN_TO_CACHE_LINE unsigned int seed;
Worker(workerid_t workerId, unsigned int seed) : workerId(workerId), seed(seed) {}
const workerid_t workerId;
Worker(workerid_t workerId, unsigned int seed) : seed(seed), workerId(workerId) {}
void setWorker();
......
......@@ -26,7 +26,7 @@ if option_urcu
endif
conf_data.set('EMPER_WORKER_SLEEP', get_option('worker_sleep'))
conf_data.set('EMPER_WORKER_WAKEUP_ALL', get_option('worker_wakeup_strategy') == 'all')
conf_data.set('EMPER_WORKER_WAKEUP_STRATEGY', get_option('worker_wakeup_strategy'))
conf_data.set('EMPER_LOCKED_WS_QUEUE', get_option('locked_ws_queue'))
conf_data.set('EMPER_OVERFLOW_QUEUE', get_option('overflow_queue'))
conf_data.set('EMPER_LOCKED_MPSC_QUEUE', get_option('locked_mpsc_queue'))
......
......@@ -19,7 +19,7 @@ option(
option(
'worker_wakeup_strategy',
type: 'combo',
description: 'How many workers should be signaled onNewWork',
description: 'The strategy used to wakeup sleeping workers (only effective if worker_sleep is enabled)',
choices: ['one', 'all'],
value: 'one',
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment