diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp index fee27a05e6..25567e7c0c 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -315,6 +315,23 @@ TEST(CommandStreamReceiverSimpleTest, givenCsrWhenSubmitiingBatchBufferThenTaskC executionEnvironment.memoryManager->freeGraphicsMemoryImpl(commandBuffer); } +TEST(CommandStreamReceiverSimpleTest, givenOverrideCsrAllocationSizeWhenCreatingCommandStreamCsrGraphicsAllocationThenAllocationHasCorrectSize) { + DebugManagerStateRestore restore; + + int32_t overrideSize = 10 * MemoryConstants::pageSize; + DebugManager.flags.OverrideCsrAllocationSize.set(overrideSize); + + MockExecutionEnvironment executionEnvironment; + executionEnvironment.prepareRootDeviceEnvironments(1); + executionEnvironment.initializeMemoryManager(); + DeviceBitfield deviceBitfield(1); + MockCommandStreamReceiver commandStreamReceiver(executionEnvironment, 0u, deviceBitfield); + + bool ret = commandStreamReceiver.createPreemptionAllocation(); + ASSERT_TRUE(ret); + EXPECT_EQ(static_cast(overrideSize), commandStreamReceiver.preemptionAllocation->getUnderlyingBufferSize()); +} + HWTEST_F(CommandStreamReceiverTest, givenCommandStreamReceiverWhenCallingGetMemoryCompressionStateThenReturnNotApplicable) { CommandStreamReceiverHw commandStreamReceiver(*pDevice->executionEnvironment, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); diff --git a/opencl/test/unit_test/test_files/igdrcl.config b/opencl/test/unit_test/test_files/igdrcl.config index eb98cc3f1a..42db19ff2e 100644 --- a/opencl/test/unit_test/test_files/igdrcl.config +++ b/opencl/test/unit_test/test_files/igdrcl.config @@ -30,6 +30,7 @@ AUBDumpForceAllToLocalMemory = 0 EnableSWTags = 0 DumpSWTagsBXML = 0 ForceDeviceId = unk +OverrideCsrAllocationSize = -1 ForceL1Caching = -1 UseKmdMigration = 0 SchedulerSimulationReturnInstance = 0 diff --git a/shared/source/command_stream/command_stream_receiver.cpp b/shared/source/command_stream/command_stream_receiver.cpp index 16ca5303da..7221113827 100644 --- a/shared/source/command_stream/command_stream_receiver.cpp +++ b/shared/source/command_stream/command_stream_receiver.cpp @@ -561,7 +561,11 @@ bool CommandStreamReceiver::createGlobalFenceAllocation() { bool CommandStreamReceiver::createPreemptionAllocation() { auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); - AllocationProperties properties{rootDeviceIndex, hwInfo->capabilityTable.requiredPreemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION, osContext->getDeviceBitfield()}; + size_t preemptionSurfaceSize = hwInfo->capabilityTable.requiredPreemptionSurfaceSize; + if (DebugManager.flags.OverrideCsrAllocationSize.get() > 0) { + preemptionSurfaceSize = DebugManager.flags.OverrideCsrAllocationSize.get(); + } + AllocationProperties properties{rootDeviceIndex, preemptionSurfaceSize, GraphicsAllocation::AllocationType::PREEMPTION, deviceBitfield}; properties.flags.uncacheable = hwInfo->workaroundTable.waCSRUncachable; properties.alignment = 256 * MemoryConstants::kiloByte; this->preemptionAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties(properties); diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index 18ee3defcd..40d617822e 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -95,6 +95,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, GpuScratchRegWriteRegisterData, 0, "register dat DECLARE_DEBUG_VARIABLE(int32_t, OverrideSlmAllocationSize, -1, "-1: default, >=0: program value for shared local memory size") DECLARE_DEBUG_VARIABLE(int32_t, DebuggerLogBitmask, 0, "0: logs disabled, 1 - INFO, 2 - ERROR, 1<<10 - Dump elf, see DebugVariables::DEBUGGER_LOG_BITMASK") DECLARE_DEBUG_VARIABLE(int32_t, DebuggerOptDisable, -1, "-1: default from debugger query, 0: do not add opt-disable, 1: add opt-disable") +DECLARE_DEBUG_VARIABLE(int32_t, OverrideCsrAllocationSize, -1, "-1: default, >0: use value for size of CSR allocation") /*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/mocks/mock_command_stream_receiver.h b/shared/test/common/mocks/mock_command_stream_receiver.h index f03e888cf9..6ddfb78b1b 100644 --- a/shared/test/common/mocks/mock_command_stream_receiver.h +++ b/shared/test/common/mocks/mock_command_stream_receiver.h @@ -33,6 +33,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { using CommandStreamReceiver::latestFlushedTaskCount; using CommandStreamReceiver::latestSentTaskCount; using CommandStreamReceiver::newResources; + using CommandStreamReceiver::preemptionAllocation; using CommandStreamReceiver::requiredThreadArbitrationPolicy; using CommandStreamReceiver::tagAddress; using CommandStreamReceiver::tagsMultiAllocation;