mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
fix: don't allow for passing null descriptor for creating mem / cmdlist
L0 headers provide default descriptors that app can use Related-To: NEO-14560 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
68d87f3499
commit
352b1dcb1c
@@ -93,13 +93,11 @@ ContextImp::~ContextImp() {
|
||||
destroyContextExt(this->contextExt);
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
ze_result_t ContextImp::allocHostMem(const ze_host_mem_alloc_desc_t *hostMemDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **ptr) {
|
||||
|
||||
auto hostMemDesc = hostDesc ? hostDesc : &zeDefaultGPUHostMemAllocDesc;
|
||||
|
||||
if (NEO::debugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||
size += (MemoryConstants::pageSize * NEO::debugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||
}
|
||||
@@ -245,12 +243,10 @@ ze_result_t ContextImp::checkMemSizeLimit(Device *inDevice, size_t size, bool re
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
const ze_device_mem_alloc_desc_t *deviceMemDesc,
|
||||
size_t size,
|
||||
size_t alignment, void **ptr) {
|
||||
|
||||
auto deviceMemDesc = deviceDesc ? deviceDesc : &zeDefaultGPUDeviceMemAllocDesc;
|
||||
|
||||
if (NEO::debugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||
size += (MemoryConstants::pageSize * NEO::debugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||
}
|
||||
@@ -369,15 +365,12 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice,
|
||||
}
|
||||
|
||||
ze_result_t ContextImp::allocSharedMem(ze_device_handle_t hDevice,
|
||||
const ze_device_mem_alloc_desc_t *deviceDesc,
|
||||
const ze_host_mem_alloc_desc_t *hostDesc,
|
||||
const ze_device_mem_alloc_desc_t *deviceMemDesc,
|
||||
const ze_host_mem_alloc_desc_t *hostMemDesc,
|
||||
size_t size,
|
||||
size_t alignment,
|
||||
void **ptr) {
|
||||
|
||||
auto deviceMemDesc = deviceDesc ? deviceDesc : &zeDefaultGPUDeviceMemAllocDesc;
|
||||
auto hostMemDesc = hostDesc ? hostDesc : &zeDefaultGPUHostMemAllocDesc;
|
||||
|
||||
if (NEO::debugManager.flags.ForceExtendedUSMBufferSize.get() >= 1) {
|
||||
size += (MemoryConstants::pageSize * NEO::debugManager.flags.ForceExtendedUSMBufferSize.get());
|
||||
}
|
||||
|
||||
@@ -199,11 +199,7 @@ ze_result_t DeviceImp::createInternalCommandList(const ze_command_list_desc_t *d
|
||||
ze_result_t DeviceImp::createCommandListImmediate(const ze_command_queue_desc_t *desc,
|
||||
ze_command_list_handle_t *phCommandList) {
|
||||
|
||||
ze_command_queue_desc_t commandQueueDesc = zeDefaultGPUImmediateCommandQueueDesc;
|
||||
|
||||
if (desc) {
|
||||
commandQueueDesc = *desc;
|
||||
}
|
||||
ze_command_queue_desc_t commandQueueDesc = *desc;
|
||||
|
||||
if (!this->isQueueGroupOrdinalValid(commandQueueDesc.ordinal)) {
|
||||
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
|
||||
|
||||
@@ -106,24 +106,6 @@ struct DefaultDescriptorWithoutBlitterTest : Test<DeviceFixture> {
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(DefaultDescriptorWithoutBlitterTest, givenDeviceWithoutBlitterSupportWhenCreatingCommandListImmediateWithoutDescriptorThenInOrderAsyncCmdListWithoutCopyOffloadIsCreated) {
|
||||
ze_command_list_handle_t hCommandList = {};
|
||||
ze_result_t result = context->createCommandListImmediate(device, nullptr, &hCommandList);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
auto commandList = CommandList::whiteboxCast(L0::CommandList::fromHandle(hCommandList));
|
||||
uint32_t ordinal = std::numeric_limits<uint32_t>::max();
|
||||
EXPECT_EQ(commandList->getOrdinal(&ordinal), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(ordinal, 0u);
|
||||
uint32_t index = std::numeric_limits<uint32_t>::max();
|
||||
EXPECT_EQ(commandList->getImmediateIndex(&index), ZE_RESULT_SUCCESS);
|
||||
EXPECT_EQ(index, 0u);
|
||||
EXPECT_TRUE(commandList->isInOrderExecutionEnabled());
|
||||
EXPECT_FALSE(commandList->isSyncModeQueue);
|
||||
EXPECT_FALSE(commandList->isCopyOffloadEnabled());
|
||||
commandList->destroy();
|
||||
}
|
||||
|
||||
TEST_F(DefaultDescriptorWithoutBlitterTest, givenDeviceWithoutBlitterSupportWhenCreatingCommandListImmediateWithDefaultDescriptorThenInOrderAsyncCmdListWithoutCopyOffloadIsCreated) {
|
||||
ze_command_list_handle_t hCommandList = {};
|
||||
ze_result_t result = context->createCommandListImmediate(device, &zeDefaultGPUImmediateCommandQueueDesc, &hCommandList);
|
||||
|
||||
@@ -798,64 +798,6 @@ TEST_F(MemoryTest, whenAllocatingSharedMemoryWithUncachedFlagThenLocallyUncached
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(MemoryTest, whenAllocatingHostMemoryWithoutDescriptorThenCachedResourceIsCreated) {
|
||||
size_t size = 10;
|
||||
size_t alignment = 1u;
|
||||
void *ptr = nullptr;
|
||||
|
||||
ze_result_t result = context->allocHostMem(nullptr, size, alignment, &ptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_NE(nullptr, allocData);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 0u);
|
||||
|
||||
result = context->freeMem(ptr);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(MemoryTest, whenAllocatingDeviceMemoryWithoutDescriptorThenCachedResourceIsCreated) {
|
||||
size_t size = 10;
|
||||
size_t alignment = 1u;
|
||||
void *ptr = nullptr;
|
||||
|
||||
ze_result_t result = context->allocDeviceMem(device->toHandle(),
|
||||
nullptr,
|
||||
size, alignment, &ptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_NE(nullptr, allocData);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 0u);
|
||||
|
||||
result = context->freeMem(ptr);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(MemoryTest, whenAllocatingSharedMemoryWithoutDescriptorsThenCachedResourceWithCpuInitialPlacementIsCreated) {
|
||||
size_t size = 10;
|
||||
size_t alignment = 1u;
|
||||
void *ptr = nullptr;
|
||||
|
||||
ze_result_t result = context->allocSharedMem(device->toHandle(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
size, alignment, &ptr);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
auto allocData = driverHandle->getSvmAllocsManager()->getSVMAlloc(ptr);
|
||||
EXPECT_NE(nullptr, allocData);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 0u);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.allocFlags.usmInitialPlacementCpu, 1u);
|
||||
EXPECT_EQ(allocData->allocationFlagsProperty.allocFlags.usmInitialPlacementGpu, 0u);
|
||||
|
||||
result = context->freeMem(ptr);
|
||||
ASSERT_EQ(result, ZE_RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
TEST_F(MemoryTest, whenAllocatingHostMemoryWithDefaultDescriptorThenCachedResourceIsCreated) {
|
||||
size_t size = 10;
|
||||
size_t alignment = 1u;
|
||||
|
||||
Reference in New Issue
Block a user