Add EngineDescriptor helper

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-08-11 17:36:00 +00:00
committed by Compute-Runtime-Automation
parent bda53f9cbf
commit fb996a3d5b
66 changed files with 505 additions and 460 deletions

View File

@@ -8,6 +8,7 @@
#include "shared/source/os_interface/device_factory.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include <atomic>
#include <memory>
@@ -23,7 +24,8 @@ struct DirectSubmissionFixture : public DeviceFixture {
DeviceFixture::SetUp();
DeviceFactory::prepareDeviceEnvironments(*pDevice->getExecutionEnvironment());
osContext.reset(OsContext::create(nullptr, 0u, pDevice->getDeviceBitfield(), EngineTypeUsage{aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::ThreadGroup, false));
osContext.reset(OsContext::create(nullptr, 0u,
EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_RCS, EngineUsage::Regular}, PreemptionMode::ThreadGroup, pDevice->getDeviceBitfield())));
}
std::unique_ptr<OsContext> osContext;

View File

@@ -15,6 +15,7 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.h
${CMAKE_CURRENT_SOURCE_DIR}/default_hw_info.inl
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_flags_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/engine_descriptor_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/engine_node_helper_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/hw_helper_extended_tests.cpp

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/engine_node_helper.h"
namespace NEO {
namespace EngineDescriptorHelper {
constexpr EngineDescriptor getDefaultDescriptor() {
return {{aub_stream::EngineType::ENGINE_RCS, EngineUsage::Regular},
1 /*deviceBitfield*/,
PreemptionMode::Disabled,
false /* isRootDevice*/};
}
constexpr EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage) {
return {engineTypeUsage,
1 /*deviceBitfield*/,
PreemptionMode::Disabled,
false /* isRootDevice*/};
}
constexpr EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage, bool isRootDevice) {
return {engineTypeUsage,
1 /*deviceBitfield*/,
PreemptionMode::Disabled,
isRootDevice};
}
constexpr EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage, PreemptionMode preemptionMode) {
return {engineTypeUsage,
1 /*deviceBitfield*/,
preemptionMode,
false /* isRootDevice*/};
}
inline EngineDescriptor getDefaultDescriptor(DeviceBitfield deviceBitfield) {
return {{aub_stream::EngineType::ENGINE_RCS, EngineUsage::Regular},
deviceBitfield,
PreemptionMode::Disabled,
false /* isRootDevice*/};
}
inline EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage, DeviceBitfield deviceBitfield) {
return {engineTypeUsage,
deviceBitfield,
PreemptionMode::Disabled,
false /* isRootDevice*/};
}
inline EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage, PreemptionMode preemptionMode, DeviceBitfield deviceBitfield) {
return {engineTypeUsage,
deviceBitfield,
preemptionMode,
false /* isRootDevice*/};
}
inline EngineDescriptor getDefaultDescriptor(EngineTypeUsage engineTypeUsage, PreemptionMode preemptionMode, DeviceBitfield deviceBitfield, bool isRootDevice) {
return {engineTypeUsage,
deviceBitfield,
preemptionMode,
isRootDevice};
}
} // namespace EngineDescriptorHelper
} // namespace NEO

View File

@@ -30,10 +30,10 @@ MockDevice::MockDevice()
CommandStreamReceiver *commandStreamReceiver = createCommandStream(*executionEnvironment, this->getRootDeviceIndex(), this->getDeviceBitfield());
commandStreamReceivers.resize(1);
commandStreamReceivers[0].reset(commandStreamReceiver);
OsContext *osContext = getMemoryManager()->createAndRegisterOsContext(commandStreamReceiver,
EngineTypeUsage{aub_stream::ENGINE_CCS, EngineUsage::Regular},
this->getDeviceBitfield(),
PreemptionMode::Disabled, true);
EngineDescriptor engineDescriptor = {EngineTypeUsage{aub_stream::ENGINE_CCS, EngineUsage::Regular}, this->getDeviceBitfield(), PreemptionMode::Disabled, true};
OsContext *osContext = getMemoryManager()->createAndRegisterOsContext(commandStreamReceiver, engineDescriptor);
commandStreamReceiver->setupContext(*osContext);
this->engines.resize(1);
this->engines[0] = {commandStreamReceiver, osContext};

View File

@@ -19,6 +19,7 @@
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/fixtures/mock_execution_environment_gmm_fixture.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/engine_descriptor_helper.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_wddm.h"
#include "shared/test/common/mocks/mock_wddm_interface20.h"
@@ -48,8 +49,7 @@ struct WddmFixture : public Test<MockExecutionEnvironmentGmmFixture> {
wddm->init();
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, 1u, engine, preemptionMode,
false);
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
osContext->ensureContextInitialized();
mockTemporaryResources = static_cast<MockWddmResidentAllocationsContainer *>(wddm->temporaryResources.get());
}
@@ -85,8 +85,7 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture, public MockExecutionEnv
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
auto engine = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, 1, engine, preemptionMode,
false);
osContext = std::make_unique<OsContextWin>(*osInterface->getDriverModel()->as<Wddm>(), 0u, EngineDescriptorHelper::getDefaultDescriptor(engine, preemptionMode));
osContext->ensureContextInitialized();
}