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

Merge branch 'callerenv' into 'master'

[LawsScheduler] Guard Runtime::getWorkerId() with CallerEnvironment

See merge request !192
parents 84fbd959 1c16998a
No related branches found
No related tags found
1 merge request!192[LawsScheduler] Guard Runtime::getWorkerId() with CallerEnvironment
Pipeline #61987 passed
......@@ -22,34 +22,40 @@ LawsScheduler::LawsScheduler(Runtime& runtime) : AbstractWorkStealingScheduler(r
addNewWorkerHook(newWorkerHook);
}
template <CallerEnvironment callerEnvironment>
void LawsScheduler::tryScheduleToPriorityQueue(Fiber& fiber) {
workeraffinity_t* const affinity_buffer = getAffinityBuffer(fiber);
if (affinity_buffer) {
workeraffinity_t affinity = *affinity_buffer;
if (!affinity_buffer) {
return;
}
workeraffinity_t affinity = *affinity_buffer;
if constexpr (callerEnvironment == CallerEnvironment::EMPER) {
workerid_t workerId = Runtime::getWorkerId();
if (affinity == workerId) {
return;
}
}
if (affinity == Fiber::NOT_AFFINE) {
return;
}
if (affinity == Fiber::NOT_AFFINE) {
return;
}
// We found a fiber to schedule on a remote prority queue.
increaseRefCount(fiber);
priorityQueues[affinity]->enqueue(&fiber);
// We found a fiber to schedule on a remote prority queue.
increaseRefCount(fiber);
priorityQueues[affinity]->enqueue(&fiber);
emper::statsIncr(LawsStrategy::stats.scheduledFibersToPriority);
}
emper::statsIncr(LawsStrategy::stats.scheduledFibersToPriority);
}
void LawsScheduler::scheduleInternal(Fiber& fiber) {
tryScheduleToPriorityQueue(fiber);
tryScheduleToPriorityQueue<CallerEnvironment::EMPER>(fiber);
scheduleViaWorkStealing(fiber);
}
void LawsScheduler::scheduleFromAnywhereInternal(Fiber& fiber) {
tryScheduleToPriorityQueue(fiber);
tryScheduleToPriorityQueue<CallerEnvironment::ANYWHERE>(fiber);
enqueueInAnywhereQueue(fiber);
onNewWork<CallerEnvironment::ANYWHERE>();
}
......@@ -57,7 +63,7 @@ void LawsScheduler::scheduleFromAnywhereInternal(Fiber& fiber) {
void LawsScheduler::scheduleFromAnywhereInternal(Fiber** fibers, unsigned count) {
for (unsigned i = 0; i < count; ++i) {
Fiber& fiber = *fibers[i];
tryScheduleToPriorityQueue(fiber);
tryScheduleToPriorityQueue<CallerEnvironment::ANYWHERE>(fiber);
}
insertInAnywhereQueue(fibers, count);
onNewWork<CallerEnvironment::ANYWHERE>();
......
......@@ -2,6 +2,7 @@
// Copyright © 2020-2021 Florian Schmaus
#pragma once
#include "CallerEnvironment.hpp"
#include "Fiber.hpp"
#include "lib/adt/MpscQueue.hpp"
#include "strategies/AbstractWorkStealingScheduler.hpp"
......@@ -17,6 +18,7 @@ class LawsScheduler : public AbstractWorkStealingScheduler {
static thread_local LawsMpscQueue priorityQueue;
template <CallerEnvironment callerEnvironment>
void tryScheduleToPriorityQueue(Fiber& fiber);
protected:
......
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