mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Add deferred list to TagAllocator for nodes that are not completed
Change-Id: I0672c487315a96540184eda793132c79c7777527 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
096fa0e64f
commit
e3df4edb90
@@ -35,6 +35,7 @@ struct HwTimeStamps {
|
||||
GlobalCompleteTS = 0;
|
||||
ContextCompleteTS = 0;
|
||||
}
|
||||
bool canBeReleased() const { return true; }
|
||||
uint64_t GlobalStartTS;
|
||||
uint64_t ContextStartTS;
|
||||
uint64_t GlobalEndTS;
|
||||
|
||||
@@ -32,6 +32,7 @@ struct HwPerfCounter {
|
||||
HWPerfCounters = {};
|
||||
HWTimeStamp.initialize();
|
||||
}
|
||||
bool canBeReleased() const { return true; }
|
||||
HwPerfCounters HWPerfCounters;
|
||||
HwTimeStamps HWTimeStamp;
|
||||
};
|
||||
|
||||
@@ -41,6 +41,11 @@ class TimestampPacket {
|
||||
End
|
||||
};
|
||||
|
||||
bool canBeReleased() const {
|
||||
return data[static_cast<uint32_t>(DataIndex::ContextEnd)] != 1 &&
|
||||
data[static_cast<uint32_t>(DataIndex::GlobalEnd)] != 1;
|
||||
}
|
||||
|
||||
const uint32_t *pickDataPtr() const { return &(data[0]); }
|
||||
|
||||
uint64_t pickAddressForPipeControlWrite(WriteOperationType operationType) const {
|
||||
|
||||
@@ -86,6 +86,7 @@ class TagAllocator {
|
||||
NodeType *getTag() {
|
||||
NodeType *node = freeTags.removeFrontOne().release();
|
||||
if (!node) {
|
||||
std::unique_lock<std::mutex> lock(allocatorMutex);
|
||||
populateFreeTags();
|
||||
node = freeTags.removeFrontOne().release();
|
||||
}
|
||||
@@ -97,13 +98,18 @@ class TagAllocator {
|
||||
|
||||
MOCKABLE_VIRTUAL void returnTag(NodeType *node) {
|
||||
if (node->refCount.fetch_sub(1) == 1) {
|
||||
return returnTagToPool(node);
|
||||
if (node->tag->canBeReleased()) {
|
||||
returnTagToFreePool(node);
|
||||
} else {
|
||||
returnTagToDeferredPool(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
IDList<NodeType> freeTags;
|
||||
IDList<NodeType> usedTags;
|
||||
IDList<NodeType> deferredTags;
|
||||
std::vector<GraphicsAllocation *> gfxAllocations;
|
||||
std::vector<NodeType *> tagPoolMemory;
|
||||
|
||||
@@ -111,23 +117,26 @@ class TagAllocator {
|
||||
size_t tagCount;
|
||||
size_t tagAlignment;
|
||||
|
||||
std::mutex allocationsMutex;
|
||||
std::mutex allocatorMutex;
|
||||
|
||||
MOCKABLE_VIRTUAL void returnTagToPool(NodeType *node) {
|
||||
MOCKABLE_VIRTUAL void returnTagToFreePool(NodeType *node) {
|
||||
NodeType *usedNode = usedTags.removeOne(*node).release();
|
||||
DEBUG_BREAK_IF(usedNode == nullptr);
|
||||
((void)(usedNode));
|
||||
freeTags.pushFrontOne(*node);
|
||||
}
|
||||
|
||||
void populateFreeTags() {
|
||||
void returnTagToDeferredPool(NodeType *node) {
|
||||
NodeType *usedNode = usedTags.removeOne(*node).release();
|
||||
DEBUG_BREAK_IF(!usedNode);
|
||||
deferredTags.pushFrontOne(*usedNode);
|
||||
}
|
||||
|
||||
void populateFreeTags() {
|
||||
size_t tagSize = sizeof(TagType);
|
||||
tagSize = alignUp(tagSize, tagAlignment);
|
||||
size_t allocationSizeRequired = tagCount * tagSize;
|
||||
|
||||
std::unique_lock<std::mutex> lock(allocationsMutex);
|
||||
|
||||
GraphicsAllocation *graphicsAllocation = memoryManager->allocateGraphicsMemory(allocationSizeRequired);
|
||||
gfxAllocations.push_back(graphicsAllocation);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user