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

@@ -55,6 +55,7 @@ MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : execu
checkIsaPlacementOnceFlags = std::make_unique<std::once_flag[]>(rootEnvCount);
isaInLocalMemory.resize(rootEnvCount);
allRegisteredEngines.resize(rootEnvCount + 1);
secondaryEngines.resize(rootEnvCount + 1);
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < rootEnvCount; ++rootDeviceIndex) {
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
@@ -85,6 +86,14 @@ MemoryManager::MemoryManager(ExecutionEnvironment &executionEnvironment) : execu
}
MemoryManager::~MemoryManager() {
for (auto &engineContainer : secondaryEngines) {
for (auto &engine : engineContainer) {
engine.osContext->decRefInternal();
}
engineContainer.clear();
}
secondaryEngines.clear();
for (auto &engineContainer : allRegisteredEngines) {
for (auto &engine : engineContainer) {
engine.osContext->decRefInternal();
@@ -349,6 +358,25 @@ OsContext *MemoryManager::createAndRegisterOsContext(CommandStreamReceiver *comm
return osContext;
}
OsContext *MemoryManager::createAndRegisterSecondaryOsContext(const OsContext *primaryContext, CommandStreamReceiver *commandStreamReceiver,
const EngineDescriptor &engineDescriptor) {
auto rootDeviceIndex = commandStreamReceiver->getRootDeviceIndex();
updateLatestContextIdForRootDevice(rootDeviceIndex);
auto contextId = primaryContext->getContextId();
auto osContext = OsContext::create(peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->osInterface.get(), rootDeviceIndex, contextId, engineDescriptor);
osContext->incRefInternal();
osContext->setPrimaryContext(primaryContext);
UNRECOVERABLE_IF(rootDeviceIndex != osContext->getRootDeviceIndex());
secondaryEngines[rootDeviceIndex].emplace_back(commandStreamReceiver, osContext);
return osContext;
}
bool MemoryManager::getAllocationData(AllocationData &allocationData, const AllocationProperties &properties, const void *hostPtr, const StorageInfo &storageInfo) {
UNRECOVERABLE_IF(hostPtr == nullptr && !properties.flags.allocateMemory);
UNRECOVERABLE_IF(properties.allocationType == AllocationType::unknown);