From a87fd77fd45fe22d4c88f93312e322352475640c Mon Sep 17 00:00:00 2001 From: Jaime Arteaga Date: Thu, 2 Mar 2023 16:46:33 +0000 Subject: [PATCH] feature: Add debug key to enable cross-shared concurrent p2p access Current support in the stack does not allow for concurrent access to shared-allocations from host and peer devices when using page-faults. So disable caps for now and introduce debug key for experimentation. Access will be added by default as support in the stack becomes available. Signed-off-by: Jaime Arteaga --- level_zero/core/source/device/device_imp.cpp | 3 +- .../sources/device/test_l0_device.cpp | 40 ++++++++++++++++++- .../debug_settings/debug_variables_base.inl | 1 + shared/test/common/test_files/igdrcl.config | 1 + 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index a0237d3497..3f80513852 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -628,7 +628,8 @@ ze_result_t DeviceImp::getMemoryAccessProperties(ze_device_memory_access_propert auto memoryManager = this->getDriverHandle()->getMemoryManager(); if (memoryManager->isKmdMigrationAvailable(this->getRootDeviceIndex()) && - memoryManager->hasPageFaultsEnabled(*this->getNEODevice())) { + memoryManager->hasPageFaultsEnabled(*this->getNEODevice()) && + NEO::DebugManager.flags.EnableConcurrentSharedCrossP2PDeviceAccess.get() == 1) { pMemAccessProperties->sharedCrossDeviceAllocCapabilities |= ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT; if (this->getNEODevice()->getHardwareInfo().capabilityTable.p2pAtomicAccessSupported) { pMemAccessProperties->sharedCrossDeviceAllocCapabilities |= ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC | ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC; diff --git a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp index 4c2e8c9486..1f41ac5f35 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp @@ -2438,7 +2438,8 @@ TEST_F(MemoryAccessPropertieP2PAccess1Atomic0, WhenCallingGetMemoryAccessPropert } using MemoryAccessPropertieP2PAccess1Atomic0 = MultipleDevicesP2PFixture<1, 0, 0, 0>; -TEST_F(MemoryAccessPropertieP2PAccess1Atomic0, WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndConcurrentAccessSupportThenSupportIsReturned) { +TEST_F(MemoryAccessPropertieP2PAccess1Atomic0, + WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndConcurrentAccessSupportThenBasicSupportIsReturned) { DebugManagerStateRestore restorer; DebugManager.flags.EnableRecoverablePageFaults.set(1); DebugManager.flags.UseKmdMigration.set(1); @@ -2448,13 +2449,32 @@ TEST_F(MemoryAccessPropertieP2PAccess1Atomic0, WhenCallingGetMemoryAccessPropert auto result = device->getMemoryAccessProperties(&properties); EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_memory_access_cap_flags_t expectedSharedCrossDeviceAllocCapabilities = + ZE_MEMORY_ACCESS_CAP_FLAG_RW; + EXPECT_EQ(expectedSharedCrossDeviceAllocCapabilities, properties.sharedCrossDeviceAllocCapabilities); +} + +using MemoryAccessPropertieP2PAccess1Atomic0 = MultipleDevicesP2PFixture<1, 0, 0, 0>; +TEST_F(MemoryAccessPropertieP2PAccess1Atomic0, + WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndConcurrentAccessSupportAndEnableCrossP2PSharedAccessKeyThenSupportIsReturned) { + DebugManagerStateRestore restorer; + DebugManager.flags.EnableRecoverablePageFaults.set(1); + DebugManager.flags.UseKmdMigration.set(1); + DebugManager.flags.EnableConcurrentSharedCrossP2PDeviceAccess.set(1); + + L0::Device *device = driverHandle->devices[0]; + ze_device_memory_access_properties_t properties; + auto result = device->getMemoryAccessProperties(&properties); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_memory_access_cap_flags_t expectedSharedCrossDeviceAllocCapabilities = ZE_MEMORY_ACCESS_CAP_FLAG_RW | ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT; EXPECT_EQ(expectedSharedCrossDeviceAllocCapabilities, properties.sharedCrossDeviceAllocCapabilities); } using MemoryAccessPropertieP2PAccess1Atomic1 = MultipleDevicesP2PFixture<1, 1, 0, 0>; -TEST_F(MemoryAccessPropertieP2PAccess1Atomic1, WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndAtomicAccessSupportThenSupportIsReturned) { +TEST_F(MemoryAccessPropertieP2PAccess1Atomic1, + WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndAtomicAccessSupportThenBasicSupportIsReturned) { DebugManagerStateRestore restorer; DebugManager.flags.EnableRecoverablePageFaults.set(1); DebugManager.flags.UseKmdMigration.set(1); @@ -2464,6 +2484,22 @@ TEST_F(MemoryAccessPropertieP2PAccess1Atomic1, WhenCallingGetMemoryAccessPropert auto result = device->getMemoryAccessProperties(&properties); EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_memory_access_cap_flags_t expectedSharedCrossDeviceAllocCapabilities = ZE_MEMORY_ACCESS_CAP_FLAG_RW; + EXPECT_EQ(expectedSharedCrossDeviceAllocCapabilities, properties.sharedCrossDeviceAllocCapabilities); +} + +TEST_F(MemoryAccessPropertieP2PAccess1Atomic1, + WhenCallingGetMemoryAccessPropertiesWithDevicesHavingP2PAndAtomicAccessSupportAndEnableCrossP2PSharedAccessKeyThenSupportIsReturned) { + DebugManagerStateRestore restorer; + DebugManager.flags.EnableRecoverablePageFaults.set(1); + DebugManager.flags.UseKmdMigration.set(1); + DebugManager.flags.EnableConcurrentSharedCrossP2PDeviceAccess.set(1); + + L0::Device *device = driverHandle->devices[0]; + ze_device_memory_access_properties_t properties; + auto result = device->getMemoryAccessProperties(&properties); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + ze_memory_access_cap_flags_t expectedSharedCrossDeviceAllocCapabilities = ZE_MEMORY_ACCESS_CAP_FLAG_RW | ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT | ZE_MEMORY_ACCESS_CAP_FLAG_ATOMIC | ZE_MEMORY_ACCESS_CAP_FLAG_CONCURRENT_ATOMIC; diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index ba1d914749..9e396ba9aa 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -481,6 +481,7 @@ DECLARE_DEBUG_VARIABLE(bool, ForceAllResourcesUncached, false, "When set, all me DECLARE_DEBUG_VARIABLE(bool, EnableDebuggerMmapMemoryAccess, false, "Mmap used to access memory by debug api, valid only on Linux OS") DECLARE_DEBUG_VARIABLE(bool, ForceDefaultGrfCompilationMode, false, "Adds build option -cl-intel-128-GRF-per-thread to force kernel compilation in Default-GRF mode") DECLARE_DEBUG_VARIABLE(bool, ForceLargeGrfCompilationMode, false, "Adds build option -cl-intel-256-GRF-per-thread to force kernel compilation in Large-GRF mode") +DECLARE_DEBUG_VARIABLE(bool, EnableConcurrentSharedCrossP2PDeviceAccess, false, "Enables the concurrent use between host and peer devices of shared-allocations ") DECLARE_DEBUG_VARIABLE(int32_t, ForceAutoGrfCompilationMode, -1, "Adds build option -*-intel-enable-auto-large-GRF-mode to force kernel compilation") DECLARE_DEBUG_VARIABLE(int32_t, ForceOCLVersion, 0, "Force specific OpenCL API version") DECLARE_DEBUG_VARIABLE(int32_t, ForceOCL21FeaturesSupport, -1, "-1: default, 0: disable, 1:enable. Force support of OpenCL 2.0 and OpenCL 2.1 API features") diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 9d92a69055..5fb3875f56 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -481,6 +481,7 @@ ExperimentalEnableTileAttach = 1 DirectSubmissionDisablePrefetcher = -1 ForceDefaultGrfCompilationMode = 0 ForceLargeGrfCompilationMode = 0 +EnableConcurrentSharedCrossP2PDeviceAccess = 0 ForceStatelessMocsEncryptionBit = -1 ExperimentalCopyThroughLock = -1 ExperimentalH2DCpuCopyThreshold = -1