Refactoring hwinfoconfig

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2021-05-24 21:06:15 +02:00
committed by Compute-Runtime-Automation
parent 67aa1ad7ec
commit bc92cbf9e7
32 changed files with 303 additions and 179 deletions

View File

@@ -13,6 +13,7 @@ set(NEO_CORE_OS_INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/device_factory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_factory.h
${CMAKE_CURRENT_SOURCE_DIR}/driver_info.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.inl
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_bdw_plus.inl

View File

@@ -0,0 +1,14 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
HwInfoConfig *hwInfoConfigFactory[IGFX_MAX_PRODUCT] = {};
} // namespace NEO

View File

@@ -25,7 +25,8 @@ class HwInfoConfig {
static HwInfoConfig *get(PRODUCT_FAMILY product) {
return hwInfoConfigFactory[product];
}
int configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface);
int configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface);
int configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface);
virtual int configureHardwareCustom(HardwareInfo *hwInfo, OSInterface *osIface) = 0;
virtual void adjustPlatformForProductFamily(HardwareInfo *hwInfo) = 0;
virtual void adjustSamplerState(void *sampler, const HardwareInfo &hwInfo) = 0;

View File

@@ -11,6 +11,8 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/cache_info_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/device_time_drm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_time_drm.h
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_wddm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_allocation.cpp
@@ -36,7 +38,8 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_memory_operations_handler_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/drm_query_extended.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_wddm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/linux_inc.cpp

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
return OSInterface::discoverDevicesDrm(executionEnvironment);
}
} // namespace NEO

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesWddm(ExecutionEnvironment &executionEnvironment) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -382,7 +382,7 @@ void appendHwDeviceId(std::vector<std::unique_ptr<HwDeviceId>> &hwDeviceIds, int
}
}
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesDrm(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> hwDeviceIds;
executionEnvironment.osEnvironment = std::make_unique<OsEnvironment>();
std::string devicePrefix = std::string(Os::pciDevicesDirectory) + "/pci-0000:";

View File

@@ -5,13 +5,12 @@
*
*/
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/utilities/cpu_info.h"
@@ -22,8 +21,6 @@
namespace NEO {
HwInfoConfig *hwInfoConfigFactory[IGFX_MAX_PRODUCT] = {};
uint32_t bitExact(uint32_t value, uint32_t highBit, uint32_t lowBit) {
uint32_t bitVal = static_cast<uint32_t>((value >> lowBit) & maxNBitValue(highBit - lowBit + 1));
return bitVal;
@@ -67,7 +64,7 @@ int configureCacheInfo(HardwareInfo *hwInfo) {
return 0;
}
int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
int ret = 0;
Drm *drm = osIface->getDriverModel()->as<Drm>();

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -42,7 +42,7 @@ bool RootDeviceEnvironment::initOsInterface(std::unique_ptr<HwDeviceId> &&hwDevi
osInterface->setDriverModel(std::unique_ptr<DriverModel>(drm));
auto hardwareInfo = getMutableHardwareInfo();
HwInfoConfig *hwConfig = HwInfoConfig::get(hardwareInfo->platform.eProductFamily);
if (hwConfig->configureHwInfo(hardwareInfo, hardwareInfo, osInterface.get())) {
if (hwConfig->configureHwInfoDrm(hardwareInfo, hardwareInfo, osInterface.get())) {
return false;
}
memoryOperationsInterface = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex);

View File

@@ -99,6 +99,8 @@ class OSInterface : public NonCopyableClass {
static bool gpuIdleImplicitFlush;
static bool requiresSupportForWddmTrimNotification;
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevicesWddm(ExecutionEnvironment &executionEnvironment);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevicesDrm(ExecutionEnvironment &executionEnvironment);
protected:
std::unique_ptr<DriverModel> driverModel = nullptr;

View File

@@ -23,12 +23,15 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/device_time_wddm.h
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver_info_windows.h
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_drm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/discover_devices_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/environment_variables.h
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_wddm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_drm_stub.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener${KMDAF_FILE_SUFFIX}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kmdaf_listener.h
${CMAKE_CURRENT_SOURCE_DIR}/os_context_win.cpp

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesDrm(ExecutionEnvironment &executionEnvironment) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
return OSInterface::discoverDevicesWddm(executionEnvironment);
}
} // namespace NEO

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
int HwInfoConfig::configureHwInfoDrm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
UNRECOVERABLE_IF(true);
return {};
}
} // namespace NEO

View File

@@ -5,21 +5,18 @@
*
*/
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "hw_cmds.h"
namespace NEO {
HwInfoConfig *hwInfoConfigFactory[IGFX_MAX_PRODUCT] = {};
int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
int HwInfoConfig::configureHwInfoWddm(const HardwareInfo *inHwInfo, HardwareInfo *outHwInfo, OSInterface *osIface) {
HwHelper &hwHelper = HwHelper::get(outHwInfo->platform.eRenderCoreFamily);
outHwInfo->capabilityTable.ftrSvm = outHwInfo->featureTable.ftrSVM;

View File

@@ -107,7 +107,7 @@ bool Wddm::init() {
HwInfoConfig *hwConfig = HwInfoConfig::get(productFamily);
hwConfig->adjustPlatformForProductFamily(hardwareInfo.get());
if (hwConfig->configureHwInfo(hardwareInfo.get(), hardwareInfo.get(), nullptr)) {
if (hwConfig->configureHwInfoWddm(hardwareInfo.get(), hardwareInfo.get(), nullptr)) {
return false;
}
@@ -298,7 +298,7 @@ std::unique_ptr<HwDeviceIdWddm> createHwDeviceIdFromAdapterLuid(OsEnvironmentWin
return std::make_unique<HwDeviceIdWddm>(OpenAdapterData.hAdapter, adapterLuid, &osEnvironment, std::move(umKmDataTranslator));
}
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevices(ExecutionEnvironment &executionEnvironment) {
std::vector<std::unique_ptr<HwDeviceId>> OSInterface::discoverDevicesWddm(ExecutionEnvironment &executionEnvironment) {
auto osEnvironment = new OsEnvironmentWin();
auto gdi = osEnvironment->gdi.get();

View File

@@ -113,7 +113,7 @@ HWTEST2_F(HwConfigTopologyQuery, WhenGettingTopologyFailsThenSetMaxValuesBasedOn
hwInfo.gtSystemInfo.MaxEuPerSubSlice = 6;
auto hwConfig = HwInfoConfigHw<productFamily>::get();
int ret = hwConfig->configureHwInfo(&hwInfo, &outHwInfo, osInterface.get());
int ret = hwConfig->configureHwInfoDrm(&hwInfo, &outHwInfo, osInterface.get());
EXPECT_NE(-1, ret);
EXPECT_EQ(6u, outHwInfo.gtSystemInfo.MaxEuPerSubSlice);