Skip to content

Commit aa51c5e

Browse files
Jaime ArteagaCompute-Runtime-Automation
Jaime Arteaga
authored andcommitted
Add support for ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
1 parent 64eb82e commit aa51c5e

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

level_zero/core/source/memory/memory.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ void *DriverHandleImp::importFdHandle(ze_device_handle_t hDevice, ze_ipc_memory_
4242
allocData.allocationFlagsProperty.flags.locallyUncachedResource = 1;
4343
}
4444

45+
if (flags & ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED) {
46+
allocData.allocationFlagsProperty.flags.locallyUncachedResource = 1;
47+
}
48+
4549
this->getSvmAllocsManager()->insertSVMAlloc(allocData);
4650

4751
if (pAlloc) {

level_zero/core/test/unit_tests/sources/memory/test_memory.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,32 @@ TEST_F(ImportFdUncachedTests,
24542454
context->freeMem(ptr);
24552455
}
24562456

2457+
TEST_F(ImportFdUncachedTests,
2458+
givenCallToImportFdHandleWithUncachedIpcFlagsThenLocallyUncachedResourceIsSet) {
2459+
ze_ipc_memory_flags_t flags = ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED;
2460+
uint64_t handle = 1;
2461+
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle, nullptr);
2462+
EXPECT_NE(nullptr, ptr);
2463+
2464+
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
2465+
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 1u);
2466+
2467+
context->freeMem(ptr);
2468+
}
2469+
2470+
TEST_F(ImportFdUncachedTests,
2471+
givenCallToImportFdHandleWithBothUncachedFlagsThenLocallyUncachedResourceIsSet) {
2472+
ze_ipc_memory_flags_t flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED | ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED;
2473+
uint64_t handle = 1;
2474+
void *ptr = driverHandle->importFdHandle(device->toHandle(), flags, handle, nullptr);
2475+
EXPECT_NE(nullptr, ptr);
2476+
2477+
auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr);
2478+
EXPECT_EQ(allocData->allocationFlagsProperty.flags.locallyUncachedResource, 1u);
2479+
2480+
context->freeMem(ptr);
2481+
}
2482+
24572483
TEST_F(ImportFdUncachedTests,
24582484
givenCallToImportFdHandleWithoutUncachedFlagsThenLocallyUncachedResourceIsNotSet) {
24592485
ze_ipc_memory_flags_t flags = {};

0 commit comments

Comments
 (0)