diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index 73c74bf9df..df68db1787 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -72,6 +72,11 @@ ze_result_t DeviceImp::canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t * DeviceImp *pPeerDevice = static_cast(Device::fromHandle(hPeerDevice)); uint32_t peerRootDeviceIndex = pPeerDevice->getNEODevice()->getRootDeviceIndex(); + if (NEO::DebugManager.flags.ForceZeDeviceCanAccessPerReturnValue.get() != -1) { + *value = !!NEO::DebugManager.flags.ForceZeDeviceCanAccessPerReturnValue.get(); + return ZE_RESULT_SUCCESS; + } + if (this->crossAccessEnabledDevices.find(peerRootDeviceIndex) != this->crossAccessEnabledDevices.end()) { *value = this->crossAccessEnabledDevices[peerRootDeviceIndex]; } else if (this->getNEODevice()->getRootDeviceIndex() == peerRootDeviceIndex) { 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 db869beebb..e0e181f0d5 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 @@ -2369,6 +2369,22 @@ TEST_F(MultipleDevicesDisabledImplicitScalingTest, givenTwoRootDevicesFromSameFa EXPECT_TRUE(canAccess); } +TEST_F(MultipleDevicesDisabledImplicitScalingTest, givenTwoRootDevicesFromSameFamilyThenCanAccessPeerReturnsValueBasingOnDebugVariable) { + DebugManagerStateRestore restorer; + DebugManager.flags.ForceZeDeviceCanAccessPerReturnValue.set(0); + L0::Device *device0 = driverHandle->devices[0]; + L0::Device *device1 = driverHandle->devices[1]; + + ze_bool_t canAccess = false; + ze_result_t res = device0->canAccessPeer(device1->toHandle(), &canAccess); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_FALSE(canAccess); + DebugManager.flags.ForceZeDeviceCanAccessPerReturnValue.set(1); + res = device0->canAccessPeer(device1->toHandle(), &canAccess); + EXPECT_EQ(ZE_RESULT_SUCCESS, res); + EXPECT_TRUE(canAccess); +} + TEST_F(MultipleDevicesDisabledImplicitScalingTest, givenCanAccessPeerCalledTwiceThenCanAccessPeerReturnsSameValueEachTime) { L0::Device *device0 = driverHandle->devices[0]; L0::Device *device1 = driverHandle->devices[1]; diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 8f48547ead..bd601eec7b 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -221,6 +221,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, PlaformSupportEvictIfNecessaryFlag, -1, "-1: def DECLARE_DEBUG_VARIABLE(int32_t, ForceEvictOnlyIfNecessaryFlag, -1, "-1: default - driver selects when to use, 0: force never use this flag, 1: force always use this flag") DECLARE_DEBUG_VARIABLE(int32_t, ForceStatelessMocsEncryptionBit, -1, "-1: default - 1: set encryption bit") DECLARE_DEBUG_VARIABLE(int32_t, CopyHostPtrOnCpu, -1, "-1: default, 0: disable, 1:enable, In clCreateBuffer with CL_MEM_COPY_HOST_PTR, copy memory using locked ptr on cpu") +DECLARE_DEBUG_VARIABLE(int32_t, ForceZeDeviceCanAccessPerReturnValue, -1, "-1: default, 0: zeDeviceCanAccessPeer always return false 1: zeDeviceCanAccessPeer always return true") /*LOGGING FLAGS*/ DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level") diff --git a/shared/test/common/test_files/igdrcl.config b/shared/test/common/test_files/igdrcl.config index 3d7cfbc2e1..8e8eca617e 100644 --- a/shared/test/common/test_files/igdrcl.config +++ b/shared/test/common/test_files/igdrcl.config @@ -472,4 +472,5 @@ ExperimentalD2HCpuCopyThreshold = -1 CopyHostPtrOnCpu = -1 PrintCompletionFenceUsage = 0 SetAmountOfReusableAllocations = -1 -ExperimentalSmallBufferPoolAllocator = -1 \ No newline at end of file +ExperimentalSmallBufferPoolAllocator = -1 +ForceZeDeviceCanAccessPerReturnValue = -1 \ No newline at end of file