diff --git a/opencl/source/command_queue/command_queue.cpp b/opencl/source/command_queue/command_queue.cpp index 2c4fb77160..ea380c38cd 100644 --- a/opencl/source/command_queue/command_queue.cpp +++ b/opencl/source/command_queue/command_queue.cpp @@ -171,6 +171,13 @@ CommandQueue::~CommandQueue() { gtpinRemoveCommandQueue(this); } +void tryAssignSecondaryEngine(Device &device, EngineControl *&engineControl, EngineTypeUsage engineTypeUsage) { + auto newEngine = device.getSecondaryEngineCsr(engineTypeUsage); + if (newEngine) { + engineControl = newEngine; + } +} + void CommandQueue::initializeGpgpu() const { if (gpgpuEngine == nullptr) { static std::mutex mutex; @@ -202,7 +209,7 @@ void CommandQueue::initializeGpgpu() const { } else { if (secondaryContextsEnabled && EngineHelpers::isCcs(defaultEngineType)) { - gpgpuEngine = device->getDevice().getSecondaryEngineCsr({defaultEngineType, EngineUsage::regular}); + tryAssignSecondaryEngine(device->getDevice(), gpgpuEngine, {defaultEngineType, EngineUsage::regular}); } if (gpgpuEngine == nullptr) { @@ -358,7 +365,7 @@ void CommandQueue::constructBcsEngine(bool internalUsage) { bcsQueueEngineType = bcsEngineType; if (gfxCoreHelper.areSecondaryContextsSupported() && !internalUsage) { - bcsEngines[bcsIndex] = device->getDevice().getSecondaryEngineCsr({bcsEngineType, engineUsage}); + tryAssignSecondaryEngine(device->getDevice(), bcsEngines[bcsIndex], {bcsEngineType, engineUsage}); } bcsEngines[bcsIndex]->osContext->ensureContextInitialized(); @@ -1225,7 +1232,7 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage bcsQueueEngineType = engineType; if (secondaryContextsEnabled) { - bcsEngines[engineIndex] = device->getDevice().getSecondaryEngineCsr({engineType, engineUsage}); + tryAssignSecondaryEngine(device->getDevice(), bcsEngines[engineIndex], {engineType, engineUsage}); } } timestampPacketContainer = std::make_unique(); @@ -1236,7 +1243,7 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage if (multiRegularContextAllowed) { gpgpuEngine = &device->getDevice().getNextEngineForMultiRegularContextMode(engineType); } else if (secondaryContextsEnabled && EngineHelpers::isCcs(engineType)) { - gpgpuEngine = device->getDevice().getSecondaryEngineCsr({engineType, engineUsage}); + tryAssignSecondaryEngine(device->getDevice(), gpgpuEngine, {engineType, engineUsage}); } else { gpgpuEngine = &device->getEngine(engineType, engineUsage); } diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index aa26b491fd..9e0a941be0 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -398,7 +398,13 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa const bool isDefaultEngine = defaultEngineType == engineType && engineUsage == EngineUsage::regular; const bool createAsEngineInstanced = engineInstanced && EngineHelpers::isCcs(engineType); - const bool isPrimaryEngine = (EngineHelpers::isCcs(engineType) || EngineHelpers::isBcs(engineType)) && engineUsage == EngineUsage::regular; + bool primaryEngineTypeAllowed = (EngineHelpers::isCcs(engineType) || EngineHelpers::isBcs(engineType)); + + if (debugManager.flags.SecondaryContextEngineTypeMask.get() != -1) { + primaryEngineTypeAllowed &= (static_cast(debugManager.flags.SecondaryContextEngineTypeMask.get()) & (1 << static_cast(engineType))) != 0; + } + + const bool isPrimaryEngine = primaryEngineTypeAllowed && (engineUsage == EngineUsage::regular); const bool useContextGroup = isPrimaryEngine && gfxCoreHelper.areSecondaryContextsSupported(); UNRECOVERABLE_IF(EngineHelpers::isBcs(engineType) && !hwInfo.capabilityTable.blitterOperationsSupported);