index a289507d4b050a9d9418b8424de26397e16b7f87..d1aa6dc7a5d403538e5cdbbedb9f5ae135847d48 100644 (file)
bool Run(int num_eve,int num_dsp, const char* ref_output);
-Executor* CreateExecutor(DeviceType dt, int num, const Configuration& c,
- int layer_group_id);
-
-void AllocateMemory(const vector<EOP *>& EOPs);
-void FreeMemory (const vector<EOP *>& EOPs);
-
-
int main(int argc, char *argv[])
{
// Catch ctrl-c to ensure a clean exit
c.PARAM_HEAP_SIZE = (3 << 20); // 3MB
c.NETWORK_HEAP_SIZE = (20 << 20); // 20MB
+ // Run this example for 16 input frames
c.numFrames = 16;
- // Assign layers 12, 13 and 14 to layer group 2
- c.layerIndex2LayerGroupId = { {12, 2}, {13, 2}, {14, 2} };
+ // Assign layers 12, 13 and 14 to the DSP layer group
+ const int EVE_LG = 1;
+ const int DSP_LG = 2;
+ c.layerIndex2LayerGroupId = { {12, DSP_LG}, {13, DSP_LG}, {14, DSP_LG} };
// Open input file for reading
std::ifstream input(c.inData, std::ios::binary);
try
{
// Create Executors - use all the DSP and EVE cores available
- // Layer group 1 will be executed on EVE, 2 on DSP
- unique_ptr<Executor> eve(CreateExecutor(DeviceType::EVE,num_eve,c,1));
- unique_ptr<Executor> dsp(CreateExecutor(DeviceType::DSP,num_dsp,c,2));
+ // Specify layer group id for each Executor
+ unique_ptr<Executor> eve(CreateExecutor(DeviceType::EVE,
+ num_eve, c, EVE_LG));
+ unique_ptr<Executor> dsp(CreateExecutor(DeviceType::DSP,
+ num_dsp, c, DSP_LG));
// Create pipelines. Each pipeline has 1 EVE and 1 DSP. If there are
// more EVEs than DSPs, the DSPs are shared across multiple
{
EOP* eop = EOPs[frame_idx % num_eops];
- // Wait for previous frame on the same eo to finish processing
+ // Wait for previous frame on the same EOP to finish processing
if (eop->ProcessFrameWait())
{
- ReportTime(eop);
-
// The reference output is valid only for the first frame
// processed on each EOP
if (frame_idx < num_eops && !CheckFrame(eop, ref_output))
return status;
}
-// Create an Executor with the specified type and number of EOs
-Executor* CreateExecutor(DeviceType dt, int num, const Configuration& c,
- int layer_group_id)
-{
- if (num == 0) return nullptr;
-
- DeviceIds ids;
- for (int i = 0; i < num; i++)
- ids.insert(static_cast<DeviceId>(i));
-
- return new Executor(dt, ids, c, layer_group_id);
-}
-
-// Allocate input and output memory for each EO
-void AllocateMemory(const vector<EOP *>& EOPs)
-{
- // Allocate input and output buffers for each execution object
- for (auto eop : EOPs)
- {
- size_t in_size = eop->GetInputBufferSizeInBytes();
- size_t out_size = eop->GetOutputBufferSizeInBytes();
- ArgInfo in = { ArgInfo(malloc(in_size), in_size)};
- ArgInfo out = { ArgInfo(malloc(out_size), out_size)};
- eop->SetInputOutputBuffer(in, out);
- }
-}
-// Free the input and output memory associated with each EO
-void FreeMemory(const vector<EOP *>& EOPs)
-{
- for (auto eop : EOPs)
- {
- free(eop->GetInputBufferPtr());
- free(eop->GetOutputBufferPtr());
- }
-
-}