Modified IODeviceArgInfo to enable pipelining EOs
authorAjay Jayaraj <ajayj@ti.com>
Mon, 13 Aug 2018 19:56:24 +0000 (14:56 -0500)
committerAjay Jayaraj <ajayj@ti.com>
Mon, 13 Aug 2018 19:56:24 +0000 (14:56 -0500)
(MCT-1030)

tidl_api/inc/execution_object.h
tidl_api/src/device_arginfo.h
tidl_api/src/execution_object.cpp

index ccc088180dd975e92e79e2e01ee0ce3f55873996..e78ad2e98f0ec8ffd4305536bca46c368dbb4f3b 100644 (file)
@@ -37,6 +37,7 @@ namespace tidl {
 class Kernel;
 class Device;
 class LayerOutput;
+class IODeviceArgInfo;
 
 typedef std::vector<std::unique_ptr<const LayerOutput>> LayerOutputs;
 
@@ -132,6 +133,10 @@ class ExecutionObject
 
         void EnableOutputBufferTrace();
 
+        //! @private
+        void SetInputOutputBuffer(const IODeviceArgInfo* in,
+                                  const IODeviceArgInfo* out);
+
     private:
         class Impl;
         std::unique_ptr<Impl> pimpl_m;
index 6db216bd35fd86771a2810fdc27773a2e5583b3d..841e0c14ad537beda063d0480a0d722f254a10b5 100644 (file)
@@ -31,6 +31,7 @@
 #pragma once
 
 #include "executor.h"
+#include <memory>
 
 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<PipeInfo>();
+        }
+
+        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<PipeInfo> pipe_m;
+};
+
+
+
 } //namespace
index 18237fb276a8eec9d5bae55575b699a594028d19..d722ebb196669019fbc3071338397d62a9a79ba9 100644 (file)
@@ -28,6 +28,9 @@
 
 /*! \file execution_object.cpp */
 
+#include <string.h>
+#include <fstream>
+#include <climits>
 #include "executor.h"
 #include "execution_object.h"
 #include "trace.h"
 #include "parameters.h"
 #include "configuration.h"
 #include "common_defines.h"
-#include <string.h>
 #include "tidl_create_params.h"
-#include <fstream>
-#include <climits>
+#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);