Move hwHelper ownership to RootDeviceEnvironment 4/n

Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>

UseRootDeviceEnvironment getHelper<CoreHelper> for:
- isLocalMemoryEnabled
- getSipKernelType
- is1MbAlignmentSupported
This commit is contained in:
Kamil Kopryk
2022-11-14 16:34:34 +00:00
committed by Compute-Runtime-Automation
parent 62db166cee
commit 211cc8552a
12 changed files with 62 additions and 56 deletions

View File

@@ -1041,11 +1041,11 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
neoDevice->incRefInternal();
auto &hwInfo = neoDevice->getHardwareInfo();
auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
auto &coreHelper = neoDevice->getRootDeviceEnvironment().getHelper<NEO::CoreHelper>();
device->execEnvironment = (void *)neoDevice->getExecutionEnvironment();
device->allocationsForReuse = std::make_unique<NEO::AllocationsList>();
bool platformImplicitScaling = hwHelper.platformSupportsImplicitScaling(hwInfo);
bool platformImplicitScaling = coreHelper.platformSupportsImplicitScaling(hwInfo);
device->implicitScalingCapable = NEO::ImplicitScalingHelper::isImplicitScalingEnabled(neoDevice->getDeviceBitfield(), platformImplicitScaling);
device->metricContext = MetricDeviceContext::create(*device);
device->builtins = BuiltinFunctionsLib::create(
@@ -1056,7 +1056,7 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
auto osInterface = neoDevice->getRootDeviceEnvironment().osInterface.get();
device->driverInfo.reset(NEO::DriverInfo::create(&hwInfo, osInterface));
auto debugSurfaceSize = hwHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
auto debugSurfaceSize = coreHelper.getSipKernelMaxDbgSurfaceSize(hwInfo);
std::vector<char> stateSaveAreaHeader;
if (neoDevice->getDebugger() || neoDevice->getPreemptionMode() == NEO::PreemptionMode::MidThread) {
@@ -1085,8 +1085,8 @@ Device *Device::create(DriverHandle *driverHandle, NEO::Device *neoDevice, bool
}
if (debugSurface && stateSaveAreaHeader.size() > 0) {
const auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
NEO::MemoryTransferHelper::transferMemoryToAllocation(hwInfoConfig.isBlitCopyRequiredForLocalMemory(hwInfo, *debugSurface),
const auto &productHelper = neoDevice->getRootDeviceEnvironment().getHelper<NEO::ProductHelper>();
NEO::MemoryTransferHelper::transferMemoryToAllocation(productHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *debugSurface),
*neoDevice, debugSurface, 0, stateSaveAreaHeader.data(),
stateSaveAreaHeader.size());
}

View File

@@ -68,7 +68,8 @@ void ClDevice::setupFp64Flags() {
void ClDevice::initializeCaps() {
auto &hwInfo = getHardwareInfo();
auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily);
auto &productHelper = getRootDeviceEnvironment().getHelper<ProductHelper>();
auto &coreHelper = getRootDeviceEnvironment().getHelper<CoreHelper>();
auto &sharedDeviceInfo = getSharedDeviceInfo();
deviceExtensions.clear();
deviceExtensions.append(deviceExtensionsList);
@@ -89,8 +90,6 @@ void ClDevice::initializeCaps() {
sharingFactory.verifyExtensionSupport(driverInfo.get());
}
auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily);
deviceInfo.name = name.c_str();
deviceInfo.driverVersion = driverVersion.c_str();
@@ -141,7 +140,7 @@ void ClDevice::initializeCaps() {
auto simdSizeUsed = DebugManager.flags.UseMaxSimdSizeToDeduceMaxWorkgroupSize.get()
? CommonConstants::maximalSimdSize
: hwHelper.getMinimalSIMDSize();
: coreHelper.getMinimalSIMDSize();
// calculate a maximum number of subgroups in a workgroup (for the required SIMD size)
deviceInfo.maxNumOfSubGroups = static_cast<uint32_t>(sharedDeviceInfo.maxWorkGroupSize / simdSizeUsed);
@@ -204,7 +203,7 @@ void ClDevice::initializeCaps() {
deviceExtensions += "cl_intel_media_block_io ";
}
if (hwInfoConfig->isBFloat16ConversionSupported(hwInfo)) {
if (productHelper.isBFloat16ConversionSupported(hwInfo)) {
deviceExtensions += "cl_intel_bfloat16_conversions ";
}
@@ -228,7 +227,7 @@ void ClDevice::initializeCaps() {
deviceExtensions += "cl_khr_pci_bus_info ";
}
deviceExtensions += hwHelper.getExtensions(hwInfo);
deviceExtensions += coreHelper.getExtensions(hwInfo);
deviceInfo.deviceExtensions = deviceExtensions.c_str();
std::vector<std::string> exposedBuiltinKernelsVector;
@@ -252,7 +251,7 @@ void ClDevice::initializeCaps() {
deviceInfo.deviceType = CL_DEVICE_TYPE_GPU;
deviceInfo.endianLittle = 1;
deviceInfo.hostUnifiedMemory = (false == hwHelper.isLocalMemoryEnabled(hwInfo));
deviceInfo.hostUnifiedMemory = (false == coreHelper.isLocalMemoryEnabled(hwInfo));
deviceInfo.deviceAvailable = CL_TRUE;
deviceInfo.compilerAvailable = CL_TRUE;
deviceInfo.parentDevice = nullptr;
@@ -284,7 +283,7 @@ void ClDevice::initializeCaps() {
deviceInfo.maxReadWriteImageArgs = hwInfo.capabilityTable.supportsImages ? 128 : 0;
deviceInfo.executionCapabilities = CL_EXEC_KERNEL;
//copy system info to prevent misaligned reads
// copy system info to prevent misaligned reads
const auto systemInfo = hwInfo.gtSystemInfo;
const auto subDevicesCount = std::max(getNumGenericSubDevices(), 1u);
@@ -326,11 +325,11 @@ void ClDevice::initializeCaps() {
deviceInfo.localMemType = CL_LOCAL;
deviceInfo.image3DMaxWidth = hwHelper.getMax3dImageWidthOrHeight();
deviceInfo.image3DMaxHeight = hwHelper.getMax3dImageWidthOrHeight();
deviceInfo.image3DMaxWidth = coreHelper.getMax3dImageWidthOrHeight();
deviceInfo.image3DMaxHeight = coreHelper.getMax3dImageWidthOrHeight();
// cl_khr_image2d_from_buffer
deviceInfo.imagePitchAlignment = hwHelper.getPitchAlignmentForImage(&hwInfo);
deviceInfo.imagePitchAlignment = coreHelper.getPitchAlignmentForImage(&hwInfo);
deviceInfo.imageBaseAddressAlignment = 4;
deviceInfo.queueOnHostProperties = CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE;
@@ -393,7 +392,7 @@ void ClDevice::initializeCaps() {
deviceInfo.globalVariablePreferredTotalSize = ocl21FeaturesEnabled ? static_cast<size_t>(sharedDeviceInfo.maxMemAllocSize) : 0;
deviceInfo.planarYuvMaxWidth = 16384;
deviceInfo.planarYuvMaxHeight = hwHelper.getPlanarYuvMaxHeight();
deviceInfo.planarYuvMaxHeight = coreHelper.getPlanarYuvMaxHeight();
deviceInfo.vmeAvcSupportsTextureSampler = hwInfo.capabilityTable.ftrSupportsVmeAvcTextureSampler;
if (hwInfo.capabilityTable.supportsVme) {
@@ -408,15 +407,15 @@ void ClDevice::initializeCaps() {
deviceInfo.preferredLocalAtomicAlignment = MemoryConstants::cacheLineSize;
deviceInfo.preferredPlatformAtomicAlignment = MemoryConstants::cacheLineSize;
deviceInfo.preferredWorkGroupSizeMultiple = hwHelper.isFusedEuDispatchEnabled(hwInfo, false)
deviceInfo.preferredWorkGroupSizeMultiple = coreHelper.isFusedEuDispatchEnabled(hwInfo, false)
? CommonConstants::maximalSimdSize * 2
: CommonConstants::maximalSimdSize;
deviceInfo.hostMemCapabilities = hwInfoConfig->getHostMemCapabilities(&hwInfo);
deviceInfo.deviceMemCapabilities = hwInfoConfig->getDeviceMemCapabilities();
deviceInfo.singleDeviceSharedMemCapabilities = hwInfoConfig->getSingleDeviceSharedMemCapabilities();
deviceInfo.crossDeviceSharedMemCapabilities = hwInfoConfig->getCrossDeviceSharedMemCapabilities();
deviceInfo.sharedSystemMemCapabilities = hwInfoConfig->getSharedSystemMemCapabilities(&hwInfo);
deviceInfo.hostMemCapabilities = productHelper.getHostMemCapabilities(&hwInfo);
deviceInfo.deviceMemCapabilities = productHelper.getDeviceMemCapabilities();
deviceInfo.singleDeviceSharedMemCapabilities = productHelper.getSingleDeviceSharedMemCapabilities();
deviceInfo.crossDeviceSharedMemCapabilities = productHelper.getCrossDeviceSharedMemCapabilities();
deviceInfo.sharedSystemMemCapabilities = productHelper.getSharedSystemMemCapabilities(&hwInfo);
initializeOsSpecificCaps();
getOpenclCFeaturesList(hwInfo, deviceInfo.openclCFeatures);

View File

@@ -944,9 +944,8 @@ TEST_F(DeviceGetCapsTest, givenNotSupporteImagesWhenCreateExtentionsListThenDevi
TEST_F(DeviceGetCapsTest, givenDeviceWhenGettingHostUnifiedMemoryCapThenItDependsOnLocalMemory) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
const auto &caps = device->getDeviceInfo();
auto &hwHelper = HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
auto localMemoryEnabled = hwHelper.isLocalMemoryEnabled(*defaultHwInfo);
auto &coreHelper = device->getRootDeviceEnvironment().getHelper<CoreHelper>();
auto localMemoryEnabled = coreHelper.isLocalMemoryEnabled(*defaultHwInfo);
EXPECT_EQ((localMemoryEnabled == false), caps.hostUnifiedMemory);
}

View File

@@ -419,13 +419,13 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, WhenGettingSupportedDeviceFeatureCapabilities
GEN12LPTEST_F(HwHelperTestGen12Lp, givenLocalMemoryFeatureDisabledWhenIsLocalMemoryEnabledIsCalledThenTrueIsReturned) {
hardwareInfo.featureTable.flags.ftrLocalMemory = true;
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
EXPECT_TRUE(helper.isLocalMemoryEnabled(hardwareInfo));
auto &coreHelper = getHelper<CoreHelper>();
EXPECT_TRUE(coreHelper.isLocalMemoryEnabled(hardwareInfo));
}
GEN12LPTEST_F(HwHelperTestGen12Lp, givenLocalMemoryFeatureEnabledWhenIsLocalMemoryEnabledIsCalledThenFalseIsReturned) {
hardwareInfo.featureTable.flags.ftrLocalMemory = false;
auto &helper = reinterpret_cast<HwHelperHw<FamilyType> &>(HwHelperHw<FamilyType>::get());
EXPECT_FALSE(helper.isLocalMemoryEnabled(hardwareInfo));
auto &coreHelper = getHelper<CoreHelper>();
EXPECT_FALSE(coreHelper.isLocalMemoryEnabled(hardwareInfo));
}

View File

@@ -1306,12 +1306,12 @@ TEST(OsAgnosticMemoryManager, givenLocalMemoryAndDebugModuleAreaTypeWhenCreating
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableLocalMemory.set(true);
// Ensure family supports local memory
if (!HwHelper::get(hwInfo.platform.eRenderCoreFamily).isLocalMemoryEnabled(hwInfo)) {
MockExecutionEnvironment executionEnvironment(&hwInfo);
auto &coreHelper = executionEnvironment.rootDeviceEnvironments[0]->getHelper<CoreHelper>();
if (!coreHelper.isLocalMemoryEnabled(hwInfo)) {
GTEST_SKIP();
}
MockExecutionEnvironment executionEnvironment(&hwInfo);
MemoryManagerCreate<OsAgnosticMemoryManager> memoryManager(false, true, executionEnvironment);
const auto size = MemoryConstants::pageSize64k;

View File

@@ -879,8 +879,11 @@ TEST(SourceLevelDebugger, givenDebuggerLibraryAvailableAndExperimentalEnableSour
DebugManager.flags.ExperimentalEnableSourceLevelDebugger.set(1);
auto hwInfo = *defaultHwInfo;
auto debugger = std::unique_ptr<Debugger>(Debugger::create(&hwInfo));
auto executionEnvironment = new ExecutionEnvironment();
MockPlatform platform(*executionEnvironment);
platform.initializeWithNewDevices();
auto debugger = std::unique_ptr<Debugger>(Debugger::create(*executionEnvironment->rootDeviceEnvironments[0].get()));
ASSERT_NE(nullptr, debugger.get());
EXPECT_TRUE(debugger->isLegacy());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,24 +8,27 @@
#include "shared/source/debugger/debugger.h"
#include "shared/source/built_ins/sip_kernel_type.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/source_level_debugger/source_level_debugger.h"
namespace NEO {
std::unique_ptr<Debugger> Debugger::create(HardwareInfo *hwInfo) {
std::unique_ptr<Debugger> Debugger::create(const RootDeviceEnvironment &rootDeviceEnvironment) {
std::unique_ptr<SourceLevelDebugger> sourceLevelDebugger;
if (hwInfo->capabilityTable.debuggerSupported || DebugManager.flags.ExperimentalEnableSourceLevelDebugger.get()) {
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
if (hwInfo.capabilityTable.debuggerSupported || DebugManager.flags.ExperimentalEnableSourceLevelDebugger.get()) {
sourceLevelDebugger.reset(SourceLevelDebugger::create());
}
if (sourceLevelDebugger) {
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == hwHelper.getSipKernelType(true));
auto &coreHelper = rootDeviceEnvironment.getHelper<CoreHelper>();
bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == coreHelper.getSipKernelType(true));
sourceLevelDebugger->initialize(localMemorySipAvailable);
if (sourceLevelDebugger->isDebuggerActive()) {
hwInfo->capabilityTable.fusedEuEnabled = false;
hwInfo.capabilityTable.fusedEuEnabled = false;
}
}
return sourceLevelDebugger;

View File

@@ -13,6 +13,7 @@ class LinearStream;
class IndirectHeap;
struct DebugData;
class GraphicsAllocation;
struct RootDeviceEnvironment;
class Debugger {
public:
@@ -27,7 +28,7 @@ class Debugger {
uint64_t BindlessSamplerStateBaseAddress = 0;
};
static std::unique_ptr<Debugger> create(HardwareInfo *hwInfo);
static std::unique_ptr<Debugger> create(const NEO::RootDeviceEnvironment &rootDeviceEnvironment);
virtual ~Debugger() = default;
bool isLegacy() const { return isLegacyMode; }
virtual void captureStateBaseAddress(NEO::LinearStream &cmdStream, SbaAddresses sba) = 0;

View File

@@ -45,7 +45,7 @@ void RootDeviceEnvironment::initAubCenter(bool localMemoryEnabled, const std::st
}
void RootDeviceEnvironment::initDebugger() {
debugger = Debugger::create(hwInfo.get());
debugger = Debugger::create(*this);
}
void RootDeviceEnvironment::initDebuggerL0(Device *neoDevice) {

View File

@@ -155,9 +155,10 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithGpuVa(con
GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const AllocationData &allocationData) {
AllocationData allocationDataAlign = allocationData;
allocationDataAlign.size = alignUp(allocationData.size, MemoryConstants::pageSize64k);
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
allocationDataAlign.alignment = hwHelper.is1MbAlignmentSupported(*hwInfo, allocationData.flags.preferCompressed)
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get();
auto hwInfo = rootDeviceEnvironment.getHardwareInfo();
auto &coreHelper = rootDeviceEnvironment.getHelper<CoreHelper>();
allocationDataAlign.alignment = coreHelper.is1MbAlignmentSupported(*hwInfo, allocationData.flags.preferCompressed)
? MemoryConstants::megaByte
: MemoryConstants::pageSize64k;
auto memoryAllocation = allocateGraphicsMemoryWithAlignment(allocationDataAlign);

View File

@@ -36,9 +36,9 @@ GEN9TEST_F(HwHelperTestGen9, WhenAdjustingDefaultEngineTypeThenEngineTypeIsSet)
}
GEN9TEST_F(HwHelperTestGen9, givenDebuggingActiveWhenSipKernelTypeIsQueriedThenDbgCsrLocalTypeIsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
auto &coreHelper = getHelper<CoreHelper>();
auto sipType = helper.getSipKernelType(true);
auto sipType = coreHelper.getSipKernelType(true);
EXPECT_EQ(SipKernelType::DbgCsrLocal, sipType);
}

View File

@@ -123,10 +123,10 @@ HWTEST_F(HwHelperTest, WhenSettingRenderSurfaceStateForBufferThenL1CachePolicyIs
}
TEST_F(HwHelperTest, givenDebuggingInactiveWhenSipKernelTypeIsQueriedThenCsrTypeIsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_NE(nullptr, &helper);
auto &coreHelper = getHelper<CoreHelper>();
EXPECT_NE(nullptr, &coreHelper);
auto sipType = helper.getSipKernelType(false);
auto sipType = coreHelper.getSipKernelType(false);
EXPECT_EQ(SipKernelType::Csr, sipType);
}
@@ -767,21 +767,21 @@ HWCMDTEST_F(IGFX_GEN8_CORE, HwHelperTest, givenHwHelperWhenGettingGlobalTimeStam
TEST_F(HwHelperTest, givenEnableLocalMemoryDebugVarAndOsEnableLocalMemoryWhenSetThenGetEnableLocalMemoryReturnsCorrectValue) {
DebugManagerStateRestore dbgRestore;
VariableBackup<bool> orgOsEnableLocalMemory(&OSInterface::osEnableLocalMemory);
auto &helper = HwHelper::get(renderCoreFamily);
auto &coreHelper = getHelper<CoreHelper>();
DebugManager.flags.EnableLocalMemory.set(0);
EXPECT_FALSE(helper.getEnableLocalMemory(hardwareInfo));
EXPECT_FALSE(coreHelper.getEnableLocalMemory(hardwareInfo));
DebugManager.flags.EnableLocalMemory.set(1);
EXPECT_TRUE(helper.getEnableLocalMemory(hardwareInfo));
EXPECT_TRUE(coreHelper.getEnableLocalMemory(hardwareInfo));
DebugManager.flags.EnableLocalMemory.set(-1);
OSInterface::osEnableLocalMemory = false;
EXPECT_FALSE(helper.getEnableLocalMemory(hardwareInfo));
EXPECT_FALSE(coreHelper.getEnableLocalMemory(hardwareInfo));
OSInterface::osEnableLocalMemory = true;
EXPECT_EQ(helper.isLocalMemoryEnabled(hardwareInfo), helper.getEnableLocalMemory(hardwareInfo));
EXPECT_EQ(coreHelper.isLocalMemoryEnabled(hardwareInfo), coreHelper.getEnableLocalMemory(hardwareInfo));
}
TEST_F(HwHelperTest, givenAUBDumpForceAllToLocalMemoryDebugVarWhenSetThenGetEnableLocalMemoryReturnsCorrectValue) {