feature: add support for HP copy engine context

- add support for contect group with HP copy engine
- choose HP copy engine when available

Related-To: NEO-11983

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2024-07-19 10:20:37 +00:00
committed by Compute-Runtime-Automation
parent 4fc37f9afd
commit b6299b8a21
13 changed files with 510 additions and 46 deletions

View File

@@ -1684,7 +1684,7 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
auto engineGroupType = getEngineGroupTypeForOrdinal(ordinal);
bool copyOnly = NEO::EngineHelper::isCopyOnlyEngineType(engineGroupType);
if (secondaryContextsEnabled && priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH) {
if (priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH) {
contextPriority = NEO::EngineUsage::highPriority;
} else if (isSuitableForLowPriority(priority, copyOnly)) {
contextPriority = NEO::EngineUsage::lowPriority;
@@ -1709,6 +1709,10 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
*csr = this->subDeviceCopyEngineGroups[subDeviceOrdinal].engines[index].commandStreamReceiver;
}
if (copyOnly && contextPriority == NEO::EngineUsage::highPriority) {
getCsrForHighPriority(csr, copyOnly);
}
auto &osContext = (*csr)->getOsContext();
if (secondaryContextsEnabled) {
@@ -1747,6 +1751,18 @@ ze_result_t DeviceImp::getCsrForLowPriority(NEO::CommandStreamReceiver **csr, bo
UNRECOVERABLE_IF(true);
return ZE_RESULT_ERROR_UNKNOWN;
}
ze_result_t DeviceImp::getCsrForHighPriority(NEO::CommandStreamReceiver **csr, bool copyOnly) {
for (auto &it : getActiveDevice()->getAllEngines()) {
bool engineTypeMatch = NEO::EngineHelpers::isBcs(it.osContext->getEngineType()) == copyOnly;
if (it.osContext->isHighPriority() && engineTypeMatch) {
*csr = it.commandStreamReceiver;
return ZE_RESULT_SUCCESS;
}
}
// if the code falls through, we have no high priority context created by neoDevice.
return ZE_RESULT_ERROR_UNKNOWN;
}
bool DeviceImp::isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly) {
bool engineSuitable = copyOnly ? getGfxCoreHelper().getContextGroupContextsCount() > 0 : !this->implicitScalingCapable;

View File

@@ -117,6 +117,7 @@ struct DeviceImp : public Device, NEO::NonCopyableOrMovableClass {
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, bool copyOnly) override;
ze_result_t getCsrForHighPriority(NEO::CommandStreamReceiver **csr, bool copyOnly);
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;