Defer OsContext initialization

Signed-off-by: Maciej Dziuban <maciej.dziuban@intel.com>
Related-To: NEO-5610
This commit is contained in:
Maciej Dziuban
2021-04-15 16:14:04 +00:00
committed by Compute-Runtime-Automation
parent b01b8ba5ac
commit 5318ff1872
35 changed files with 366 additions and 46 deletions

View File

@@ -150,16 +150,17 @@ std::unique_ptr<CommandStreamReceiver> Device::createCommandStreamReceiver() con
}
bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage) {
auto &hwInfo = getHardwareInfo();
auto defaultEngineType = getChosenEngineType(hwInfo);
const auto &hwInfo = getHardwareInfo();
const auto engineType = engineTypeUsage.first;
const auto engineUsage = engineTypeUsage.second;
const auto defaultEngineType = getChosenEngineType(hwInfo);
const bool isDefaultEngine = defaultEngineType == engineType && engineUsage == EngineUsage::Regular;
std::unique_ptr<CommandStreamReceiver> commandStreamReceiver = createCommandStreamReceiver();
if (!commandStreamReceiver) {
return false;
}
auto engineType = engineTypeUsage.first;
bool internalUsage = (engineTypeUsage.second == EngineUsage::Internal);
if (internalUsage) {
commandStreamReceiver->initializeDefaultsForInternalEngine();
@@ -175,6 +176,9 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa
getDeviceBitfield(),
preemptionMode,
false);
if (osContext->isImmediateContextInitializationEnabled(isDefaultEngine)) {
osContext->ensureContextInitialized();
}
commandStreamReceiver->setupContext(*osContext);
if (!commandStreamReceiver->initializeTagAllocation()) {
@@ -185,7 +189,7 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa
return false;
}
if (engineType == defaultEngineType && !lowPriority && !internalUsage) {
if (isDefaultEngine) {
defaultEngineIndex = deviceCsrIndex;
}