mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Use csr internal allocs for host pointers for flushTask
Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com> Signed-off-by: Vinod Tipparaju <vinod.tipparaju@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
faea7915c2
commit
5d1c3c98a4
@@ -10,6 +10,8 @@
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/device/device_info.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
@@ -21,7 +23,9 @@ CommandList::~CommandList() {
|
||||
cmdQImmediate->destroy();
|
||||
}
|
||||
removeDeallocationContainerData();
|
||||
removeHostPtrAllocations();
|
||||
if (this->cmdListType == CommandListType::TYPE_REGULAR || !this->isFlushTaskSubmissionEnabled) {
|
||||
removeHostPtrAllocations();
|
||||
}
|
||||
printfFunctionContainer.clear();
|
||||
}
|
||||
|
||||
@@ -56,6 +60,14 @@ NEO::GraphicsAllocation *CommandList::getAllocationFromHostPtrMap(const void *bu
|
||||
return allocation->second;
|
||||
}
|
||||
}
|
||||
if (this->cmdListType == CommandListType::TYPE_IMMEDIATE && this->isFlushTaskSubmissionEnabled) {
|
||||
auto allocation = this->csr->getInternalAllocationStorage()->obtainTemporaryAllocationWithPtr(bufferSize, buffer, NEO::GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR);
|
||||
if (allocation != nullptr) {
|
||||
auto alloc = allocation.get();
|
||||
this->csr->getInternalAllocationStorage()->storeAllocation(std::move(allocation), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
return alloc;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -66,7 +78,11 @@ NEO::GraphicsAllocation *CommandList::getHostPtrAlloc(const void *buffer, uint64
|
||||
}
|
||||
alloc = device->allocateMemoryFromHostPtr(buffer, bufferSize);
|
||||
UNRECOVERABLE_IF(alloc == nullptr);
|
||||
hostPtrMap.insert(std::make_pair(buffer, alloc));
|
||||
if (this->cmdListType == CommandListType::TYPE_IMMEDIATE && this->isFlushTaskSubmissionEnabled) {
|
||||
this->csr->getInternalAllocationStorage()->storeAllocation(std::unique_ptr<NEO::GraphicsAllocation>(alloc), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
} else {
|
||||
hostPtrMap.insert(std::make_pair(buffer, alloc));
|
||||
}
|
||||
return alloc;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist/cmdlist_hw_immediate.h"
|
||||
|
||||
@@ -92,7 +93,7 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::executeCommandListImm
|
||||
if (this->isSyncModeQueue) {
|
||||
auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
|
||||
this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, completionStamp.taskCount);
|
||||
this->removeHostPtrAllocations();
|
||||
this->csr->getInternalAllocationStorage()->cleanAllocationList(completionStamp.taskCount, NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
}
|
||||
|
||||
cmdListBBEndOffset = commandStream->getUsed();
|
||||
|
||||
@@ -27,7 +27,7 @@ CommandListAllocatorFn commandListFactory[IGFX_MAX_PRODUCT] = {};
|
||||
CommandListAllocatorFn commandListFactoryImmediate[IGFX_MAX_PRODUCT] = {};
|
||||
|
||||
ze_result_t CommandListImp::destroy() {
|
||||
if (this->isFlushTaskSubmissionEnabled && !this->isSyncModeQueue) {
|
||||
if (this->cmdListType == CommandListType::TYPE_IMMEDIATE && this->isFlushTaskSubmissionEnabled && !this->isSyncModeQueue) {
|
||||
auto timeoutMicroseconds = NEO::TimeoutControls::maxTimeout;
|
||||
this->csr->waitForCompletionWithTimeout(false, timeoutMicroseconds, this->csr->peekTaskCount());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
|
||||
#include "level_zero/core/source/event/event.h"
|
||||
|
||||
namespace L0 {
|
||||
@@ -98,6 +100,7 @@ ze_result_t EventImp<TagSizeT>::queryStatusKernelTimestamp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
this->csr->getInternalAllocationStorage()->cleanAllocationList(this->csr->peekTaskCount(), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -113,6 +116,7 @@ ze_result_t EventImp<TagSizeT>::queryStatusNonTimestamp() {
|
||||
}
|
||||
}
|
||||
}
|
||||
this->csr->getInternalAllocationStorage()->cleanAllocationList(this->csr->peekTaskCount(), NEO::AllocationUsage::TEMPORARY_ALLOCATION);
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -706,19 +706,54 @@ HWTEST_F(L0DebuggerInternalUsageTest, givenUseCsrImmediateSubmissionEnabledForIm
|
||||
|
||||
void *srcPtr = reinterpret_cast<void *>(0x1234);
|
||||
void *dstPtr = reinterpret_cast<void *>(0x2345);
|
||||
ze_copy_region_t dstRegion = {};
|
||||
ze_copy_region_t srcRegion = {};
|
||||
uint32_t width = 16;
|
||||
uint32_t height = 16;
|
||||
ze_copy_region_t sr = {0U, 0U, 0U, width, height, 0U};
|
||||
ze_copy_region_t dr = {0U, 0U, 0U, width, height, 0U};
|
||||
|
||||
ze_command_queue_desc_t queueDesc = {};
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
auto commandList = CommandList::createImmediate(productFamily, device, &queueDesc, true, NEO::EngineGroupType::RenderCompute, returnValue);
|
||||
|
||||
auto result = commandList->appendMemoryCopyRegion(dstPtr, &dstRegion, 0, 0, srcPtr, &srcRegion, 0, 0, nullptr, 0, nullptr);
|
||||
auto result = commandList->appendMemoryCopyRegion(dstPtr, &dr, 0, 0, srcPtr, &sr, 0, 0, nullptr, 0, nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
commandList->destroy();
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerInternalUsageTest, givenUseCsrImmediateSubmissionEnabledForRegularCommandListForAppendMemoryCopyRegionThenSuccessIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.EnableFlushTaskSubmission.set(true);
|
||||
|
||||
void *srcPtr = reinterpret_cast<void *>(0x1234);
|
||||
void *dstPtr = reinterpret_cast<void *>(0x2345);
|
||||
uint32_t width = 16;
|
||||
uint32_t height = 16;
|
||||
ze_copy_region_t sr = {0U, 0U, 0U, width, height, 0U};
|
||||
ze_copy_region_t dr = {0U, 0U, 0U, width, height, 0U};
|
||||
|
||||
ze_command_queue_desc_t queueDesc = {};
|
||||
ze_result_t returnValue;
|
||||
auto commandQueue = whitebox_cast(CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, returnValue));
|
||||
ASSERT_NE(nullptr, commandQueue->commandStream);
|
||||
|
||||
ze_command_list_handle_t commandLists[] = {
|
||||
CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle()};
|
||||
const uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]);
|
||||
|
||||
auto commandList = CommandList::fromHandle(commandLists[0]);
|
||||
auto result = commandList->appendMemoryCopyRegion(dstPtr, &dr, 0, 0, srcPtr, &sr, 0, 0, nullptr, 0, nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
commandQueue->synchronize(0);
|
||||
|
||||
commandList->destroy();
|
||||
commandQueue->destroy();
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerInternalUsageTest, givenUseCsrImmediateSubmissionDisabledForImmediateCommandListForAppendMemoryCopyRegionThenSuccessIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.EnableFlushTaskSubmission.set(false);
|
||||
@@ -1048,6 +1083,28 @@ HWTEST_F(L0DebuggerSimpleTest, givenUseCsrImmediateSubmissionDisabledWithImmedia
|
||||
context->freeMem(dstPtr);
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerSimpleTest, givenUseCsrImmediateSubmissionEnabledForImmediateCommandListForAppendMemoryFillWithDeviceMemoryThenSuccessIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.EnableFlushTaskSubmission.set(true);
|
||||
|
||||
void *dstPtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
auto result = context->allocDeviceMem(device->toHandle(), &deviceDesc, 16384u, 4096u, &dstPtr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
int pattern = 1;
|
||||
|
||||
ze_command_queue_desc_t queueDesc = {};
|
||||
queueDesc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS;
|
||||
ze_result_t returnValue = ZE_RESULT_SUCCESS;
|
||||
auto commandList = CommandList::createImmediate(productFamily, device, &queueDesc, true, NEO::EngineGroupType::RenderCompute, returnValue);
|
||||
|
||||
result = commandList->appendMemoryFill(dstPtr, reinterpret_cast<void *>(&pattern), sizeof(pattern), 4096u, nullptr, 0, nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
context->freeMem(dstPtr);
|
||||
commandList->destroy();
|
||||
}
|
||||
|
||||
HWTEST_F(L0DebuggerSimpleTest, givenUseCsrImmediateSubmissionEnabledForImmediateCommandListForAppendMemoryFillThenSuccessIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::DebugManager.flags.EnableFlushTaskSubmission.set(true);
|
||||
@@ -1107,12 +1164,22 @@ HWTEST_F(L0DebuggerSimpleTest, givenUseCsrImmediateSubmissionEnabledForRegularCo
|
||||
CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle()};
|
||||
const uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]);
|
||||
|
||||
auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true);
|
||||
void *dstPtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
auto result = context->allocDeviceMem(device->toHandle(), &deviceDesc, 16384u, 4096u, &dstPtr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
int pattern = 1;
|
||||
|
||||
auto commandList = CommandList::fromHandle(commandLists[0]);
|
||||
result = commandList->appendMemoryFill(dstPtr, reinterpret_cast<void *>(&pattern), sizeof(pattern), 4096u, nullptr, 0, nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
commandQueue->synchronize(0);
|
||||
|
||||
auto commandList = CommandList::fromHandle(commandLists[0]);
|
||||
context->freeMem(dstPtr);
|
||||
commandList->destroy();
|
||||
|
||||
commandQueue->destroy();
|
||||
@@ -1131,12 +1198,23 @@ HWTEST_F(L0DebuggerSimpleTest, givenUseCsrImmediateSubmissionDisabledForRegularC
|
||||
CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)->toHandle()};
|
||||
const uint32_t numCommandLists = sizeof(commandLists) / sizeof(commandLists[0]);
|
||||
|
||||
auto result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true);
|
||||
void *dstPtr = nullptr;
|
||||
ze_device_mem_alloc_desc_t deviceDesc = {};
|
||||
ze_host_mem_alloc_desc_t hostDesc = {};
|
||||
auto result = context->allocSharedMem(device->toHandle(), &deviceDesc, &hostDesc, 16384u, 4096u, &dstPtr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
int pattern = 1;
|
||||
|
||||
auto commandList = CommandList::fromHandle(commandLists[0]);
|
||||
result = commandList->appendMemoryFill(dstPtr, reinterpret_cast<void *>(&pattern), sizeof(pattern), 4096u, nullptr, 0, nullptr);
|
||||
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
result = commandQueue->executeCommandLists(numCommandLists, commandLists, nullptr, true);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
commandQueue->synchronize(0);
|
||||
|
||||
auto commandList = CommandList::fromHandle(commandLists[0]);
|
||||
context->freeMem(dstPtr);
|
||||
commandList->destroy();
|
||||
|
||||
commandQueue->destroy();
|
||||
|
||||
Reference in New Issue
Block a user