Correct nullptr SVM arg handling

Related-To: NEO-5001
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-01-25 13:17:51 +00:00
committed by Compute-Runtime-Automation
parent 147dc0fbc8
commit 6f2a8e8a1c
2 changed files with 19 additions and 2 deletions

View File

@ -18,8 +18,10 @@ GraphicsAllocation *SvmObjectArg::getGraphicsAllocation(uint32_t rootDeviceIndex
DEBUG_BREAK_IF(singleDeviceSvmAlloc && rootDeviceIndex != singleDeviceSvmAlloc->getRootDeviceIndex());
return singleDeviceSvmAlloc;
}
UNRECOVERABLE_IF(!multiDeviceSvmAlloc);
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
if (multiDeviceSvmAlloc) {
return multiDeviceSvmAlloc->getGraphicsAllocation(rootDeviceIndex);
}
return nullptr;
}
bool SvmObjectArg::isCoherent() const {

View File

@ -39,3 +39,18 @@ TEST(SvmObjectArgTest, givenMultiGraphicsAllocationWhenCreatingSvmObjectArgThenP
EXPECT_EQ(multiGraphicsAllocation.getAllocationType(), svmObjectArg.getAllocationType());
EXPECT_EQ(&multiGraphicsAllocation, svmObjectArg.getMultiDeviceSvmAlloc());
}
TEST(SvmObjectArgTest, givenNullPtrAllocationWhenGettingGraphicsAllocationFromSvmObjectArgThenNullptrIsReturned) {
{
GraphicsAllocation *nullGraphicsAllocation = nullptr;
SvmObjectArg svmObjectArg(nullGraphicsAllocation);
EXPECT_EQ(nullptr, svmObjectArg.getGraphicsAllocation(0u));
}
{
MultiGraphicsAllocation *nullMultiGraphicsAllocation = nullptr;
SvmObjectArg svmObjectArg(nullMultiGraphicsAllocation);
EXPECT_EQ(nullptr, svmObjectArg.getGraphicsAllocation(0u));
}
}