mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 06:23:01 +08:00
Fix resource destruction scheme on device closure.
- Call waitForTaskCountAndCleanAllocationList with latest flushed task count to reflect what was actually sent to HW. - refactor cleanAllocationList to waitForTaskCountAndCleanAllocationList Change-Id: I5301185c5fce212e39eb017b952b43c279559cf4
This commit is contained in:
committed by
sys_ocldev
parent
42798fcae0
commit
af77720f9c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -409,7 +409,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
|
||||
if (printfHandler) {
|
||||
printfHandler->printEnqueueOutput();
|
||||
}
|
||||
commandStreamReceiver.cleanAllocationList(taskCount, TEMPORARY_ALLOCATION);
|
||||
commandStreamReceiver.waitForTaskCountAndCleanAllocationList(taskCount, TEMPORARY_ALLOCATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -43,7 +43,7 @@ cl_int CommandQueueHw<GfxFamily>::finish(bool dcFlush) {
|
||||
// Stall until HW reaches CQ taskCount
|
||||
waitUntilComplete(taskCountToWaitFor, flushStampToWaitFor);
|
||||
|
||||
commandStreamReceiver.cleanAllocationList(taskCountToWaitFor, TEMPORARY_ALLOCATION);
|
||||
commandStreamReceiver.waitForTaskCountAndCleanAllocationList(taskCountToWaitFor, TEMPORARY_ALLOCATION);
|
||||
|
||||
return CL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ GraphicsAllocation *CommandStreamReceiver::createAllocationAndHandleResidency(co
|
||||
return graphicsAllocation;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::cleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType) {
|
||||
void CommandStreamReceiver::waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType) {
|
||||
|
||||
auto address = getTagAddress();
|
||||
if (address && requiredTaskCount != (unsigned int)-1) {
|
||||
@@ -153,6 +153,9 @@ void CommandStreamReceiver::cleanupResources() {
|
||||
if (!memoryManager)
|
||||
return;
|
||||
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, TEMPORARY_ALLOCATION);
|
||||
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, REUSABLE_ALLOCATION);
|
||||
|
||||
if (scratchAllocation) {
|
||||
memoryManager->freeGraphicsMemory(scratchAllocation);
|
||||
scratchAllocation = nullptr;
|
||||
@@ -162,9 +165,6 @@ void CommandStreamReceiver::cleanupResources() {
|
||||
memoryManager->freeGraphicsMemory(preemptionCsrAllocation);
|
||||
}
|
||||
|
||||
cleanAllocationList(-1, TEMPORARY_ALLOCATION);
|
||||
cleanAllocationList(-1, REUSABLE_ALLOCATION);
|
||||
|
||||
if (commandStream.getBase()) {
|
||||
memoryManager->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
||||
commandStream.replaceGraphicsAllocation(nullptr);
|
||||
@@ -196,7 +196,7 @@ bool CommandStreamReceiver::waitForCompletionWithTimeout(bool enableTimeout, int
|
||||
|
||||
void CommandStreamReceiver::setTagAllocation(GraphicsAllocation *allocation) {
|
||||
this->tagAllocation = allocation;
|
||||
this->tagAddress = reinterpret_cast<uint32_t *>(allocation->getUnderlyingBuffer());
|
||||
this->tagAddress = allocation ? reinterpret_cast<uint32_t *>(allocation->getUnderlyingBuffer()) : nullptr;
|
||||
}
|
||||
|
||||
void CommandStreamReceiver::setRequiredScratchSize(uint32_t newRequiredScratchSize) {
|
||||
|
||||
@@ -75,7 +75,7 @@ class CommandStreamReceiver {
|
||||
void setMemoryManager(MemoryManager *mm);
|
||||
|
||||
GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true);
|
||||
void cleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType);
|
||||
void waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType);
|
||||
|
||||
LinearStream &getCS(size_t minRequiredSize = 1024u);
|
||||
OSInterface *getOSInterface() { return osInterface.get(); };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Intel Corporation
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
@@ -83,14 +83,14 @@ Device::Device(const HardwareInfo &hwInfo,
|
||||
|
||||
Device::~Device() {
|
||||
DEBUG_BREAK_IF(nullptr == memoryManager);
|
||||
if (memoryManager) {
|
||||
memoryManager->freeGraphicsMemory(tagAllocation);
|
||||
}
|
||||
tagAllocation = nullptr;
|
||||
if (performanceCounters) {
|
||||
performanceCounters->shutdown();
|
||||
}
|
||||
delete commandStreamReceiver;
|
||||
if (memoryManager) {
|
||||
memoryManager->freeGraphicsMemory(tagAllocation);
|
||||
}
|
||||
tagAllocation = nullptr;
|
||||
commandStreamReceiver = nullptr;
|
||||
if (memoryManager) {
|
||||
memoryManager->waitForDeletions();
|
||||
|
||||
Reference in New Issue
Block a user