DRQ的作用:
DRQ负责调度管理pipeline里的node处理逻辑(通过node之间的dependency依赖机制)
利用多线程并行处理Pipeline中并行的node,加快处理速度
DRQ运转流程:
DRQ先告诉node fill dependency, 此时seq id 为0(metadata/property,buffer,chifence)
metadatapool writeDataList - DRQ - thread pool - node 此时seq id 为1
buffer signal - camsync - DRQ - node
chifence signal - camsync - DRQ - node
线程池和DRQ实例:
session, pipeline, node, drq, metapool等用的是chicontext里的同一个线程池
ChiContext::Initialize()
{
ThreadManager::Create(&m_pThreadManager, "SoloThreadManager", numThreads);
//线程池handler会传递给session, pipeline, node, drq, metapool等进行共同使用
}
一个session里面所有的pipeline共用一个DRQ
Session::Initialize()
{
m_pDeferredRequestQueue = DeferredRequestQueue::Create(&pDeferredCreateData);
}
重要结构体介绍:
DeferredRequestQueue:
class DeferredRequestQueue : public IPropertyPoolObserver(观察者模式)
{
Hashmap* m_pDependencyMap; ///< Hashmap to store pending dependencies(所有的依赖)
ThreadManager* m_pThreadManager; ///< 指向一个线程池
Session* m_pSession; ///< pointer to Session to which this DRQ belongs
JobHandle m_hDeferredWorker; ///< 通过这个worker handle执行异步操作
LightweightDoublyLinkedList m_deferredNodes; ///< List of deferred nodes
LightweightDoublyLinkedList m_readyNodes; ///< List of ready nodes
MetadataPool* m_pMainPools[MaxPipelinesPerSession]; ///< 保存了每个pipeline的result metadata pool
}
DependencyUnit:(每个node需要填充的Dependency)
每个Node需要填写自己处理一个request需要的dependency(chifence, fence, metadata/property),只有所有的dependency都满足后,DRQ才会调度线程池去安排node处理request
struct DependencyUnit
{
PropertyDependency propertyDependency(metadata);
bufferDependency;// input buffer fence
chiFenceDependency;// non buffer fence(NCS)
}
Dependency:(node填充完Dependency后会送到DRQ,这个是转换为属于DRQ的Dependency)
DependencyKey:(Hashmap的key)
struct DependencyKey
{
UINT64 requestId; ///< Request ID
UINT64 pipelineId; ///< pipeline id for the data
UINT32 dataId; ///< Property/Metadata/Data identifier
VOID* pFence; ///< Fence pointer
VOID* pChiFence; ///< Chi Fence pointer
};
mapKey-property类型:
DependencyKey mapKey = {request, pDependency->pipelineIds[i], pDependency->properties[i], NULL, NULL};
mapKey-buffer fence(csl)类型:
DependencyKey mapKey = {0, 0, PropertyIDInvalid, pDependency->phFences[i], NULL};
mapKey-chi fence类型:
DependencyKey mapKey = {0, 0, PropertyIDInvalid, NULL, pDependency->pChiFences[i]};
HashMap结构图:
m_deferredNodes 与 m_readyNodes 结构:
所有的Dependency会先加入到m_deferredNodes 链表中,当所有的Dependency满足时会添加到m_readyNodes链表中
m_readyNodes会丢进线程池中去处理(即调用当前已经满足依赖的node processrequest)
DRQ相关知识点可以结合以下博客,共同分析:
【Qcom Camera】DumpDebugInfo分析-****博客