From c2dbaee128cb5c0d858492b8728c0e7d5dce3380 Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Tue, 25 May 2021 12:23:49 +0000 Subject: [PATCH] Add force host pointer import debug variable. Signed-off-by: Michal Mrozek --- level_zero/core/source/driver/driver_handle_imp.cpp | 5 +++++ .../unit_tests/sources/cmdlist/test_cmdlist_3.cpp | 13 +++++++++++++ opencl/test/unit_test/test_files/igdrcl.config | 3 ++- .../source/debug_settings/debug_variables_base.inl | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/level_zero/core/source/driver/driver_handle_imp.cpp b/level_zero/core/source/driver/driver_handle_imp.cpp index c5fb948dd4..fa2e8291c3 100644 --- a/level_zero/core/source/driver/driver_handle_imp.cpp +++ b/level_zero/core/source/driver/driver_handle_imp.cpp @@ -354,6 +354,11 @@ NEO::GraphicsAllocation *DriverHandleImp::findHostPointerAllocation(void *ptr, s } return nullptr; } + + if (NEO::DebugManager.flags.ForceHostPointerImport.get() == 1) { + importExternalPointer(ptr, size); + return hostPointerManager->getHostPointerAllocation(ptr)->hostPtrAllocations.getGraphicsAllocation(rootDeviceIndex); + } return nullptr; } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp index 6da9748e69..0e7f65deb6 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_3.cpp @@ -1511,5 +1511,18 @@ HWTEST2_F(HostPointerManagerCommandListTest, givenImmediateCommandListWhenMemory commandList->cmdQImmediate = nullptr; } +HWTEST2_F(HostPointerManagerCommandListTest, givenDebugModeToRegisterAllHostPointerWhenFindIsCalledThenRegisterHappens, Platforms) { + DebugManagerStateRestore restorer; + DebugManager.flags.ForceHostPointerImport.set(1); + void *testPtr = heapPointer; + + auto gfxAllocation = hostDriverHandle->findHostPointerAllocation(testPtr, 0x10u, device->getRootDeviceIndex()); + EXPECT_NE(nullptr, gfxAllocation); + EXPECT_EQ(testPtr, gfxAllocation->getUnderlyingBuffer()); + + auto result = hostDriverHandle->releaseImportedPointer(testPtr); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); +} + } // namespace ult } // namespace L0 diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index ae5affc4ef..bd5b6c13c2 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -243,4 +243,5 @@ AlignLocalMemoryVaTo2MB = -1 EngineInstancedSubDevices = 0 OverrideTimestampPacketSize = -1 ClDeviceGlobalMemSizeAvailablePercent = -1 -DebugApiUsed = 0 \ No newline at end of file +DebugApiUsed = 0 +ForceHostPointerImport = -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 eb210d77be..1a3885164f 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -256,6 +256,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, PassBoundBOToExec, -1, "Pass bound BOs to exec c DECLARE_DEBUG_VARIABLE(int32_t, EnableStaticPartitioning, -1, "Divide workload into partitions during dispatch, -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, UpdateTaskCountFromWait, -1, " Do not update task count after each enqueue, but send update request while wait, -1: default(disabled), 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, DeferOsContextInitialization, -1, "-1: default, 0: create all contexts immediately, 1: defer, if possible") +DECLARE_DEBUG_VARIABLE(int32_t, ForceHostPointerImport, -1, "-1: default, 0: disable, 1: enable, Forces the driver to import every host pointer coming into driver, WARNING this is not spec complaint.") DECLARE_DEBUG_VARIABLE(bool, UseMaxSimdSizeToDeduceMaxWorkgroupSize, false, "With this flag on, max workgroup size is deduced using SIMD32 instead of SIMD8, this causes the max wkg size to be 4 times bigger") DECLARE_DEBUG_VARIABLE(bool, ReturnRawGpuTimestamps, false, "Driver returns raw GPU tiemstamps instead of calculated ones.") DECLARE_DEBUG_VARIABLE(bool, ForcePerDssBackedBufferProgramming, false, "Always program per-DSS memory backed buffer in preamble")