Create resource with given address

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2022-02-23 14:06:22 +00:00
committed by Compute-Runtime-Automation
parent 4cdc4ff9c8
commit 0634aa3f1b
8 changed files with 33 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -99,6 +99,7 @@ using cl_unified_shared_memory_capabilities_intel = cl_bitfield;
/* cl_mem_properties_intel */
#define CL_MEM_ALLOC_FLAGS_INTEL 0x4195
#define CL_MEM_ALLOC_USE_HOST_PTR_INTEL 0x1000F
/* cl_mem_alloc_flags_intel - bitfield */
#define CL_MEM_ALLOC_DEFAULT_INTEL 0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 Intel Corporation
* Copyright (C) 2021-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -16,7 +16,7 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel,
cl_mem_alloc_flags_intel &allocflags, MemoryPropertiesHelper::ObjType objectType, Context &context) {
Device *pDevice = &context.getDevice(0)->getDevice();
uintptr_t hostptr = 0;
if (properties != nullptr) {
for (int i = 0; properties[i] != 0; i += 2) {
switch (properties[i]) {
@@ -29,6 +29,9 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
case CL_MEM_ALLOC_FLAGS_INTEL:
allocflags |= static_cast<cl_mem_alloc_flags_intel>(properties[i + 1]);
break;
case CL_MEM_ALLOC_USE_HOST_PTR_INTEL:
hostptr = static_cast<uintptr_t>(properties[i + 1]);
break;
default:
return false;
}
@@ -36,6 +39,7 @@ bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_int
}
memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags, pDevice);
memoryProperties.hostptr = hostptr;
switch (objectType) {
case MemoryPropertiesHelper::ObjType::BUFFER:

View File

@@ -4792,6 +4792,19 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWithoutLocalMemoryAndCpuPtrWhe
memoryManager.freeGraphicsMemory(allocation);
}
TEST_F(DrmMemoryManagerTest, givenNullDefaultAllocWhenCreateGraphicsAllocationFromExistingStorageThenDoNotImportHandle) {
TestedDrmMemoryManager memoryManager(false, false, false, *executionEnvironment);
mock->ioctl_expected.primeFdToHandle = 0;
MockAllocationProperties properties(0u, 1u);
MultiGraphicsAllocation allocation(0u);
auto alloc = memoryManager.createGraphicsAllocationFromExistingStorage(properties, nullptr, allocation);
EXPECT_NE(alloc, nullptr);
memoryManager.freeGraphicsMemory(alloc);
}
TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenAllocateInDevicePoolIsCalledThenNullptrAndStatusRetryIsReturned) {
MockExecutionEnvironment executionEnvironment(defaultHwInfo.get());
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();