4 #include "smaug/operators/smv/smv_accel_pool.h"
5 #include "smaug/utility/debug_stream.h"
9 SmvAcceleratorPool::SmvAcceleratorPool(
int _size)
10 : size(_size), finishFlags(_size) {}
12 void SmvAcceleratorPool::addFinishFlag(
13 int accelIdx, std::unique_ptr<volatile int> finishFlag) {
15 finishFlags[accelIdx].push_back(std::move(finishFlag));
19 void SmvAcceleratorPool::join(
int accelIdx) {
20 if (finishFlags[accelIdx].empty())
23 while (!finishFlags[accelIdx].empty()) {
24 std::unique_ptr<volatile int> finishFlag =
25 std::move(finishFlags[accelIdx].front());
26 waitForAccelerator(finishFlag.get());
27 finishFlags[accelIdx].pop_front();
29 dout(1) <<
"Accelerator " << accelIdx <<
" finished.\n";
32 void SmvAcceleratorPool::joinAll() {
33 dout(1) <<
"Waiting for all accelerators to finish.\n";
34 for (
int i = 0; i < size; i++)
36 dout(1) <<
"All accelerators finished.\n";
39 int SmvAcceleratorPool::getNextAvailableAccelerator(
int currAccelIdx) {
41 int pickedAccel = currAccelIdx + 1;
42 if (pickedAccel == size)
47 dout(1) <<
"Switched to accelerator " << pickedAccel <<
".\n";