From 4602220e62894f004ba48cb2a8c7a93048f99973 Mon Sep 17 00:00:00 2001 From: Zbigniew Zdanowicz Date: Wed, 25 Nov 2020 10:31:09 +0100 Subject: [PATCH] Add manager of imported host pointers Related-To: NEO-5126 Signed-off-by: Zbigniew Zdanowicz --- level_zero/core/source/CMakeLists.txt | 2 + level_zero/core/source/driver/driver_handle.h | 7 + .../core/source/driver/driver_handle_imp.cpp | 70 +++- .../core/source/driver/driver_handle_imp.h | 33 +- .../source/driver/host_pointer_manager.cpp | 143 ++++++++ .../core/source/driver/host_pointer_manager.h | 83 +++++ .../test/unit_tests/fixtures/CMakeLists.txt | 1 + .../test/unit_tests/fixtures/device_fixture.h | 1 + .../fixtures/host_pointer_manager_fixture.h | 51 +++ .../core/test/unit_tests/mocks/CMakeLists.txt | 1 + .../test/unit_tests/mocks/mock_cmdlist.cpp | 4 +- .../test/unit_tests/mocks/mock_cmdqueue.cpp | 2 +- .../test/unit_tests/mocks/mock_device.cpp | 2 +- .../test/unit_tests/mocks/mock_driver.cpp | 2 +- .../unit_tests/mocks/mock_driver_handle.cpp | 4 +- .../unit_tests/mocks/mock_driver_handle.h | 23 ++ .../core/test/unit_tests/mocks/mock_event.cpp | 2 +- .../mocks/mock_host_pointer_manager.h | 25 ++ .../test/unit_tests/mocks/mock_module.cpp | 2 +- .../unit_tests/sources/device/test_device.cpp | 1 + .../unit_tests/sources/driver/CMakeLists.txt | 1 + .../driver/host_pointer_manager_tests.cpp | 317 ++++++++++++++++++ .../unit_tests/sources/driver/test_driver.cpp | 1 - .../sources/tracing/test_api_tracing_common.h | 1 + .../test/unit_test/test_files/igdrcl.config | 1 + .../debug_settings/debug_variables_base.inl | 1 + 26 files changed, 759 insertions(+), 22 deletions(-) create mode 100644 level_zero/core/source/driver/host_pointer_manager.cpp create mode 100644 level_zero/core/source/driver/host_pointer_manager.h create mode 100644 level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h create mode 100644 level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h create mode 100644 level_zero/core/test/unit_tests/sources/driver/host_pointer_manager_tests.cpp diff --git a/level_zero/core/source/CMakeLists.txt b/level_zero/core/source/CMakeLists.txt index ccfae37a60..3ed06c9b56 100644 --- a/level_zero/core/source/CMakeLists.txt +++ b/level_zero/core/source/CMakeLists.txt @@ -42,6 +42,8 @@ set(L0_RUNTIME_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/driver/driver.cpp ${CMAKE_CURRENT_SOURCE_DIR}/driver/driver.h ${CMAKE_CURRENT_SOURCE_DIR}/driver/driver_imp.h + ${CMAKE_CURRENT_SOURCE_DIR}/driver/host_pointer_manager.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/driver/host_pointer_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/event/event.cpp ${CMAKE_CURRENT_SOURCE_DIR}/event/event.h ${CMAKE_CURRENT_SOURCE_DIR}/fence/fence.cpp diff --git a/level_zero/core/source/driver/driver_handle.h b/level_zero/core/source/driver/driver_handle.h index 9dfafbcc8c..457e5cd578 100644 --- a/level_zero/core/source/driver/driver_handle.h +++ b/level_zero/core/source/driver/driver_handle.h @@ -70,6 +70,13 @@ struct DriverHandle : _ze_driver_handle_t { virtual NEO::SVMAllocsManager *getSvmAllocsManager() = 0; virtual ze_result_t sysmanEventsListen(uint32_t timeout, uint32_t count, zes_device_handle_t *phDevices, uint32_t *pNumDeviceEvents, zes_event_type_flags_t *pEvents) = 0; + virtual ze_result_t importExternalPointer(void *ptr, size_t size) = 0; + virtual ze_result_t releaseImportedPointer(void *ptr) = 0; + virtual ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) = 0; + + virtual NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) = 0; + virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) = 0; + static DriverHandle *fromHandle(ze_driver_handle_t handle) { return static_cast(handle); } inline ze_driver_handle_t toHandle() { return this; } diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index 44dfc822d2..92af787c1d 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -17,6 +17,7 @@ #include "level_zero/core/source/debugger/debugger_l0.h" #include "level_zero/core/source/device/device_imp.h" #include "level_zero/core/source/driver/driver_imp.h" +#include "level_zero/core/source/driver/host_pointer_manager.h" #include "driver_version_l0.h" @@ -275,6 +276,10 @@ ze_result_t DriverHandleImp::initialize(std::vector uuidTimestamp = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + if (NEO::DebugManager.flags.EnableHostPointerImport.get() == 1) { + createHostPointerManager(); + } + return ZE_RESULT_SUCCESS; } @@ -294,7 +299,7 @@ DriverHandle *DriverHandle::create(std::vector> dev GlobalDriver = driverHandle; - driverHandle->memoryManager->setForceNonSvmForExternalHostPtr(true); + driverHandle->getMemoryManager()->setForceNonSvmForExternalHostPtr(true); return driverHandle; } @@ -392,4 +397,67 @@ ze_result_t DriverHandleImp::openEventPoolIpcHandle(ze_ipc_event_pool_handle_t h return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } +void DriverHandleImp::createHostPointerManager() { + hostPointerManager = std::make_unique(getMemoryManager()); +} + +ze_result_t DriverHandleImp::importExternalPointer(void *ptr, size_t size) { + if (hostPointerManager.get() != nullptr) { + auto ret = hostPointerManager->createHostPointerMultiAllocation(this->devices, + ptr, + size); + return ret; + } + + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ze_result_t DriverHandleImp::releaseImportedPointer(void *ptr) { + if (hostPointerManager.get() != nullptr) { + bool ret = hostPointerManager->freeHostPointerAllocation(ptr); + return ret ? ZE_RESULT_SUCCESS : ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +ze_result_t DriverHandleImp::getHostPointerBaseAddress(void *ptr, void **baseAddress) { + if (hostPointerManager.get() != nullptr) { + auto hostPointerData = hostPointerManager->getHostPointerAllocation(ptr); + if (hostPointerData != nullptr) { + if (baseAddress != nullptr) { + *baseAddress = hostPointerData->basePtr; + } + return ZE_RESULT_SUCCESS; + } + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; +} + +NEO::GraphicsAllocation *DriverHandleImp::findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) { + if (hostPointerManager.get() != nullptr) { + HostPointerData *hostData = hostPointerManager->getHostPointerAllocation(ptr); + if (hostData != nullptr) { + size_t foundEndSize = reinterpret_cast(hostData->basePtr) + hostData->size; + size_t inputEndSize = reinterpret_cast(ptr) + size; + if (foundEndSize >= inputEndSize) { + return hostData->hostPtrAllocations.getGraphicsAllocation(rootDeviceIndex); + } + return nullptr; + } + return nullptr; + } + + return nullptr; +} + +NEO::GraphicsAllocation *DriverHandleImp::getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) { + NEO::SvmAllocationData *allocData = nullptr; + bool allocFound = findAllocationDataForRange(ptr, size, &allocData); + if (allocFound) { + return allocData->gpuAllocations.getGraphicsAllocation(rootDeviceIndex); + } + return findHostPointerAllocation(ptr, size, rootDeviceIndex); +} + } // namespace L0 diff --git a/level_zero/core/source/driver/driver_handle_imp.h b/level_zero/core/source/driver/driver_handle_imp.h index 77986bd9e5..39443945f6 100644 --- a/level_zero/core/source/driver/driver_handle_imp.h +++ b/level_zero/core/source/driver/driver_handle_imp.h @@ -14,6 +14,7 @@ #include "level_zero/extensions/public/ze_exp_ext.h" namespace L0 { +class HostPointerManager; struct DriverHandleImp : public DriverHandle { ~DriverHandleImp() override; @@ -68,25 +69,35 @@ struct DriverHandleImp : public DriverHandle { ze_result_t sysmanEventsListen(uint32_t timeout, uint32_t count, zes_device_handle_t *phDevices, uint32_t *pNumDeviceEvents, zes_event_type_flags_t *pEvents) override; + ze_result_t importExternalPointer(void *ptr, size_t size) override; + ze_result_t releaseImportedPointer(void *ptr) override; + ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) override; + + virtual NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override; + virtual NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override; uint32_t parseAffinityMask(std::vector> &neoDevices); + void createHostPointerManager(); - uint32_t numDevices = 0; - std::vector devices; - NEO::MemoryManager *memoryManager = nullptr; - NEO::SVMAllocsManager *svmAllocsManager = nullptr; - uint64_t uuidTimestamp = 0u; + std::unique_ptr hostPointerManager; + // Experimental functions + std::unordered_map extensionFunctionsLookupMap; - // Environment Variables std::string affinityMaskString = ""; - bool enableProgramDebugging = false; - bool enableSysman = false; - + std::vector devices; // Spec extensions const std::vector> extensionsSupported = { {ZE_MODULE_PROGRAM_EXP_NAME, ZE_MODULE_PROGRAM_EXP_VERSION_CURRENT}}; - // Experimental functions - std::unordered_map extensionFunctionsLookupMap; + uint64_t uuidTimestamp = 0u; + + NEO::MemoryManager *memoryManager = nullptr; + NEO::SVMAllocsManager *svmAllocsManager = nullptr; + + uint32_t numDevices = 0; + + // Environment Variables + bool enableProgramDebugging = false; + bool enableSysman = false; }; extern struct DriverHandleImp *GlobalDriver; diff --git a/level_zero/core/source/driver/host_pointer_manager.cpp b/level_zero/core/source/driver/host_pointer_manager.cpp new file mode 100644 index 0000000000..20809479d2 --- /dev/null +++ b/level_zero/core/source/driver/host_pointer_manager.cpp @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "level_zero/core/source/driver/host_pointer_manager.h" + +#include "shared/source/helpers/aligned_memory.h" +#include "shared/source/helpers/constants.h" +#include "shared/source/memory_manager/allocation_properties.h" +#include "shared/source/memory_manager/graphics_allocation.h" +#include "shared/source/memory_manager/memory_manager.h" +#include "shared/source/memory_manager/multi_graphics_allocation.h" + +#include "level_zero/core/source/device/device_imp.h" + +namespace L0 { + +void HostPointerManager::MapBasedAllocationTracker::insert(HostPointerData allocationsData) { + allocations.insert(std::make_pair(reinterpret_cast(allocationsData.basePtr), allocationsData)); +} + +void HostPointerManager::MapBasedAllocationTracker::remove(const void *ptr) { + HostPointerContainer::iterator iter; + iter = allocations.find(ptr); + allocations.erase(iter); +} + +HostPointerData *HostPointerManager::MapBasedAllocationTracker::get(const void *ptr) { + HostPointerContainer::iterator iter, end; + HostPointerData *hostPtrData; + if ((ptr == nullptr) || (allocations.size() == 0)) { + return nullptr; + } + end = allocations.end(); + iter = allocations.lower_bound(ptr); + if (((iter != end) && (iter->first != ptr)) || + (iter == end)) { + if (iter == allocations.begin()) { + iter = end; + } else { + iter--; + } + } + if (iter != end) { + hostPtrData = &iter->second; + char *charPtr = reinterpret_cast(hostPtrData->basePtr); + if (ptr < (charPtr + hostPtrData->size)) { + return hostPtrData; + } + } + return nullptr; +} + +HostPointerManager::HostPointerManager(NEO::MemoryManager *memoryManager) : memoryManager(memoryManager) { +} + +HostPointerManager::~HostPointerManager() { +} + +ze_result_t HostPointerManager::createHostPointerMultiAllocation(std::vector &devices, void *ptr, size_t size) { + if (size == 0) { + return ZE_RESULT_ERROR_INVALID_ARGUMENT; + } + + void *basePtr = alignDown(ptr, MemoryConstants::pageSize); + size_t endAddress = reinterpret_cast(ptr) + size; + endAddress = alignUp(endAddress, MemoryConstants::pageSize); + size_t totalSize = endAddress - reinterpret_cast(basePtr); + + std::unique_lock lock(this->mtx); + auto baseAllocation = hostPointerAllocations.get(basePtr); + auto endingAllocation = hostPointerAllocations.get(reinterpret_cast(endAddress - 1)); + if (baseAllocation != nullptr && baseAllocation == endingAllocation) { + return ZE_RESULT_SUCCESS; + } + if (baseAllocation != nullptr) { + if (endingAllocation != nullptr) { + return ZE_RESULT_ERROR_OVERLAPPING_REGIONS; + } + return ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE; + } + if (endingAllocation != nullptr) { + UNRECOVERABLE_IF(endingAllocation->basePtr == basePtr); + return ZE_RESULT_ERROR_INVALID_SIZE; + } + + HostPointerData hostData(static_cast(devices.size() - 1)); + hostData.basePtr = basePtr; + hostData.size = totalSize; + for (auto device : devices) { + NEO::GraphicsAllocation *gfxAlloc = createHostPointerAllocation(device->getRootDeviceIndex(), + basePtr, + totalSize, + device->getNEODevice()->getDeviceBitfield()); + if (gfxAlloc == nullptr) { + auto allocations = hostData.hostPtrAllocations.getGraphicsAllocations(); + for (auto &allocation : allocations) { + memoryManager->freeGraphicsMemory(allocation); + } + return ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY; + } + hostData.hostPtrAllocations.addAllocation(gfxAlloc); + } + hostPointerAllocations.insert(hostData); + return ZE_RESULT_SUCCESS; +} + +NEO::GraphicsAllocation *HostPointerManager::createHostPointerAllocation(uint32_t rootDeviceIndex, + void *ptr, + size_t size, + const NEO::DeviceBitfield &deviceBitfield) { + NEO::AllocationProperties properties = {rootDeviceIndex, false, size, + NEO::GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR, + false, deviceBitfield}; + properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = true; + auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, + ptr); + return allocation; +} + +HostPointerData *HostPointerManager::getHostPointerAllocation(const void *ptr) { + std::unique_lock lock(mtx); + return hostPointerAllocations.get(ptr); +} + +bool HostPointerManager::freeHostPointerAllocation(void *ptr) { + std::unique_lock lock(mtx); + HostPointerData *hostPtrData = hostPointerAllocations.get(ptr); + if (hostPtrData == nullptr) { + return false; + } + auto graphicsAllocations = hostPtrData->hostPtrAllocations.getGraphicsAllocations(); + for (auto gpuAllocation : graphicsAllocations) { + memoryManager->freeGraphicsMemory(gpuAllocation); + } + hostPointerAllocations.remove(hostPtrData->basePtr); + return true; +} + +} // namespace L0 diff --git a/level_zero/core/source/driver/host_pointer_manager.h b/level_zero/core/source/driver/host_pointer_manager.h new file mode 100644 index 0000000000..cbe119ea06 --- /dev/null +++ b/level_zero/core/source/driver/host_pointer_manager.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "shared/source/helpers/common_types.h" +#include "shared/source/memory_manager/multi_graphics_allocation.h" +#include "shared/source/utilities/spinlock.h" + +#include + +#include +#include +#include +#include + +namespace NEO { +class GraphicsAllocation; +class MemoryManager; +} // namespace NEO + +namespace L0 { +struct Device; + +struct HostPointerData { + HostPointerData(uint32_t maxRootDeviceIndex) + : hostPtrAllocations(maxRootDeviceIndex), + maxRootDeviceIndex(maxRootDeviceIndex) { + } + HostPointerData(const HostPointerData &hostPtrData) + : HostPointerData(hostPtrData.maxRootDeviceIndex) { + basePtr = hostPtrData.basePtr; + size = hostPtrData.size; + for (auto allocation : hostPtrData.hostPtrAllocations.getGraphicsAllocations()) { + if (allocation) { + this->hostPtrAllocations.addAllocation(allocation); + } + } + } + NEO::MultiGraphicsAllocation hostPtrAllocations; + void *basePtr = nullptr; + size_t size = 0u; + + protected: + const uint32_t maxRootDeviceIndex; +}; + +class HostPointerManager { + public: + class MapBasedAllocationTracker { + friend class HostPointerManager; + + public: + using HostPointerContainer = std::map; + void insert(HostPointerData allocationsData); + void remove(const void *ptr); + HostPointerData *get(const void *ptr); + size_t getNumAllocs() const { return allocations.size(); }; + + protected: + HostPointerContainer allocations; + }; + + HostPointerManager(NEO::MemoryManager *memoryManager); + virtual ~HostPointerManager(); + ze_result_t createHostPointerMultiAllocation(std::vector &devices, void *ptr, size_t size); + HostPointerData *getHostPointerAllocation(const void *ptr); + bool freeHostPointerAllocation(void *ptr); + + protected: + NEO::GraphicsAllocation *createHostPointerAllocation(uint32_t rootDeviceIndex, + void *ptr, + size_t size, + const NEO::DeviceBitfield &deviceBitfield); + + MapBasedAllocationTracker hostPointerAllocations; + NEO::MemoryManager *memoryManager; + NEO::SpinLock mtx; +}; +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/fixtures/CMakeLists.txt b/level_zero/core/test/unit_tests/fixtures/CMakeLists.txt index 0c620eaa80..2e7d90a933 100644 --- a/level_zero/core/test/unit_tests/fixtures/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/fixtures/CMakeLists.txt @@ -11,6 +11,7 @@ set(L0_FIXTURES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/cmdlist_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/device_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/device_fixture.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/host_pointer_manager_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/module_fixture.h ) 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 86a137ece2..b64e08a6e9 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.h @@ -12,6 +12,7 @@ #include "shared/test/unit_test/helpers/default_hw_info.h" #include "shared/test/unit_test/mocks/mock_device.h" +#include "level_zero/core/source/driver/host_pointer_manager.h" #include "level_zero/core/test/unit_tests/mocks/mock_built_ins.h" #include "level_zero/core/test/unit_tests/mocks/mock_context.h" #include "level_zero/core/test/unit_tests/mocks/mock_device.h" diff --git a/level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h b/level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h new file mode 100644 index 0000000000..e65967a741 --- /dev/null +++ b/level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "shared/source/helpers/constants.h" +#include "shared/test/unit_test/helpers/debug_manager_state_restore.h" +#include "shared/test/unit_test/helpers/default_hw_info.h" +#include "shared/test/unit_test/mocks/mock_device.h" + +#include "level_zero/core/test/unit_tests/fixtures/device_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h" +#include "level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h" + +namespace L0 { +namespace ult { + +struct HostPointerManagerFixure { + void SetUp() { + NEO::DeviceVector devices; + neoDevice = NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get()); + auto mockBuiltIns = new MockBuiltins(); + neoDevice->executionEnvironment->rootDeviceEnvironments[0]->builtins.reset(mockBuiltIns); + devices.push_back(std::unique_ptr(neoDevice)); + + DebugManager.flags.EnableHostPointerImport.set(1); + hostDriverHandle = std::make_unique(); + hostDriverHandle->initialize(std::move(devices)); + device = hostDriverHandle->devices[0]; + EXPECT_NE(nullptr, hostDriverHandle->hostPointerManager.get()); + openHostPointerManager = static_cast(hostDriverHandle->hostPointerManager.get()); + heapPointer = hostDriverHandle->getMemoryManager()->allocateSystemMemory(4 * MemoryConstants::pageSize, MemoryConstants::pageSize); + ASSERT_NE(nullptr, heapPointer); + } + + void TearDown() { + hostDriverHandle->getMemoryManager()->freeSystemMemory(heapPointer); + } + L0::ult::HostPointerManager *openHostPointerManager = nullptr; + std::unique_ptr hostDriverHandle; + void *heapPointer = nullptr; + NEO::MockDevice *neoDevice = nullptr; + L0::Device *device = nullptr; +}; + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/mocks/CMakeLists.txt b/level_zero/core/test/unit_tests/mocks/CMakeLists.txt index ff0ca9654c..a61e7f6fb2 100644 --- a/level_zero/core/test/unit_tests/mocks/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/mocks/CMakeLists.txt @@ -25,6 +25,7 @@ set(L0_MOCKS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mock_event.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_event.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_gmm_resource_info_l0.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mock_host_pointer_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_kernel.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_l0_debugger.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_manager.h diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp index c92cf23b0a..bb1b0e1fe9 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.cpp @@ -5,9 +5,7 @@ * */ -#include "mock_cmdlist.h" - -#include "level_zero/core/test/unit_tests/mocks/mock_device.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" namespace L0 { namespace ult { diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.cpp b/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.cpp index e3c964f188..cd9b4b2409 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdqueue.cpp @@ -5,7 +5,7 @@ * */ -#include "mock_cmdqueue.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" #include "shared/source/device/device.h" diff --git a/level_zero/core/test/unit_tests/mocks/mock_device.cpp b/level_zero/core/test/unit_tests/mocks/mock_device.cpp index af4791ae15..c6a52a7e58 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_device.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_device.cpp @@ -5,7 +5,7 @@ * */ -#include "mock_device.h" +#include "level_zero/core/test/unit_tests/mocks/mock_device.h" #include "shared/source/device/device.h" diff --git a/level_zero/core/test/unit_tests/mocks/mock_driver.cpp b/level_zero/core/test/unit_tests/mocks/mock_driver.cpp index 8db329cba2..6748a2aa92 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_driver.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_driver.cpp @@ -5,7 +5,7 @@ * */ -#include "mock_driver.h" +#include "level_zero/core/test/unit_tests/mocks/mock_driver.h" namespace L0 { namespace ult { diff --git a/level_zero/core/test/unit_tests/mocks/mock_driver_handle.cpp b/level_zero/core/test/unit_tests/mocks/mock_driver_handle.cpp index dd7942fa3e..a61dd27b46 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_driver_handle.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_driver_handle.cpp @@ -5,10 +5,12 @@ * */ -#include "mock_driver_handle.h" +#include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h" #include "shared/test/unit_test/mocks/mock_graphics_allocation.h" +#include "level_zero/core/source/driver/host_pointer_manager.h" + namespace L0 { namespace ult { diff --git a/level_zero/core/test/unit_tests/mocks/mock_driver_handle.h b/level_zero/core/test/unit_tests/mocks/mock_driver_handle.h index 933bdeaf62..38baf99e65 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_driver_handle.h +++ b/level_zero/core/test/unit_tests/mocks/mock_driver_handle.h @@ -148,6 +148,29 @@ struct Mock : public DriverHandleImp { size_t size, size_t alignment, void **ptr); + + ze_result_t importExternalPointer(void *ptr, size_t size) override { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ze_result_t releaseImportedPointer(void *ptr) override { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + ze_result_t getHostPointerBaseAddress(void *ptr, void **baseAddress) override { + return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; + } + + NEO::GraphicsAllocation *findHostPointerAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override { + return nullptr; + } + NEO::GraphicsAllocation *getDriverSystemMemoryAllocation(void *ptr, size_t size, uint32_t rootDeviceIndex) override { + auto svmData = svmAllocsManager->getSVMAlloc(ptr); + if (svmData != nullptr) { + return svmData->gpuAllocations.getGraphicsAllocation(rootDeviceIndex); + } + return nullptr; + } }; } // namespace ult diff --git a/level_zero/core/test/unit_tests/mocks/mock_event.cpp b/level_zero/core/test/unit_tests/mocks/mock_event.cpp index 9bf9dcb8eb..f226ef910e 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_event.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_event.cpp @@ -5,7 +5,7 @@ * */ -#include "mock_event.h" +#include "level_zero/core/test/unit_tests/mocks/mock_event.h" #include diff --git a/level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h b/level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h new file mode 100644 index 0000000000..7c41b386e5 --- /dev/null +++ b/level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once +#include "level_zero/core/source/driver/host_pointer_manager.h" +#include "level_zero/core/test/unit_tests/white_box.h" + +namespace L0 { +namespace ult { + +template <> +struct WhiteBox<::L0::HostPointerManager> : public ::L0::HostPointerManager { + using ::L0::HostPointerManager::createHostPointerAllocation; + using ::L0::HostPointerManager::hostPointerAllocations; + using ::L0::HostPointerManager::memoryManager; +}; + +using HostPointerManager = WhiteBox<::L0::HostPointerManager>; + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/mocks/mock_module.cpp b/level_zero/core/test/unit_tests/mocks/mock_module.cpp index 978d9e4ecc..236478e9f7 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_module.cpp +++ b/level_zero/core/test/unit_tests/mocks/mock_module.cpp @@ -5,7 +5,7 @@ * */ -#include "mock_module.h" +#include "level_zero/core/test/unit_tests/mocks/mock_module.h" using ::testing::Return; diff --git a/level_zero/core/test/unit_tests/sources/device/test_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_device.cpp index 142cb7fbb2..7f048527ab 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_device.cpp @@ -15,6 +15,7 @@ #include "test.h" #include "level_zero/core/source/cmdqueue/cmdqueue_imp.h" +#include "level_zero/core/source/driver/host_pointer_manager.h" #include "level_zero/core/test/unit_tests/mocks/mock_driver_handle.h" #include "gtest/gtest.h" diff --git a/level_zero/core/test/unit_tests/sources/driver/CMakeLists.txt b/level_zero/core/test/unit_tests/sources/driver/CMakeLists.txt index d4238619e5..61a3af567a 100644 --- a/level_zero/core/test/unit_tests/sources/driver/CMakeLists.txt +++ b/level_zero/core/test/unit_tests/sources/driver/CMakeLists.txt @@ -6,5 +6,6 @@ target_sources(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt + ${CMAKE_CURRENT_SOURCE_DIR}/host_pointer_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_driver.cpp ) diff --git a/level_zero/core/test/unit_tests/sources/driver/host_pointer_manager_tests.cpp b/level_zero/core/test/unit_tests/sources/driver/host_pointer_manager_tests.cpp new file mode 100644 index 0000000000..db3c8428f2 --- /dev/null +++ b/level_zero/core/test/unit_tests/sources/driver/host_pointer_manager_tests.cpp @@ -0,0 +1,317 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/unit_test/helpers/debug_manager_state_restore.h" + +#include "opencl/test/unit_test/mocks/mock_memory_manager.h" +#include "test.h" + +#include "level_zero/core/source/driver/driver_handle_imp.h" +#include "level_zero/core/test/unit_tests/fixtures/host_pointer_manager_fixture.h" +#include "level_zero/core/test/unit_tests/mocks/mock_host_pointer_manager.h" + +using ::testing::Return; + +namespace L0 { +namespace ult { + +using HostPointerManagerTest = Test; + +TEST_F(HostPointerManagerTest, + givenMultipleGraphicsAllocationWhenCopyingHostPointerDataThenCopyOnlyExistingAllocations) { + HostPointerData originData(4); + auto gfxAllocation = openHostPointerManager->createHostPointerAllocation(device->getRootDeviceIndex(), + heapPointer, + MemoryConstants::pageSize, + device->getNEODevice()->getDeviceBitfield()); + originData.hostPtrAllocations.addAllocation(gfxAllocation); + + HostPointerData copyData(originData); + for (auto allocation : copyData.hostPtrAllocations.getGraphicsAllocations()) { + if (allocation != nullptr) { + EXPECT_EQ(device->getRootDeviceIndex(), allocation->getRootDeviceIndex()); + EXPECT_EQ(gfxAllocation, allocation); + } + } + hostDriverHandle->getMemoryManager()->freeGraphicsMemory(gfxAllocation); +} + +TEST_F(HostPointerManagerTest, givenNoHeapManagerThenReturnFeatureUnsupported) { + hostDriverHandle->hostPointerManager.reset(nullptr); + + void *testPtr = heapPointer; + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, nullptr); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, result); + + auto gfxAllocation = hostDriverHandle->getDriverSystemMemoryAllocation(testPtr, 1u, device->getRootDeviceIndex()); + EXPECT_EQ(nullptr, gfxAllocation); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenSvmAllocationExistsThenRetrieveSvmFirst) { + void *testPtr = heapPointer; + + size_t usmSize = MemoryConstants::pageSize; + void *usmBuffer = hostDriverHandle->getMemoryManager()->allocateSystemMemory(usmSize, usmSize); + NEO::GraphicsAllocation *usmAllocation = hostDriverHandle->getMemoryManager()->allocateGraphicsMemoryWithProperties( + {device->getRootDeviceIndex(), false, usmSize, NEO::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, false, neoDevice->getDeviceBitfield()}, + usmBuffer); + ASSERT_NE(nullptr, usmAllocation); + + NEO::SvmAllocationData allocData(device->getRootDeviceIndex()); + allocData.gpuAllocations.addAllocation(usmAllocation); + allocData.cpuAllocation = nullptr; + allocData.size = usmSize; + allocData.memoryType = InternalMemoryType::NOT_SPECIFIED; + allocData.device = nullptr; + hostDriverHandle->getSvmAllocsManager()->insertSVMAlloc(allocData); + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + auto gfxAllocation = hostDriverHandle->getDriverSystemMemoryAllocation(usmBuffer, 1u, device->getRootDeviceIndex()); + ASSERT_NE(nullptr, gfxAllocation); + EXPECT_EQ(usmBuffer, gfxAllocation->getUnderlyingBuffer()); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + hostDriverHandle->getMemoryManager()->freeGraphicsMemory(usmAllocation); + hostDriverHandle->getMemoryManager()->freeSystemMemory(usmBuffer); +} + +TEST_F(HostPointerManagerTest, WhenSizeIsZeroThenExpectInvalidArgument) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, 0u); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); +} + +TEST_F(HostPointerManagerTest, givenNoPointerWhenImportAddressThenRegisterNewHostData) { + void *testPtr = heapPointer; + void *baseAddress; + + auto result = hostDriverHandle->getHostPointerBaseAddress(testPtr, nullptr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); + + result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, &baseAddress); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(heapPointer, baseAddress); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, nullptr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); +} + +TEST_F(HostPointerManagerTest, givenNoPointerWhenImportMisalignedAddressThenRegisterNewHostData) { + void *testPtr = heapPointer; + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + 0x10); + size_t size = 0x10; + + void *baseAddress; + + auto result = hostDriverHandle->getHostPointerBaseAddress(testPtr, nullptr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); + + result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, &baseAddress); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(heapPointer, baseAddress); + auto hostPointerData = openHostPointerManager->hostPointerAllocations.get(testPtr); + ASSERT_NE(nullptr, hostPointerData); + EXPECT_EQ(MemoryConstants::pageSize, hostPointerData->size); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenBiggerAddressImportedWhenImportingWithinThenReturnSuccess) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + 0x10); + size_t size = 0x10; + + result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(1u, openHostPointerManager->hostPointerAllocations.getNumAllocs()); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, nullptr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenUsingInvalidAddressThenReturnError) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->getHostPointerBaseAddress(nullptr, nullptr); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); + + result = hostDriverHandle->releaseImportedPointer(heapPointer); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenSizeEndsInNoAllocationThenExpectObjectInUseError) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + 0x10); + size_t size = MemoryConstants::pageSize + 0x10; + + result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_ERROR_HANDLE_OBJECT_IN_USE, result); + + result = hostDriverHandle->releaseImportedPointer(heapPointer); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenSizeEndsInDifferentAllocationThenExpectOverlappingError) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + MemoryConstants::pageSize); + size_t size = MemoryConstants::pageSize; + + result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + void *errorPtr = reinterpret_cast(reinterpret_cast(heapPointer) + 0x10); + result = hostDriverHandle->importExternalPointer(errorPtr, size); + EXPECT_EQ(ZE_RESULT_ERROR_OVERLAPPING_REGIONS, result); + + result = hostDriverHandle->releaseImportedPointer(heapPointer); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerNotRegisteredWhenSizeEndsInDifferentAllocationThenExpectInvalidSizeError) { + void *testPtr = reinterpret_cast(reinterpret_cast(heapPointer) + MemoryConstants::pageSize); + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + void *errorPtr = reinterpret_cast(reinterpret_cast(heapPointer) + 0x10); + size_t size = MemoryConstants::pageSize; + result = hostDriverHandle->importExternalPointer(errorPtr, size); + EXPECT_EQ(ZE_RESULT_ERROR_INVALID_SIZE, result); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerUsesTwoPagesThenBothPagesAreAvailableAndSizeIsCorrect) { + void *testPtr = heapPointer; + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + 0x10); + size_t size = MemoryConstants::pageSize; + + void *baseAddress; + + auto result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, &baseAddress); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(heapPointer, baseAddress); + auto hostPointerData = openHostPointerManager->hostPointerAllocations.get(testPtr); + ASSERT_NE(nullptr, hostPointerData); + EXPECT_EQ(2 * MemoryConstants::pageSize, hostPointerData->size); + + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + MemoryConstants::pageSize); + size = 0x010; + + result = hostDriverHandle->importExternalPointer(testPtr, size); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + result = hostDriverHandle->getHostPointerBaseAddress(testPtr, &baseAddress); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(heapPointer, baseAddress); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenSizeFitsThenReturnGraphicsAllocation) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + auto gfxAllocation = hostDriverHandle->findHostPointerAllocation(testPtr, 0x10u, device->getRootDeviceIndex()); + EXPECT_NE(nullptr, gfxAllocation); + EXPECT_EQ(testPtr, gfxAllocation->getUnderlyingBuffer()); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerNotRegisteredThenReturnNullptrGraphicsAllocation) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + testPtr = reinterpret_cast(reinterpret_cast(testPtr) + MemoryConstants::pageSize); + auto gfxAllocation = hostDriverHandle->findHostPointerAllocation(testPtr, 0x10u, device->getRootDeviceIndex()); + EXPECT_EQ(nullptr, gfxAllocation); + + result = hostDriverHandle->releaseImportedPointer(heapPointer); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenPointerRegisteredWhenSizeExceedsAllocationThenReturnNullptrGraphicsAllocation) { + void *testPtr = heapPointer; + + auto result = hostDriverHandle->importExternalPointer(testPtr, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + + auto gfxAllocation = hostDriverHandle->findHostPointerAllocation(testPtr, MemoryConstants::pageSize + 0x10u, device->getRootDeviceIndex()); + EXPECT_EQ(nullptr, gfxAllocation); + + result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + +TEST_F(HostPointerManagerTest, givenNoPointerRegisteredWhenAllocationCreationFailThenExpectOutOfMemoryError) { + std::unique_ptr failMemoryManager = std::make_unique(0, *neoDevice->executionEnvironment); + openHostPointerManager->memoryManager = failMemoryManager.get(); + + auto result = hostDriverHandle->importExternalPointer(heapPointer, MemoryConstants::pageSize); + EXPECT_EQ(ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, result); +} + +} // namespace ult +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp index ae480a1282..402b070665 100644 --- a/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp +++ b/level_zero/core/test/unit_tests/sources/driver/test_driver.cpp @@ -654,6 +654,5 @@ TEST(zeDriverGetIpcProperties, whenZeDriverGetIpcPropertiesIsCalledThenGetIPCPro result = zeDriverGetIpcProperties(driverHandle.toHandle(), &ipcProperties); EXPECT_EQ(ZE_RESULT_SUCCESS, result); } - } // namespace ult } // namespace L0 diff --git a/level_zero/experimental/test/unit_tests/sources/tracing/test_api_tracing_common.h b/level_zero/experimental/test/unit_tests/sources/tracing/test_api_tracing_common.h index 5cb4c23e4a..a75429d807 100644 --- a/level_zero/experimental/test/unit_tests/sources/tracing/test_api_tracing_common.h +++ b/level_zero/experimental/test/unit_tests/sources/tracing/test_api_tracing_common.h @@ -8,6 +8,7 @@ #pragma once #include "level_zero/core/source/device/device_imp.h" #include "level_zero/core/source/driver/driver_handle_imp.h" +#include "level_zero/core/source/driver/host_pointer_manager.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" #include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" #include "level_zero/core/test/unit_tests/mocks/mock_device.h" diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index b2e286afca..288cda69ee 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -205,5 +205,6 @@ UseBindlessMode = -1 MediaVfeStateMaxSubSlices = -1 PrintBlitDispatchDetails = 0 EnableMockSourceLevelDebugger = 0 +EnableHostPointerImport = -1 EnableHostUsmSupport = -1 ForceBtpPrefetchMode = -1 \ No newline at end of file diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 9e01bd24be..7eb4e387f0 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -84,6 +84,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableHostUsmSupport, -1, "-1: default, 0: disab DECLARE_DEBUG_VARIABLE(int32_t, MediaVfeStateMaxSubSlices, -1, ">=0: Programs Media Vfe State Maximum Number of Dual-Subslices to given value ") DECLARE_DEBUG_VARIABLE(int32_t, EnableMockSourceLevelDebugger, 0, "Switches driver to mode with active debugger. Active modes: 1: opt-disabled, 2: opt-enabled") DECLARE_DEBUG_VARIABLE(int32_t, ForceBtpPrefetchMode, -1, "-1: default, 0: disable, 1: enable, Enables Btp prefetching") +DECLARE_DEBUG_VARIABLE(int32_t, EnableHostPointerImport, -1, "-1: default - disabled, 0: disabled, 1: enabled, Experimental implementation to import Host Pointer into L0") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")