| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#ifndef __VP_GRAPH_MANAGER_H__ |
| 29 |
#define __VP_GRAPH_MANAGER_H__ |
| 30 |
|
| 31 |
#include "vp_pipeline_common.h" |
| 32 |
#include "vp_allocator.h" |
| 33 |
#include "vp_graphset.h" |
| 34 |
#include "vp_ai_kernel_pipe.h" |
| 35 |
#include "levelzero_npu_interface.h" |
| 36 |
#include "npu_cmd_packet.h" |
| 37 |
|
| 38 |
namespace vp |
| 39 |
{ |
| 40 |
|
| 41 |
#define GRAPH_PACKAGE_INITIALIZE_TIMEOUT_MS 100 // first frame need initialize graph timing |
| 42 |
|
| 43 |
class GraphPackage |
| 44 |
{ |
| 45 |
public: |
| 46 |
GraphPackage() : m_npuWLContext(GRAPH_PACKAGE_INITIALIZE_TIMEOUT_MS) {}; |
| 47 |
NpuWLContext &GetNpuWLContext() |
| 48 |
{ |
| 49 |
return m_npuWLContext; |
| 50 |
} |
| 51 |
std::map<SurfaceType, PVP_SURFACE> &IntermiedateSurfaces() |
| 52 |
{ |
| 53 |
return m_intermediateSurfaces; |
| 54 |
} |
| 55 |
|
| 56 |
private: |
| 57 |
|
| 58 |
std::map<SurfaceType, PVP_SURFACE> m_intermediateSurfaces = {}; |
| 59 |
NpuWLContext m_npuWLContext; |
| 60 |
}; |
| 61 |
|
| 62 |
class VpGraphManager |
| 63 |
{ |
| 64 |
public: |
| 65 |
VpGraphManager(VpGraphSet *graphset, PMOS_INTERFACE osInterface, VpAllocator *allocator); |
| 66 |
~VpGraphManager() { Destroy(); }; |
| 67 |
|
| 68 |
MOS_STATUS GetGraphPackage(std::vector<AI_SINGLE_NPU_GRAPH_SETTING> &graphSettings, SwFilterPipe &executingPipe, GraphPackage *&graphPackage); |
| 69 |
|
| 70 |
private: |
| 71 |
MOS_STATUS Destroy(); |
| 72 |
|
| 73 |
private: |
| 74 |
std::map<VpGraphIDList, GraphPackage> m_graphPackages = {}; |
| 75 |
VpGraphSet *m_graphset = nullptr; |
| 76 |
PMOS_INTERFACE m_osInterface = nullptr; |
| 77 |
L0NpuInterface *m_npuInterface = nullptr; |
| 78 |
VpAllocator *m_allocator = nullptr; |
| 79 |
|
| 80 |
MEDIA_CLASS_DEFINE_END(vp__VpGraphManager) |
| 81 |
}; |
| 82 |
|
| 83 |
class InitGraphListCmdPackage : public CmdPackage |
| 84 |
{ |
| 85 |
public: |
| 86 |
InitGraphListCmdPackage(L0NpuInterface *npuInterface, GraphPackage *graphPackage) : m_npuInterface(npuInterface), m_graphPackage(graphPackage) {}; |
| 87 |
virtual MOS_STATUS Submit(); |
| 88 |
virtual MOS_STATUS Wait() { return MOS_STATUS_SUCCESS; }; |
| 89 |
virtual std::unique_ptr<CmdPackage> Clone() const; |
| 90 |
virtual bool Releaseable() override { return m_releaseable; }; |
| 91 |
virtual MOS_STATUS AddGraphHandle(GraphHandle *grapHandle) |
| 92 |
{ |
| 93 |
m_graphHandles.push_back(grapHandle); |
| 94 |
return MOS_STATUS_SUCCESS; |
| 95 |
} |
| 96 |
virtual MOS_STATUS AddSingleLayerGraphArgs(std::vector<void *> &singleLayerGraphArgs) |
| 97 |
{ |
| 98 |
m_multiLayerGraphArgs.push_back(singleLayerGraphArgs); |
| 99 |
return MOS_STATUS_SUCCESS; |
| 100 |
} |
| 101 |
|
| 102 |
private: |
| 103 |
L0NpuInterface *m_npuInterface = nullptr; |
| 104 |
GraphPackage *m_graphPackage = nullptr; |
| 105 |
std::vector<GraphHandle *> m_graphHandles = {}; |
| 106 |
std::vector<std::vector<void *>> m_multiLayerGraphArgs = {}; |
| 107 |
bool m_releaseable = false; |
| 108 |
}; |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
#endif |