Skip to content

Commit

Permalink
Add Scheduler TImers (#109)
Browse files Browse the repository at this point in the history
* Add schedule timing counters

* Updates to loadbalance benchmark

* doAll counters
  • Loading branch information
AdityaAtulTewari authored May 30, 2024
1 parent f7558a3 commit de5af5c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
27 changes: 16 additions & 11 deletions examples/benchmark_loadbalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,25 @@ int pandoMain(int argc, char** argv) {
if (numItemsPerChunk != 1) {
printUsageExit(argv[0]);
}
Arr<G<std::uint64_t>> arr;
Arr<std::uint64_t> arr;
PANDO_CHECK(arr.initialize(galois::getNumThreads()));
G<std::uint64_t> hello;
pando::LocalStorageGuard<std::uint64_t> helloGuard(hello, 1);
*hello = 0;
for (Ref<G<std::uint64_t>> item : arr) {
item = hello;
}
galois::doAll(
arr, +[](G<std::uint64_t> hello) {
pando::atomicFetchAdd(hello, 1, std::memory_order_relaxed);
while (pando::atomicLoad(hello, std::memory_order_relaxed) != galois::getNumThreads()) {}
galois::WaitGroup wg;
PANDO_CHECK(wg.initialize(0));
auto wgh = wg.getHandle();
counter::HighResolutionCount<true> makeSpanCounter;
makeSpanCounter.start();
galois::doAllEvenlyPartition(
wgh, arr, arr.size(),
+[](Arr<std::uint64_t> arr, std::uint64_t i, std::uint64_t numThreads) {
UNUSED(arr);
UNUSED(i);
UNUSED(numThreads);
});
PANDO_CHECK(wg.wait());
auto time = makeSpanCounter.stop();
arr.deinitialize();
wg.deinitialize();
std::cout << "The makespan of one task per thread was " << time.count() << std::endl;
}
pando::waitAll();
return 0;
Expand Down
15 changes: 15 additions & 0 deletions include/pando-lib-galois/loops/do_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#include <pando-rt/pando-rt.hpp>

constexpr bool SCHEDULER_TIMER_ENABLE = false;
constexpr bool DOALL_TIMER_ENABLE = false;

extern counter::Record<std::minstd_rand> perCoreRNG;
extern counter::Record<std::uniform_int_distribution<std::int8_t>> perCoreDist;
extern counter::Record<std::int64_t> schedulerCount;
extern counter::Record<std::int64_t> doAllCount;

namespace galois {

Expand Down Expand Up @@ -176,6 +178,8 @@ class DoAll {
template <typename State, typename R, typename F, typename L>
static pando::Status doAll(WaitGroup::HandleType wgh, State s, R& range, const F& func,
const L& localityFunc) {
counter::HighResolutionCount<DOALL_TIMER_ENABLE> doAllTimer;
doAllTimer.start();
LoopLocalSchedulerStruct<CURRENT_SCHEDULER_POLICY> loopLocal{};
pando::Status err = pando::Status::Success;

Expand All @@ -198,6 +202,7 @@ class DoAll {
}
iter++;
}
counter::recordHighResolutionEvent(doAllCount, doAllTimer);
return err;
}

Expand All @@ -216,6 +221,8 @@ class DoAll {
*/
template <typename State, typename R, typename F>
static pando::Status doAll(WaitGroup::HandleType wgh, State s, R& range, const F& func) {
counter::HighResolutionCount<DOALL_TIMER_ENABLE> doAllTimer;
doAllTimer.start();
LoopLocalSchedulerStruct<CURRENT_SCHEDULER_POLICY> loopLocal{};
pando::Status err = pando::Status::Success;

Expand All @@ -238,6 +245,7 @@ class DoAll {
}
iter++;
}
counter::recordHighResolutionEvent(doAllCount, doAllTimer);
return err;
}

Expand All @@ -256,6 +264,8 @@ class DoAll {
*/
template <typename R, typename F>
static pando::Status doAll(WaitGroup::HandleType wgh, R& range, const F& func) {
counter::HighResolutionCount<DOALL_TIMER_ENABLE> doAllTimer;
doAllTimer.start();
LoopLocalSchedulerStruct<CURRENT_SCHEDULER_POLICY> loopLocal{};
pando::Status err = pando::Status::Success;

Expand All @@ -277,6 +287,7 @@ class DoAll {
}
iter++;
}
counter::recordHighResolutionEvent(doAllCount, doAllTimer);
return err;
}

Expand Down Expand Up @@ -370,9 +381,12 @@ class DoAll {
template <typename State, typename F>
static pando::Status doAllEvenlyPartition(WaitGroup::HandleType wgh, State s, uint64_t workItems,
const F& func) {
counter::HighResolutionCount<DOALL_TIMER_ENABLE> doAllTimer;
doAllTimer.start();
LoopLocalSchedulerStruct<EVENLY_PARITION_SCHEDULER_POLICY> loopLocal;
pando::Status err = pando::Status::Success;
if (workItems == 0) {
counter::recordHighResolutionEvent(doAllCount, doAllTimer);
return err;
}

Expand Down Expand Up @@ -407,6 +421,7 @@ class DoAll {
return err;
}
}
counter::recordHighResolutionEvent(doAllCount, doAllTimer);
return err;
}

Expand Down
5 changes: 5 additions & 0 deletions pando-rt/src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
counter::Record<std::minstd_rand> perCoreRNG;
counter::Record<std::uniform_int_distribution<std::int8_t>> perCoreDist;
counter::Record<std::int64_t> schedulerCount = counter::Record<std::int64_t>();
counter::Record<std::int64_t> doAllCount = counter::Record<std::int64_t>();

namespace pando {

Expand Down Expand Up @@ -216,6 +217,10 @@ int main(int argc, char* argv[]) {
thisPlace.node.id,
std::int8_t((i == std::uint64_t(dims.core.x + 1)) ? -1 : i),
schedulerCount.get(i));
SPDLOG_WARN("DoAll time on node: {}, core: {} was {}",
thisPlace.node.id,
std::int8_t((i == std::uint64_t(dims.core.x + 1)) ? -1 : i),
doAllCount.get(i));
}


Expand Down

0 comments on commit de5af5c

Please sign in to comment.