Add debug flag to override zeDeviceCanAccessPeer return value.

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek
2022-10-20 12:56:29 +00:00
committed by Compute-Runtime-Automation
parent 22dbae1771
commit 3384b2fed0
4 changed files with 24 additions and 1 deletions

View File

@@ -72,6 +72,11 @@ ze_result_t DeviceImp::canAccessPeer(ze_device_handle_t hPeerDevice, ze_bool_t *
DeviceImp *pPeerDevice = static_cast<DeviceImp *>(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) {

View File

@@ -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];