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

Merge branch 'cache-get-workerid' into 'master'

Re-use Runtime::getWorkerId() when possible

See merge request !44
parents fc1d42ef 1aa19dab
No related branches found
No related tags found
1 merge request!44Re-use Runtime::getWorkerId() when possible
Pipeline #53831 passed
...@@ -40,12 +40,13 @@ class MemoryManager { ...@@ -40,12 +40,13 @@ class MemoryManager {
if (likely(poped)) return memory; if (likely(poped)) return memory;
// Fallback to memory-stealing. // Fallback to memory-stealing.
const workerid_t myWorkerId = Runtime::getWorkerId();
const workerid_t startWorkerId = Runtime::rand() % workerCount; const workerid_t startWorkerId = Runtime::rand() % workerCount;
for (workerid_t i = 0; i < workerCount; ++i) { for (workerid_t i = 0; i < workerCount; ++i) {
workerid_t victim = (startWorkerId + i) % workerCount; workerid_t victim = (startWorkerId + i) % workerCount;
// Don't steal from ourselves. // Don't steal from ourselves.
if (unlikely(victim == Runtime::getWorkerId())) continue; if (unlikely(victim == myWorkerId)) continue;
poped = queues[victim]->popTop(&memory); poped = queues[victim]->popTop(&memory);
if (poped) return memory; if (poped) return memory;
......
...@@ -102,7 +102,7 @@ auto LawsScheduler::nextFiber() -> Fiber* { ...@@ -102,7 +102,7 @@ auto LawsScheduler::nextFiber() -> Fiber* {
poped = queues[victim]->popTop(&fiber); poped = queues[victim]->popTop(&fiber);
if (poped) { if (poped) {
if (emper::STATS) { if constexpr (emper::STATS) {
auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen); auto flag = static_cast<unsigned int>(LawsStrategy::FiberSource::stolen);
fiber->setFlag(flag); fiber->setFlag(flag);
} }
......
...@@ -54,6 +54,7 @@ auto WsScheduler::nextFiber() -> Fiber* { ...@@ -54,6 +54,7 @@ auto WsScheduler::nextFiber() -> Fiber* {
return fiber; return fiber;
} }
const workerid_t myWorkerId = Runtime::getWorkerId();
const workerid_t workerCount = runtime.getWorkerCount(); const workerid_t workerCount = runtime.getWorkerCount();
workerid_t startWorkerId = Runtime::rand() % workerCount; workerid_t startWorkerId = Runtime::rand() % workerCount;
// TODO: See how reducing the loop bound affects things. // TODO: See how reducing the loop bound affects things.
...@@ -61,7 +62,7 @@ auto WsScheduler::nextFiber() -> Fiber* { ...@@ -61,7 +62,7 @@ auto WsScheduler::nextFiber() -> Fiber* {
workerid_t victim = (startWorkerId + i) % workerCount; workerid_t victim = (startWorkerId + i) % workerCount;
// Don't steal from ourselves. // Don't steal from ourselves.
if (unlikely(victim == Runtime::getWorkerId())) continue; if (unlikely(victim == myWorkerId)) continue;
poped = queues[victim]->popTop(&fiber); poped = queues[victim]->popTop(&fiber);
if (poped) { if (poped) {
......
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