feature: allow creating L0 BCS LowPriority Queues

Related-To: NEO-7824

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2024-07-02 14:27:17 +00:00
committed by Compute-Runtime-Automation
parent 5188ab8909
commit 024c015dab
7 changed files with 66 additions and 27 deletions

View File

@@ -142,7 +142,7 @@ struct Device : _ze_device_handle_t {
virtual void setSysmanHandle(SysmanDevice *pSysmanDevice) = 0;
virtual SysmanDevice *getSysmanHandle() = 0;
virtual ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index, ze_command_queue_priority_t priority, bool allocateInterrupt) = 0;
virtual ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr, aub_stream::EngineType engineType) = 0;
virtual ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr, bool copyOnly) = 0;
virtual NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::AllocationType type) = 0;
virtual void storeReusableAllocation(NEO::GraphicsAllocation &alloc) = 0;
virtual ze_result_t getFabricVertex(ze_fabric_vertex_handle_t *phVertex) = 0;

View File

@@ -1682,39 +1682,37 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
auto contextPriority = NEO::EngineUsage::regular;
auto engineGroupType = getEngineGroupTypeForOrdinal(ordinal);
bool copyOnly = NEO::EngineHelper::isCopyOnlyEngineType(engineGroupType);
if (secondaryContextsEnabled && priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH) {
contextPriority = NEO::EngineUsage::highPriority;
} else if (isSuitableForLowPriority(priority, NEO::EngineHelper::isCopyOnlyEngineType(engineGroupType))) {
} else if (isSuitableForLowPriority(priority, copyOnly)) {
contextPriority = NEO::EngineUsage::lowPriority;
}
if (contextPriority == NEO::EngineUsage::lowPriority) {
getCsrForLowPriority(csr, copyOnly);
return ZE_RESULT_SUCCESS;
}
if (ordinal < numEngineGroups) {
auto &engines = engineGroups[ordinal].engines;
if (index >= engines.size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = engines[index].commandStreamReceiver;
auto &osContext = (*csr)->getOsContext();
if (secondaryContextsEnabled && (contextPriority != NEO::EngineUsage::lowPriority)) {
tryAssignSecondaryContext(osContext.getEngineType(), contextPriority, csr, allocateInterrupt);
}
} else {
auto subDeviceOrdinal = ordinal - numEngineGroups;
if (index >= this->subDeviceCopyEngineGroups[subDeviceOrdinal].engines.size()) {
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
*csr = this->subDeviceCopyEngineGroups[subDeviceOrdinal].engines[index].commandStreamReceiver;
if (secondaryContextsEnabled && (contextPriority != NEO::EngineUsage::lowPriority)) {
tryAssignSecondaryContext((*csr)->getOsContext().getEngineType(), contextPriority, csr, allocateInterrupt);
}
}
if (contextPriority == NEO::EngineUsage::lowPriority) {
getCsrForLowPriority(csr, (*csr)->getOsContext().getEngineType());
auto &osContext = (*csr)->getOsContext();
if (secondaryContextsEnabled) {
tryAssignSecondaryContext(osContext.getEngineType(), contextPriority, csr, allocateInterrupt);
}
return ZE_RESULT_SUCCESS;
@@ -1735,11 +1733,9 @@ bool DeviceImp::tryAssignSecondaryContext(aub_stream::EngineType engineType, NEO
return false;
}
ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr, aub_stream::EngineType engineType) {
bool isComputeEngine = NEO::EngineHelpers::isComputeEngine(engineType);
ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr, bool copyOnly) {
for (auto &it : getActiveDevice()->getAllEngines()) {
bool engineTypeMatch = NEO::EngineHelpers::isComputeEngine(it.osContext->getEngineType()) && isComputeEngine;
bool engineTypeMatch = NEO::EngineHelpers::isBcs(it.osContext->getEngineType()) == copyOnly;
if (it.osContext->isLowPriority() && engineTypeMatch) {
*csr = it.commandStreamReceiver;
return ZE_RESULT_SUCCESS;
@@ -1753,7 +1749,9 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr, au
}
bool DeviceImp::isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly) {
return (priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && !copyOnly && !this->implicitScalingCapable);
bool engineSuitable = copyOnly ? getGfxCoreHelper().getContextGroupContextsCount() > 0 : !this->implicitScalingCapable;
return (priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && engineSuitable);
}
DebugSession *DeviceImp::getDebugSession(const zet_debug_config_t &config) {

View File

@@ -116,7 +116,7 @@ struct DeviceImp : public Device, NEO::NonCopyableOrMovableClass {
void setSysmanHandle(SysmanDevice *pSysman) override;
SysmanDevice *getSysmanHandle() override;
ze_result_t getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr, uint32_t ordinal, uint32_t index, ze_command_queue_priority_t priority, bool allocateInterrupt) override;
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr, aub_stream::EngineType engineType) override;
ze_result_t getCsrForLowPriority(NEO::CommandStreamReceiver **csr, bool copyOnly) override;
bool isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly);
NEO::GraphicsAllocation *obtainReusableAllocation(size_t requiredSize, NEO::AllocationType type) override;
void storeReusableAllocation(NEO::GraphicsAllocation &alloc) override;