X-Git-Url: https://git.ti.com/gitweb?p=tidl%2Ftidl-api.git;a=blobdiff_plain;f=examples%2Ftwo_eo_per_frame%2Fmain.cpp;h=d1aa6dc7a5d403538e5cdbbedb9f5ae135847d48;hp=a289507d4b050a9d9418b8424de26397e16b7f87;hb=58664e9e96684e54db9553f5e41b1b8d5fbc9bb5;hpb=6b03a3b668a0d0c299b886ba3802b850bc674ebf diff --git a/examples/two_eo_per_frame/main.cpp b/examples/two_eo_per_frame/main.cpp index a289507..d1aa6dc 100644 --- a/examples/two_eo_per_frame/main.cpp +++ b/examples/two_eo_per_frame/main.cpp @@ -51,13 +51,6 @@ using EOP = tidl::ExecutionObjectPipeline; 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& EOPs); -void FreeMemory (const vector& EOPs); - - int main(int argc, char *argv[]) { // Catch ctrl-c to ensure a clean exit @@ -100,10 +93,13 @@ bool Run(int num_eve, int num_dsp, const char* ref_output) 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); @@ -112,9 +108,11 @@ bool Run(int num_eve, int num_dsp, const char* ref_output) try { // Create Executors - use all the DSP and EVE cores available - // Layer group 1 will be executed on EVE, 2 on DSP - unique_ptr eve(CreateExecutor(DeviceType::EVE,num_eve,c,1)); - unique_ptr dsp(CreateExecutor(DeviceType::DSP,num_dsp,c,2)); + // Specify layer group id for each Executor + unique_ptr eve(CreateExecutor(DeviceType::EVE, + num_eve, c, EVE_LG)); + unique_ptr 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 @@ -136,11 +134,9 @@ bool Run(int num_eve, int num_dsp, const char* ref_output) { 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)) @@ -166,40 +162,4 @@ bool Run(int num_eve, int num_dsp, const char* 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(i)); - - return new Executor(dt, ids, c, layer_group_id); -} - -// Allocate input and output memory for each EO -void AllocateMemory(const vector& 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& EOPs) -{ - for (auto eop : EOPs) - { - free(eop->GetInputBufferPtr()); - free(eop->GetOutputBufferPtr()); - } - -}