From 36786d7afca8c1906293854d1e6243bb961c712f Mon Sep 17 00:00:00 2001 From: Ajay Jayaraj Date: Mon, 13 Aug 2018 14:56:24 -0500 Subject: [PATCH 1/1] Modified IODeviceArgInfo to enable pipelining EOs (MCT-1030) --- tidl_api/inc/execution_object.h | 5 ++++ tidl_api/src/device_arginfo.h | 46 +++++++++++++++++++++++++++++++ tidl_api/src/execution_object.cpp | 42 ++++++++-------------------- 3 files changed, 62 insertions(+), 31 deletions(-) diff --git a/tidl_api/inc/execution_object.h b/tidl_api/inc/execution_object.h index ccc0881..e78ad2e 100644 --- a/tidl_api/inc/execution_object.h +++ b/tidl_api/inc/execution_object.h @@ -37,6 +37,7 @@ namespace tidl { class Kernel; class Device; class LayerOutput; +class IODeviceArgInfo; typedef std::vector> LayerOutputs; @@ -132,6 +133,10 @@ class ExecutionObject void EnableOutputBufferTrace(); + //! @private + void SetInputOutputBuffer(const IODeviceArgInfo* in, + const IODeviceArgInfo* out); + private: class Impl; std::unique_ptr pimpl_m; diff --git a/tidl_api/src/device_arginfo.h b/tidl_api/src/device_arginfo.h index 6db216b..841e0c1 100644 --- a/tidl_api/src/device_arginfo.h +++ b/tidl_api/src/device_arginfo.h @@ -31,6 +31,7 @@ #pragma once #include "executor.h" +#include namespace tidl { @@ -60,4 +61,49 @@ class DeviceArgInfo: public ArgInfo Kind kind_m; }; +/*! @class PipeInfo + * @brief Describe input and output required by piping output and input + * between Execution Objects + */ +class PipeInfo +{ + public: + uint32_t dataQ_m[OCL_TIDL_MAX_IN_BUFS]; + uint32_t bufAddr_m[OCL_TIDL_MAX_IN_BUFS]; +}; + +/*! @class IODeviceArgInfo + * @brief Describe input and output buffers by an Execution Object (EO) + * Also used to chain execution objects - the output buffer of a + * producer EO is the same as the input buffer of a consumer EO. + * The PipeInfo must be shared across the producer and consumer EO, + * hence the shared pointer. + */ +class IODeviceArgInfo +{ + public: + explicit IODeviceArgInfo(const ArgInfo& arg): + arg_m(arg, DeviceArgInfo::Kind::BUFFER) + { + pipe_m = std::make_shared(); + } + + IODeviceArgInfo(): arg_m(nullptr, 0, DeviceArgInfo::Kind::BUFFER) + { + pipe_m = nullptr; + } + + PipeInfo& GetPipe() { return *pipe_m; } + const DeviceArgInfo& GetArg() const { return arg_m; } + + //IODeviceArgInfo(const IODeviceArgInfo&) = delete; + //IODeviceArgInfo& operator=(const IODeviceArgInfo&) = delete; + + private: + DeviceArgInfo arg_m; + std::shared_ptr pipe_m; +}; + + + } //namespace diff --git a/tidl_api/src/execution_object.cpp b/tidl_api/src/execution_object.cpp index 18237fb..d722ebb 100644 --- a/tidl_api/src/execution_object.cpp +++ b/tidl_api/src/execution_object.cpp @@ -28,6 +28,9 @@ /*! \file execution_object.cpp */ +#include +#include +#include #include "executor.h" #include "execution_object.h" #include "trace.h" @@ -35,41 +38,11 @@ #include "parameters.h" #include "configuration.h" #include "common_defines.h" -#include #include "tidl_create_params.h" -#include -#include +#include "device_arginfo.h" using namespace tidl; -/*! @class PipeInfo - * @brief Describe input and output required by piping output and input - * between Execution Objects - */ -class PipeInfo -{ - public: - uint32_t dataQ_m[OCL_TIDL_MAX_IN_BUFS]; - uint32_t bufAddr_m[OCL_TIDL_MAX_IN_BUFS]; -}; - - -class IODeviceArgInfo -{ - public: - IODeviceArgInfo(const ArgInfo& arg): - arg_m(arg, DeviceArgInfo::Kind::BUFFER) {} explicit - - IODeviceArgInfo(): arg_m(nullptr, 0, DeviceArgInfo::Kind::BUFFER) {} - - PipeInfo& GetPipe() { return pipe_m; } - const DeviceArgInfo& GetArg() const { return arg_m; } - - private: - DeviceArgInfo arg_m; - PipeInfo pipe_m; -}; - class ExecutionObject::Impl { public: @@ -233,6 +206,13 @@ void ExecutionObject::SetInputOutputBuffer(const ArgInfo& in, const ArgInfo& out pimpl_m->out_m = IODeviceArgInfo(out); } +void ExecutionObject::SetInputOutputBuffer(const IODeviceArgInfo* in, + const IODeviceArgInfo* out) +{ + pimpl_m->in_m = *in; + pimpl_m->out_m = *out; +} + bool ExecutionObject::ProcessFrameStartAsync() { return pimpl_m->RunAsync(ExecutionObject::CallType::PROCESS); -- 2.39.2