From 050e4fb1daa4b5db9e7c24225897cbb3526382e9 Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Thu, 15 Dec 2022 03:59:35 +0000 Subject: [PATCH] Pass allocation type to import handle functions This to allow flexibilty on choosing the allocation type from the callers in layers above on the driver. Signed-off-by: Jaime Arteaga --- level_zero/core/source/context/context.h | 3 ++- level_zero/core/source/context/context_imp.cpp | 14 +++++++++++--- level_zero/core/source/context/context_imp.h | 2 +- .../core/source/context/context_imp_drm.cpp | 4 ++-- .../source/context/context_imp_drm_or_wddm.cpp | 15 ++++++++++++--- .../core/source/context/context_imp_wddm.cpp | 4 ++-- .../core/source/driver/driver_handle_imp.cpp | 16 ++++++++++++---- .../core/source/driver/driver_handle_imp.h | 4 ++-- .../test/unit_tests/fixtures/device_fixture.h | 4 ++-- .../unit_tests/fixtures/memory_ipc_fixture.h | 12 +++++++----- .../sources/context/test_context_drm.cpp | 4 ++-- .../sources/context/test_context_drm_or_wddm.cpp | 10 +++++----- .../sources/context/test_context_wddm.cpp | 4 ++-- .../sources/memory/linux/test_memory_linux.cpp | 2 +- .../unit_tests/sources/memory/test_memory.cpp | 12 ++++++------ .../sources/memory/test_memory_drm.cpp | 2 ++ 16 files changed, 71 insertions(+), 41 deletions(-) diff --git a/level_zero/core/source/context/context.h b/level_zero/core/source/context/context.h index 546c063c5c..86ed990f57 100644 --- a/level_zero/core/source/context/context.h +++ b/level_zero/core/source/context/context.h @@ -7,6 +7,7 @@ #pragma once +#include "shared/source/memory_manager/allocation_type.h" #include "shared/source/unified_memory/unified_memory.h" #include @@ -154,7 +155,7 @@ struct Context : _ze_context_handle_t { const ze_image_desc_t *desc, ze_image_handle_t *phImage) = 0; virtual bool isShareableMemory(const void *exportDesc, bool exportableMemory, NEO::Device *neoDevice) = 0; - virtual void *getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, ze_ipc_memory_flags_t flags) = 0; + virtual void *getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) = 0; static Context *fromHandle(ze_context_handle_t handle) { return static_cast(handle); } inline ze_context_handle_t toHandle() { return this; } diff --git a/level_zero/core/source/context/context_imp.cpp b/level_zero/core/source/context/context_imp.cpp index fd87336e96..bb56b1baae 100644 --- a/level_zero/core/source/context/context_imp.cpp +++ b/level_zero/core/source/context/context_imp.cpp @@ -136,13 +136,18 @@ ze_result_t ContextImp::allocDeviceMem(ze_device_handle_t hDevice, if (lookupTable.isSharedHandle) { if (lookupTable.sharedHandleType.isDMABUFHandle) { ze_ipc_memory_flags_t flags = {}; - *ptr = getMemHandlePtr(hDevice, lookupTable.sharedHandleType.fd, flags); + *ptr = getMemHandlePtr(hDevice, + lookupTable.sharedHandleType.fd, + NEO::AllocationType::BUFFER, + flags); if (nullptr == *ptr) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; } } else { UNRECOVERABLE_IF(!lookupTable.sharedHandleType.isNTHandle); - *ptr = this->driverHandle->importNTHandle(hDevice, lookupTable.sharedHandleType.ntHnadle); + *ptr = this->driverHandle->importNTHandle(hDevice, + lookupTable.sharedHandleType.ntHnadle, + NEO::AllocationType::BUFFER); if (*ptr == nullptr) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; } @@ -498,7 +503,10 @@ ze_result_t ContextImp::openIpcMemHandle(ze_device_handle_t hDevice, pIpcHandle.data, sizeof(handle)); - *ptr = getMemHandlePtr(hDevice, handle, flags); + *ptr = getMemHandlePtr(hDevice, + handle, + NEO::AllocationType::BUFFER, + flags); if (nullptr == *ptr) { return ZE_RESULT_ERROR_INVALID_ARGUMENT; } diff --git a/level_zero/core/source/context/context_imp.h b/level_zero/core/source/context/context_imp.h index 276b8fdb21..8793e649b2 100644 --- a/level_zero/core/source/context/context_imp.h +++ b/level_zero/core/source/context/context_imp.h @@ -151,7 +151,7 @@ struct ContextImp : Context { bool isDeviceDefinedForThisContext(Device *inDevice); bool isShareableMemory(const void *exportDesc, bool exportableMemory, NEO::Device *neoDevice) override; - void *getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, ze_ipc_memory_flags_t flags) override; + void *getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) override; void initDeviceHandles(uint32_t numDevices, ze_device_handle_t *deviceHandles) { this->numDevices = numDevices; diff --git a/level_zero/core/source/context/context_imp_drm.cpp b/level_zero/core/source/context/context_imp_drm.cpp index 81dfa7f89b..4e07f14902 100644 --- a/level_zero/core/source/context/context_imp_drm.cpp +++ b/level_zero/core/source/context/context_imp_drm.cpp @@ -18,8 +18,8 @@ bool ContextImp::isShareableMemory(const void *exportDesc, bool exportableMemory return false; } -void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, ze_ipc_memory_flags_t flags) { - return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(), flags, handle, nullptr); +void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) { + return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(), flags, handle, allocationType, nullptr); } } // namespace L0 diff --git a/level_zero/core/source/context/context_imp_drm_or_wddm.cpp b/level_zero/core/source/context/context_imp_drm_or_wddm.cpp index a3e9c5a874..4ed7573db5 100644 --- a/level_zero/core/source/context/context_imp_drm_or_wddm.cpp +++ b/level_zero/core/source/context/context_imp_drm_or_wddm.cpp @@ -28,7 +28,10 @@ bool ContextImp::isShareableMemory(const void *exportDesc, bool exportableMemory return false; } -void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, ze_ipc_memory_flags_t flags) { +void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, + uint64_t handle, + NEO::AllocationType allocationType, + ze_ipc_memory_flags_t flags) { L0::Device *device = L0::Device::fromHandle(hDevice); auto neoDevice = device->getNEODevice(); NEO::DriverModelType driverType = NEO::DriverModelType::UNKNOWN; @@ -37,9 +40,15 @@ void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, z } bool isNTHandle = this->getDriverHandle()->getMemoryManager()->isNTHandle(NEO::toOsHandle(reinterpret_cast(handle)), device->getNEODevice()->getRootDeviceIndex()); if (isNTHandle) { - return this->driverHandle->importNTHandle(hDevice, reinterpret_cast(handle)); + return this->driverHandle->importNTHandle(hDevice, + reinterpret_cast(handle), + allocationType); } else if (driverType == NEO::DriverModelType::DRM) { - return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(), flags, handle, nullptr); + return this->driverHandle->importFdHandle(Device::fromHandle(hDevice)->getNEODevice(), + flags, + handle, + allocationType, + nullptr); } else { return nullptr; } diff --git a/level_zero/core/source/context/context_imp_wddm.cpp b/level_zero/core/source/context/context_imp_wddm.cpp index 1e6d25316d..fdb7d64d7d 100644 --- a/level_zero/core/source/context/context_imp_wddm.cpp +++ b/level_zero/core/source/context/context_imp_wddm.cpp @@ -18,8 +18,8 @@ bool ContextImp::isShareableMemory(const void *exportDesc, bool exportableMemory return false; } -void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, ze_ipc_memory_flags_t flags) { - return this->driverHandle->importNTHandle(hDevice, reinterpret_cast(handle)); +void *ContextImp::getMemHandlePtr(ze_device_handle_t hDevice, uint64_t handle, NEO::AllocationType allocationType, ze_ipc_memory_flags_t flags) { + return this->driverHandle->importNTHandle(hDevice, reinterpret_cast(handle), allocationType); } } // namespace L0 diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index b0deb47ae8..8633a82a71 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -462,11 +462,15 @@ bool DriverHandleImp::isRemoteResourceNeeded(void *ptr, NEO::GraphicsAllocation return (alloc == nullptr || (allocData && ((allocData->gpuAllocations.getGraphicsAllocations().size() - 1) < device->getRootDeviceIndex()))); } -void *DriverHandleImp::importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAlloc) { +void *DriverHandleImp::importFdHandle(NEO::Device *neoDevice, + ze_ipc_memory_flags_t flags, + uint64_t handle, + NEO::AllocationType allocationType, + NEO::GraphicsAllocation **pAlloc) { NEO::osHandle osHandle = static_cast(handle); NEO::AllocationProperties unifiedMemoryProperties{neoDevice->getRootDeviceIndex(), MemoryConstants::pageSize, - NEO::AllocationType::BUFFER, + allocationType, neoDevice->getDeviceBitfield()}; unifiedMemoryProperties.subDevicesBitfield = neoDevice->getDeviceBitfield(); NEO::GraphicsAllocation *alloc = @@ -586,7 +590,11 @@ NEO::GraphicsAllocation *DriverHandleImp::getPeerAllocation(Device *device, if (ret < 0) { return nullptr; } - peerPtr = this->importFdHandle(device->getNEODevice(), flags, handle, &alloc); + peerPtr = this->importFdHandle(device->getNEODevice(), + flags, + handle, + NEO::AllocationType::BUFFER, + &alloc); } if (peerPtr == nullptr) { @@ -604,7 +612,7 @@ NEO::GraphicsAllocation *DriverHandleImp::getPeerAllocation(Device *device, return alloc; } -void *DriverHandleImp::importNTHandle(ze_device_handle_t hDevice, void *handle) { +void *DriverHandleImp::importNTHandle(ze_device_handle_t hDevice, void *handle, NEO::AllocationType allocationType) { auto neoDevice = Device::fromHandle(hDevice)->getNEODevice(); auto alloc = this->getMemoryManager()->createGraphicsAllocationFromNTHandle(handle, neoDevice->getRootDeviceIndex(), NEO::AllocationType::SHARED_BUFFER); diff --git a/level_zero/core/source/driver/driver_handle_imp.h b/level_zero/core/source/driver/driver_handle_imp.h index 175800aec5..a94293977f 100644 --- a/level_zero/core/source/driver/driver_handle_imp.h +++ b/level_zero/core/source/driver/driver_handle_imp.h @@ -39,9 +39,9 @@ struct DriverHandleImp : public DriverHandle { NEO::MemoryManager *getMemoryManager() override; void setMemoryManager(NEO::MemoryManager *memoryManager) override; - MOCKABLE_VIRTUAL void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAlloc); + MOCKABLE_VIRTUAL void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAlloc); MOCKABLE_VIRTUAL void *importFdHandles(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, const std::vector &handles, NEO::GraphicsAllocation **pAlloc); - MOCKABLE_VIRTUAL void *importNTHandle(ze_device_handle_t hDevice, void *handle); + MOCKABLE_VIRTUAL void *importNTHandle(ze_device_handle_t hDevice, void *handle, NEO::AllocationType allocationType); ze_result_t checkMemoryAccessFromDevice(Device *device, const void *ptr) override; NEO::SVMAllocsManager *getSvmAllocsManager() override; ze_result_t initialize(std::vector> neoDevices); diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.h b/level_zero/core/test/unit_tests/fixtures/device_fixture.h index a9048e9812..139fc53b00 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.h @@ -49,14 +49,14 @@ struct DeviceFixture { }; struct DriverHandleGetMemHandlePtrMock : public L0::DriverHandleImp { - void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAloc) override { + void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAloc) override { if (failHandleLookup) { return nullptr; } return &mockFd; } - void *importNTHandle(ze_device_handle_t hDevice, void *handle) override { + void *importNTHandle(ze_device_handle_t hDevice, void *handle, NEO::AllocationType allocationType) override { if (failHandleLookup) { return nullptr; } diff --git a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h index 94a4528fcf..dc49307beb 100644 --- a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h @@ -37,7 +37,8 @@ namespace L0 { namespace ult { struct DriverHandleGetFdMock : public L0::DriverHandleImp { - void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAloc) override { + void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAloc) override { + this->allocationTypeRequested = allocationType; if (mockFd == allocationMap.second) { return allocationMap.first; } @@ -46,6 +47,7 @@ struct DriverHandleGetFdMock : public L0::DriverHandleImp { const int mockFd = 57; std::pair allocationMap; + NEO::AllocationType allocationTypeRequested = NEO::AllocationType::UNKNOWN; }; struct ContextFdMock : public L0::ContextImp { @@ -136,13 +138,13 @@ struct MemoryExportImportTest : public ::testing::Test { }; struct DriverHandleGetMemHandleMock : public L0::DriverHandleImp { - void *importNTHandle(ze_device_handle_t hDevice, void *handle) override { + void *importNTHandle(ze_device_handle_t hDevice, void *handle, NEO::AllocationType allocationType) override { if (mockHandle == allocationHandleMap.second) { return allocationHandleMap.first; } return nullptr; } - void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAloc) override { + void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAloc) override { if (mockFd == allocationFdMap.second) { return allocationFdMap.first; } @@ -252,7 +254,7 @@ struct MemoryExportImportWSLTest : public ::testing::Test { }; struct DriverHandleGetWinHandleMock : public L0::DriverHandleImp { - void *importNTHandle(ze_device_handle_t hDevice, void *handle) override { + void *importNTHandle(ze_device_handle_t hDevice, void *handle, NEO::AllocationType allocationType) override { if (mockHandle == allocationMap.second) { return allocationMap.first; } @@ -344,7 +346,7 @@ struct MemoryExportImportWinHandleTest : public ::testing::Test { }; struct DriverHandleGetIpcHandleMock : public DriverHandleImp { - void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAlloc) override { + void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAlloc) override { EXPECT_EQ(handle, static_cast(mockFd)); if (mockFd == allocationMap.second) { return allocationMap.first; diff --git a/level_zero/core/test/unit_tests/sources/context/test_context_drm.cpp b/level_zero/core/test/unit_tests/sources/context/test_context_drm.cpp index 835307a47b..380288d6cc 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context_drm.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context_drm.cpp @@ -52,7 +52,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithValidHandleThenSuccess // Test Successfully returning fd Handle fixtureMemoryManager->NTHandle = false; - EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullptrIsReturned) { @@ -64,7 +64,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullp // Test Failing returning fd Handle fixtureMemoryManager->NTHandle = false; - EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } } // namespace ult diff --git a/level_zero/core/test/unit_tests/sources/context/test_context_drm_or_wddm.cpp b/level_zero/core/test/unit_tests/sources/context/test_context_drm_or_wddm.cpp index e2fbab4508..884706555c 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context_drm_or_wddm.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context_drm_or_wddm.cpp @@ -65,7 +65,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithValidNTHandleThenSucce // Test Successfully returning NT Handle fixtureMemoryManager->NTHandle = true; - EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullptrIsReturned) { @@ -77,11 +77,11 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullp // Test Failing returning NT Handle fixtureMemoryManager->NTHandle = true; - EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); // Test Failing returning fd Handle fixtureMemoryManager->NTHandle = false; - EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithDRMDriverTypeWithNonNTHandleThenSuccessIsReturned) { @@ -92,7 +92,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithDRMDriverTypeWithNonNT // Test Successfully returning fd Handle fixtureMemoryManager->NTHandle = false; - EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithWDDMDriverTypeWithNonNTHandleThenNullPtrIsReturned) { @@ -103,7 +103,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithWDDMDriverTypeWithNonN // Test Successfully returning fd Handle fixtureMemoryManager->NTHandle = false; - EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } } // namespace ult diff --git a/level_zero/core/test/unit_tests/sources/context/test_context_wddm.cpp b/level_zero/core/test/unit_tests/sources/context/test_context_wddm.cpp index 480542139f..7d59e1880d 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context_wddm.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context_wddm.cpp @@ -52,7 +52,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithValidHandleThenSuccess // Test Successfully returning NT Handle fixtureMemoryManager->NTHandle = true; - EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_NE(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullptrIsReturned) { @@ -64,7 +64,7 @@ TEST_F(GetMemHandlePtrTest, whenCallingGetMemHandlePtrWithInvalidHandleThenNullp // Test Failing returning NT Handle fixtureMemoryManager->NTHandle = true; - EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, 0)); + EXPECT_EQ(nullptr, context->getMemHandlePtr(device, handle, NEO::AllocationType::BUFFER, 0)); } } // namespace ult diff --git a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp index c84160b623..d4d2d22ce8 100644 --- a/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/linux/test_memory_linux.cpp @@ -601,7 +601,7 @@ class MemoryManagerIpcObtainFdMock : public NEO::DrmMemoryManager { }; struct DriverHandleObtaindFdMock : public L0::DriverHandleImp { - void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAloc) override { + void *importFdHandle(NEO::Device *neoDevice, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAloc) override { DeviceBitfield deviceBitfield{0x0}; AllocationProperties properties(0, MemoryConstants::pageSize, AllocationType::BUFFER, diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp index 5d572ada53..5eb26837a8 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory.cpp @@ -306,7 +306,7 @@ TEST_F(MemoryExportImportImplicitScalingTest, ze_ipc_memory_flags_t flags = {}; NEO::GraphicsAllocation *ipcAlloc = nullptr; DriverHandleImp *driverHandleImp = static_cast(context->getDriverHandle()); - void *ipcPtr = driverHandleImp->importFdHandle(device->getNEODevice(), flags, handle, &ipcAlloc); + void *ipcPtr = driverHandleImp->importFdHandle(device->getNEODevice(), flags, handle, NEO::AllocationType::BUFFER, &ipcAlloc); EXPECT_EQ(ipcPtr, nullptr); result = context->freeMem(ptr); @@ -1628,7 +1628,7 @@ TEST_F(ContextMemoryTests, givenMultipleSubDevicesWhenAllocatingThenUseCorrectGl } struct DriverHandleFailGetFdMock : public L0::DriverHandleImp { - void *importFdHandle(NEO::Device *neoDevicee, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::GraphicsAllocation **pAloc) override { + void *importFdHandle(NEO::Device *neoDevicee, ze_ipc_memory_flags_t flags, uint64_t handle, NEO::AllocationType allocationType, NEO::GraphicsAllocation **pAloc) override { importFdHandleCalledTimes++; if (mockFd == allocationMap.second) { return allocationMap.first; @@ -3763,7 +3763,7 @@ TEST_F(ImportFdUncachedTests, givenCallToImportFdHandleWithUncachedFlagsThenLocallyUncachedResourceIsSet) { ze_ipc_memory_flags_t flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED; uint64_t handle = 1; - void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, nullptr); + void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, NEO::AllocationType::BUFFER, nullptr); EXPECT_NE(nullptr, ptr); auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr); @@ -3776,7 +3776,7 @@ TEST_F(ImportFdUncachedTests, givenCallToImportFdHandleWithUncachedIpcFlagsThenLocallyUncachedResourceIsSet) { ze_ipc_memory_flags_t flags = ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED; uint64_t handle = 1; - void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, nullptr); + void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, NEO::AllocationType::BUFFER, nullptr); EXPECT_NE(nullptr, ptr); auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr); @@ -3789,7 +3789,7 @@ TEST_F(ImportFdUncachedTests, givenCallToImportFdHandleWithBothUncachedFlagsThenLocallyUncachedResourceIsSet) { ze_ipc_memory_flags_t flags = ZE_DEVICE_MEM_ALLOC_FLAG_BIAS_UNCACHED | ZE_IPC_MEMORY_FLAG_BIAS_UNCACHED; uint64_t handle = 1; - void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, nullptr); + void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, NEO::AllocationType::BUFFER, nullptr); EXPECT_NE(nullptr, ptr); auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr); @@ -3802,7 +3802,7 @@ TEST_F(ImportFdUncachedTests, givenCallToImportFdHandleWithoutUncachedFlagsThenLocallyUncachedResourceIsNotSet) { ze_ipc_memory_flags_t flags = {}; uint64_t handle = 1; - void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, nullptr); + void *ptr = driverHandle->importFdHandle(device->getNEODevice(), flags, handle, NEO::AllocationType::BUFFER, nullptr); EXPECT_NE(nullptr, ptr); auto allocData = driverHandle->svmAllocsManager->getSVMAlloc(ptr); diff --git a/level_zero/core/test/unit_tests/sources/memory/test_memory_drm.cpp b/level_zero/core/test/unit_tests/sources/memory/test_memory_drm.cpp index 4e4da5a116..8837c73755 100644 --- a/level_zero/core/test/unit_tests/sources/memory/test_memory_drm.cpp +++ b/level_zero/core/test/unit_tests/sources/memory/test_memory_drm.cpp @@ -281,6 +281,8 @@ TEST_F(MemoryExportImportTest, size, alignment, &importedPtr); EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(driverHandle->allocationTypeRequested, NEO::AllocationType::BUFFER); + result = context->freeMem(ptr); EXPECT_EQ(ZE_RESULT_SUCCESS, result); }