fix: add nullptr check in cache reservation API

in case of AUB/TBX mode there is no os interface

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski 2024-09-03 14:07:24 +00:00 committed by Compute-Runtime-Automation
parent 6d7e2760dc
commit 43e3957e66
2 changed files with 10 additions and 2 deletions

View File

@ -1166,7 +1166,8 @@ ze_result_t DeviceImp::getCacheProperties(uint32_t *pCount, ze_device_cache_prop
}
ze_result_t DeviceImp::reserveCache(size_t cacheLevel, size_t cacheReservationSize) {
if (getOsInterface().getDriverModel()->getDriverModelType() != NEO::DriverModelType::drm) {
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
if (!osInterface || osInterface->getDriverModel()->getDriverModelType() != NEO::DriverModelType::drm) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}
@ -1187,7 +1188,8 @@ ze_result_t DeviceImp::reserveCache(size_t cacheLevel, size_t cacheReservationSi
}
ze_result_t DeviceImp::setCacheAdvice(void *ptr, size_t regionSize, ze_cache_ext_region_t cacheRegion) {
if (getOsInterface().getDriverModel()->getDriverModelType() != NEO::DriverModelType::drm) {
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
if (!osInterface || osInterface->getDriverModel()->getDriverModelType() != NEO::DriverModelType::drm) {
return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

View File

@ -840,6 +840,12 @@ TEST_F(DeviceTest, givenNonEmptyAllocationsListAndUnproperAllocationTypeWhenRequ
EXPECT_FALSE(deviceImp->allocationsForReuse->peekIsEmpty());
}
TEST_F(DeviceTest, givenNoOsInterfaceWhenUseCacheReservationApiThenUnsupportedFeatureErrorIsReturned) {
EXPECT_EQ(nullptr, neoDevice->getRootDeviceEnvironment().osInterface.get());
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, device->reserveCache(0, 0));
EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, device->setCacheAdvice(nullptr, 0, ze_cache_ext_region_t::ZE_CACHE_EXT_REGION_ZE_CACHE_REGION_DEFAULT));
}
struct DeviceHostPointerTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new NEO::ExecutionEnvironment();