feature: add support for secondary contexts in group

Related-To: NEO-7824

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2023-11-15 09:01:43 +00:00
committed by Compute-Runtime-Automation
parent 7bc8424a69
commit 31e9b5e9fa
27 changed files with 652 additions and 8 deletions

View File

@@ -137,7 +137,9 @@ ClDevice *ClDevice::getNearestGenericSubDevice(uint32_t deviceId) {
bool ClDevice::getDeviceAndHostTimer(uint64_t *deviceTimestamp, uint64_t *hostTimestamp) const { return device.getDeviceAndHostTimer(deviceTimestamp, hostTimestamp); }
bool ClDevice::getHostTimer(uint64_t *hostTimestamp) const { return device.getHostTimer(hostTimestamp); }
const HardwareInfo &ClDevice::getHardwareInfo() const { return device.getHardwareInfo(); }
EngineControl &ClDevice::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) { return device.getEngine(engineType, engineUsage); }
EngineControl &ClDevice::getEngine(aub_stream::EngineType engineType, EngineUsage engineUsage) {
return device.getEngine(engineType, engineUsage);
}
EngineControl &ClDevice::getDefaultEngine() { return device.getDefaultEngine(); }
EngineControl &ClDevice::getInternalEngine() { return device.getInternalEngine(); }
SelectorCopyEngine &ClDevice::getSelectorCopyEngine() { return device.getSelectorCopyEngine(); }

View File

@@ -191,12 +191,22 @@ void CommandQueue::initializeGpgpu() const {
auto defaultEngineType = device->getDefaultEngine().getEngineType();
const GfxCoreHelper &gfxCoreHelper = getDevice().getGfxCoreHelper();
bool secondaryContextsEnabled = gfxCoreHelper.areSecondaryContextsSupported();
if (device->getDevice().isMultiRegularContextSelectionAllowed(defaultEngineType, EngineUsage::regular)) {
this->gpgpuEngine = &device->getDevice().getNextEngineForMultiRegularContextMode(defaultEngineType);
} else if (assignEngineRoundRobin) {
this->gpgpuEngine = &device->getDevice().getNextEngineForCommandQueue();
} else {
this->gpgpuEngine = &device->getDefaultEngine();
if (secondaryContextsEnabled && EngineHelpers::isCcs(defaultEngineType)) {
gpgpuEngine = device->getDevice().getSecondaryEngineCsr(0, {defaultEngineType, EngineUsage::regular});
}
if (gpgpuEngine == nullptr) {
this->gpgpuEngine = &device->getDefaultEngine();
}
}
this->initializeGpgpuInternals();
@@ -1188,6 +1198,7 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage
const bool isEngineCopyOnly = EngineHelper::isCopyOnlyEngineType(engineGroupType);
bool multiRegularContextAllowed = device->getDevice().isMultiRegularContextSelectionAllowed(engineType, engineUsage);
bool secondaryContextsEnabled = gfxCoreHelper.areSecondaryContextsSupported();
if (isEngineCopyOnly) {
std::fill(bcsEngines.begin(), bcsEngines.end(), nullptr);
@@ -1208,6 +1219,9 @@ void CommandQueue::overrideEngine(aub_stream::EngineType engineType, EngineUsage
} else {
if (multiRegularContextAllowed) {
gpgpuEngine = &device->getDevice().getNextEngineForMultiRegularContextMode(engineType);
} else if (secondaryContextsEnabled && EngineHelpers::isCcs(engineType)) {
auto index = EngineHelpers::getCcsIndex(engineType);
gpgpuEngine = device->getDevice().getSecondaryEngineCsr(index, {engineType, engineUsage});
} else {
gpgpuEngine = &device->getEngine(engineType, engineUsage);
}

View File

@@ -8,6 +8,7 @@
#pragma once
#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/device/device.h"
#include "shared/source/helpers/engine_control.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/os_context.h"
@@ -48,6 +49,7 @@ class CommandQueueHw : public CommandQueue {
if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_LOW_KHR)) {
priority = QueuePriority::low;
this->gpgpuEngine = &device->getNearestGenericSubDevice(0)->getEngine(getChosenEngineType(device->getHardwareInfo()), EngineUsage::lowPriority);
} else if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_MED_KHR)) {
priority = QueuePriority::medium;
} else if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_HIGH_KHR)) {