SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smaug::SmvAcceleratorPool Class Reference

Implements a pool of worker accelerators. More...

#include <smv_accel_pool.h>

Detailed Description

Implements a pool of worker accelerators.

For operators that require work tiling, tiles can be distributed across multiple accelerators to exploit parallelism. This class implements a deterministic round-robin worker pool. Determinism is required because when generating multiple dynamic traces, worker accelerator assignments must match with simulation of the binary in gem5.

To use:

SmvAcceleratorPool pool(size);
int currAccel = 0;
for (int i = 0; i < tiles; i++) {
volatile int* finishFlag = invokeKernelNoBlock(currAccel, redCode, kernel, args...);
pool.addFinishFlag(currAccel, std::make_unique(finishFlag));
currAccel = pool.getNextAvailableAccelerator(currAccel);
}
pool.joinAll();

Definition at line 32 of file smv_accel_pool.h.

Public Member Functions

 SmvAcceleratorPool (int _size)
 
void addFinishFlag (int accelIdx, std::unique_ptr< volatile int > finishFlag)
 Add a finish flag for the specified accelerator.
 
void joinAll ()
 Wait until all the finish flags turn complete.
 
int getNextAvailableAccelerator (int currAccelIdx)
 Get the next accelerator and wait if it's still busy. More...
 

Protected Member Functions

void join (int accelIdx)
 Wait until this accelerator's finish flags turn complete.
 

Protected Attributes

int size
 Number of accelerators in the pool.
 
std::vector< std::deque< std::unique_ptr< volatile int > > > finishFlags
 Active finish flags for all the accelerators in the pool.
 

Member Function Documentation

◆ getNextAvailableAccelerator()

int smaug::SmvAcceleratorPool::getNextAvailableAccelerator ( int  currAccelIdx)

Get the next accelerator and wait if it's still busy.

A round-robin scheduling policy is used for picking the accelerator. The simple static policy is used because the scheduling decisions need to be the same as when we generate the traces, whereas dynamic decisions that depend on runtime information may lead to mismatch between the traces and the simulation.

TODO(xyzsam): the pool should be able to keep track of the current accelerator index on its own.

Definition at line 39 of file smv_accel_pool.cpp.


The documentation for this class was generated from the following files:
smaug::SmvAcceleratorPool::size
int size
Number of accelerators in the pool.
Definition: smv_accel_pool.h:60
smaug::invokeKernelNoBlock
std::unique_ptr< volatile int > invokeKernelNoBlock(int accelIdx, unsigned reqCode, const Kernel &kernel, Args &&... args)
A generic non-blocking interface to accelerated kernel functions.
Definition: common.h:106