mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
Add cmdContainer ULTs - idOffset & numIdd reset, Gfx alloc failure
ULT required to cover IDOffset and numIdd values during reset. ULT required to cover OUT_OF_MEM retrun during init. Fix to check for valid gfx allocation inside heap helper & destructor Change-Id: Ied9049b33dc0605d5f5f51c96114d5e96b26a4f7 Signed-off-by: Vinod Tipparaju <vinod.tipparaju@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
b7d5427f01
commit
8e6be83fcc
@@ -26,8 +26,7 @@ struct Event;
|
|||||||
struct Kernel;
|
struct Kernel;
|
||||||
|
|
||||||
struct CommandList : _ze_command_list_handle_t {
|
struct CommandList : _ze_command_list_handle_t {
|
||||||
static constexpr uint32_t maxNumInterfaceDescriptorsPerMediaInterfaceDescriptorLoad = 62u;
|
static constexpr uint32_t defaultNumIddsPerBlock = 64u;
|
||||||
static constexpr uint32_t defaultNumIddsPerBlock = maxNumInterfaceDescriptorsPerMediaInterfaceDescriptorLoad;
|
|
||||||
static constexpr uint32_t commandListimmediateIddsPerBlock = 1u;
|
static constexpr uint32_t commandListimmediateIddsPerBlock = 1u;
|
||||||
|
|
||||||
CommandList() = delete;
|
CommandList() = delete;
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ CommandContainer::~CommandContainer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (auto allocationIndirectHeap : allocationIndirectHeaps) {
|
for (auto allocationIndirectHeap : allocationIndirectHeaps) {
|
||||||
heapHelper->storeHeapAllocation(allocationIndirectHeap);
|
if (heapHelper) {
|
||||||
|
heapHelper->storeHeapAllocation(allocationIndirectHeap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (auto deallocation : deallocationContainer) {
|
for (auto deallocation : deallocationContainer) {
|
||||||
if (((deallocation->getAllocationType() == GraphicsAllocation::AllocationType::INTERNAL_HEAP) || (deallocation->getAllocationType() == GraphicsAllocation::AllocationType::LINEAR_STREAM))) {
|
if (((deallocation->getAllocationType() == GraphicsAllocation::AllocationType::INTERNAL_HEAP) || (deallocation->getAllocationType() == GraphicsAllocation::AllocationType::LINEAR_STREAM))) {
|
||||||
@@ -48,8 +50,6 @@ ErrorCode CommandContainer::initialize(Device *device) {
|
|||||||
}
|
}
|
||||||
this->device = device;
|
this->device = device;
|
||||||
|
|
||||||
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u));
|
|
||||||
|
|
||||||
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
|
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);
|
||||||
AllocationProperties properties{device->getRootDeviceIndex(),
|
AllocationProperties properties{device->getRootDeviceIndex(),
|
||||||
true /* allocateMemory*/,
|
true /* allocateMemory*/,
|
||||||
@@ -71,7 +71,9 @@ ErrorCode CommandContainer::initialize(Device *device) {
|
|||||||
commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
|
commandStream->replaceGraphicsAllocation(cmdBufferAllocation);
|
||||||
|
|
||||||
addToResidencyContainer(cmdBufferAllocation);
|
addToResidencyContainer(cmdBufferAllocation);
|
||||||
|
|
||||||
constexpr size_t heapSize = 65536u;
|
constexpr size_t heapSize = 65536u;
|
||||||
|
heapHelper = std::unique_ptr<HeapHelper>(new HeapHelper(device->getMemoryManager(), device->getDefaultEngine().commandStreamReceiver->getInternalAllocationStorage(), device->getNumAvailableDevices() > 1u));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) {
|
for (uint32_t i = 0; i < IndirectHeap::Type::NUM_TYPES; i++) {
|
||||||
allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i,
|
allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i,
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ GraphicsAllocation *HeapHelper::getHeapAllocation(uint32_t heapType, size_t heap
|
|||||||
return this->memManager->allocateGraphicsMemoryWithProperties(properties);
|
return this->memManager->allocateGraphicsMemoryWithProperties(properties);
|
||||||
}
|
}
|
||||||
void HeapHelper::storeHeapAllocation(GraphicsAllocation *heapAllocation) {
|
void HeapHelper::storeHeapAllocation(GraphicsAllocation *heapAllocation) {
|
||||||
this->storageForReuse->storeAllocation(std::unique_ptr<NEO::GraphicsAllocation>(heapAllocation), NEO::AllocationUsage::REUSABLE_ALLOCATION);
|
if (heapAllocation) {
|
||||||
|
this->storageForReuse->storeAllocation(std::unique_ptr<NEO::GraphicsAllocation>(heapAllocation), NEO::AllocationUsage::REUSABLE_ALLOCATION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
#include "shared/test/unit_test/fixtures/device_fixture.h"
|
#include "shared/test/unit_test/fixtures/device_fixture.h"
|
||||||
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
|
#include "shared/test/unit_test/mocks/mock_graphics_allocation.h"
|
||||||
|
|
||||||
|
#include "opencl/test/unit_test/mocks/mock_memory_manager.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
using namespace NEO;
|
using namespace NEO;
|
||||||
|
|
||||||
|
constexpr uint32_t defaultNumIddsPerBlock = 64;
|
||||||
|
|
||||||
class CommandContainerTest : public DeviceFixture,
|
class CommandContainerTest : public DeviceFixture,
|
||||||
public ::testing::Test {
|
public ::testing::Test {
|
||||||
|
|
||||||
@@ -128,6 +131,9 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeThenEverythingIs
|
|||||||
EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation);
|
EXPECT_EQ(indirectHeap->getGraphicsAllocation(), heapAllocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(cmdContainer.getIddBlock(), nullptr);
|
||||||
|
EXPECT_EQ(cmdContainer.getNumIddPerBlock(), defaultNumIddsPerBlock);
|
||||||
|
|
||||||
auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
|
auto &hwHelper = HwHelper::get(pDevice->getHardwareInfo().platform.eRenderCoreFamily);
|
||||||
|
|
||||||
EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(),
|
EXPECT_EQ(cmdContainer.getInstructionHeapBaseAddress(),
|
||||||
@@ -140,6 +146,22 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenInitializeWithoutDeviceThe
|
|||||||
EXPECT_EQ(ErrorCode::INVALID_DEVICE, status);
|
EXPECT_EQ(ErrorCode::INVALID_DEVICE, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateGfxMemoryFailsThenErrorIsReturned) {
|
||||||
|
CommandContainer cmdContainer;
|
||||||
|
pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(0, *pDevice->executionEnvironment));
|
||||||
|
auto status = cmdContainer.initialize(pDevice);
|
||||||
|
EXPECT_EQ(ErrorCode::OUT_OF_DEVICE_MEMORY, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(CommandContainerTest, givenCommandContainerDuringInitWhenAllocateHeapMemoryFailsThenErrorIsReturned) {
|
||||||
|
CommandContainer cmdContainer;
|
||||||
|
auto temp_memoryManager = pDevice->executionEnvironment->memoryManager.release();
|
||||||
|
pDevice->executionEnvironment->memoryManager.reset(new FailMemoryManager(1, *pDevice->executionEnvironment));
|
||||||
|
auto status = cmdContainer.initialize(pDevice);
|
||||||
|
EXPECT_EQ(ErrorCode::OUT_OF_DEVICE_MEMORY, status);
|
||||||
|
delete temp_memoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(CommandContainerTest, givenCommandContainerWhenSettingIndirectHeapAllocationThenAllocationIsSet) {
|
TEST_F(CommandContainerTest, givenCommandContainerWhenSettingIndirectHeapAllocationThenAllocationIsSet) {
|
||||||
CommandContainer cmdContainer;
|
CommandContainer cmdContainer;
|
||||||
MockGraphicsAllocation mockAllocation;
|
MockGraphicsAllocation mockAllocation;
|
||||||
@@ -173,6 +195,8 @@ TEST_F(CommandContainerTest, givenCommandContainerWhenResetThenStateIsReset) {
|
|||||||
EXPECT_NE(usedSize, cmdContainer.getCommandStream()->getUsed());
|
EXPECT_NE(usedSize, cmdContainer.getCommandStream()->getUsed());
|
||||||
EXPECT_EQ(0u, cmdContainer.getCommandStream()->getUsed());
|
EXPECT_EQ(0u, cmdContainer.getCommandStream()->getUsed());
|
||||||
EXPECT_EQ(0u, cmdContainer.lastSentNumGrfRequired);
|
EXPECT_EQ(0u, cmdContainer.lastSentNumGrfRequired);
|
||||||
|
EXPECT_EQ(cmdContainer.getIddBlock(), nullptr);
|
||||||
|
EXPECT_EQ(cmdContainer.getNumIddPerBlock(), defaultNumIddsPerBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidencyContainerThenNothingIsAdded) {
|
TEST_F(CommandContainerTest, givenCommandContainerWhenWantToAddNullPtrToResidencyContainerThenNothingIsAdded) {
|
||||||
|
|||||||
Reference in New Issue
Block a user