diff --git a/opencl/source/memory_manager/migration_controller.cpp b/opencl/source/memory_manager/migration_controller.cpp index d6fecacd37..7d94e1bb30 100644 --- a/opencl/source/memory_manager/migration_controller.cpp +++ b/opencl/source/memory_manager/migration_controller.cpp @@ -17,9 +17,6 @@ #include "opencl/source/mem_obj/mem_obj.h" namespace NEO { -class MemoryManager; -class CommandStreamReceiver; -class MultiGraphicsAllocation; void MigrationController::handleMigration(Context &context, CommandStreamReceiver &targetCsr, MemObj *memObj) { auto memoryManager = targetCsr.getMemoryManager(); auto targetRootDeviceIndex = targetCsr.getRootDeviceIndex(); diff --git a/shared/source/memory_manager/multi_graphics_allocation.cpp b/shared/source/memory_manager/multi_graphics_allocation.cpp index 7724b29271..25c909d2b7 100644 --- a/shared/source/memory_manager/multi_graphics_allocation.cpp +++ b/shared/source/memory_manager/multi_graphics_allocation.cpp @@ -74,7 +74,9 @@ StackVec const &MultiGraphicsAllocation::getGraphicsAll void MultiGraphicsAllocation::setMultiStorage(bool value) { isMultiStorage = value; if (isMultiStorage && !migrationSyncData) { - migrationSyncData = createMigrationSyncDataFunc(getDefaultGraphicsAllocation()->getUnderlyingBufferSize()); + auto graphicsAllocation = getDefaultGraphicsAllocation(); + UNRECOVERABLE_IF(!graphicsAllocation); + migrationSyncData = createMigrationSyncDataFunc(graphicsAllocation->getUnderlyingBufferSize()); migrationSyncData->incRefInternal(); } } diff --git a/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp b/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp index b7ba196637..8b4629f151 100644 --- a/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp +++ b/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp @@ -255,6 +255,12 @@ TEST_F(MigrationSyncDataTests, whenMigrationSyncDataExistsAndSetMultiStorageIsCa EXPECT_EQ(migrationSyncData, multiGraphicsAllocation.getMigrationSyncData()); } +TEST(MigrationSyncDataTest, givenEmptyMultiGraphicsAllocationWhenSetMultiStorageIsCalledThenAbortIsCalled) { + MultiGraphicsAllocation multiGraphicsAllocation(1); + EXPECT_EQ(nullptr, multiGraphicsAllocation.getDefaultGraphicsAllocation()); + EXPECT_THROW(multiGraphicsAllocation.setMultiStorage(true), std::exception); +} + TEST_F(MigrationSyncDataTests, whenMigrationIsNotStartedThenMigrationIsNotInProgress) { EXPECT_FALSE(migrationSyncData->isMigrationInProgress());