From d4805c12df508ead89b8b2c8fdb20ae3adb86eee Mon Sep 17 00:00:00 2001 From: sant0s12 Date: Thu, 13 Jun 2024 16:39:16 +0200 Subject: [PATCH] [software] Simplify omp dynamic schedule --- software/runtime/kmp/team.hpp | 36 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/software/runtime/kmp/team.hpp b/software/runtime/kmp/team.hpp index 1e86c6c19..71582b68f 100644 --- a/software/runtime/kmp/team.hpp +++ b/software/runtime/kmp/team.hpp @@ -12,7 +12,6 @@ #include #include #include -#include namespace kmp { @@ -22,16 +21,12 @@ class Barrier; class Team { - template ::type, - typename UnsignedT = typename std::make_unsigned::type> struct DynamicSchedule { - DynamicSchedule() {} - - T lowerNext = 0; - T upper = 0; - SignedT chunk = 0; - SignedT incr = 0; - SignedT stride = 0; + kmp_uint32 lowerNext = 0; + kmp_uint32 upper = 0; + kmp_uint32 chunk = 0; // Chunk size assumed to be positive + kmp_int32 incr = 0; + kmp_int32 stride = 0; bool valid = false; kmp_uint32 numDone = 0; @@ -150,7 +145,7 @@ class Team { DEBUG_PRINT("Dispatch init\n"); - auto &dynamicSchedule = std::get>(this->dynamicSchedule); + DEBUG_PRINT("Got dynamic schedule\n"); switch (schedtype) { case kmp_sch_dynamic_chunked: { @@ -163,9 +158,9 @@ class Team { SignedT span = incr * chunk; - dynamicSchedule.lowerNext = lower; - dynamicSchedule.upper = upper; - dynamicSchedule.chunk = chunk; + dynamicSchedule.lowerNext = static_cast(lower); + dynamicSchedule.upper = static_cast(upper); + dynamicSchedule.chunk = static_cast(chunk); dynamicSchedule.incr = incr; dynamicSchedule.stride = span * static_cast(numThreads); @@ -193,8 +188,6 @@ class Team { DEBUG_PRINT("Dispatch next\n"); - auto &dynamicSchedule = std::get>(this->dynamicSchedule); - std::lock_guard lock(dynamicSchedule.mutex); assert(dynamicSchedule.valid && "Dynamic schedule is not valid"); @@ -208,14 +201,14 @@ class Team { return false; } - *plower = dynamicSchedule.lowerNext; + *plower = static_cast(dynamicSchedule.lowerNext); - dynamicSchedule.lowerNext += static_cast(dynamicSchedule.chunk); + dynamicSchedule.lowerNext += dynamicSchedule.chunk; if (dynamicSchedule.lowerNext > dynamicSchedule.upper) { - *pupper = dynamicSchedule.upper; + *pupper = static_cast(dynamicSchedule.upper); *plastiter = true; } else { - *pupper = dynamicSchedule.lowerNext - 1; + *pupper = static_cast(dynamicSchedule.lowerNext - 1); *plastiter = false; } @@ -231,8 +224,7 @@ class Team { Barrier barrier; - std::variant, DynamicSchedule> - dynamicSchedule; + DynamicSchedule dynamicSchedule; void *copyPrivateData = nullptr;