4 changes: 3 additions & 1 deletion shared/source/os_interface/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/settings_reader_create.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sys_calls.h
${CMAKE_CURRENT_SOURCE_DIR}/system_info.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/system_info_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/system_info_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/system_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/system_info_external.cpp
)

if(DISABLE_WDDM_LINUX)
Expand Down
32 changes: 32 additions & 0 deletions shared/source/os_interface/linux/drm_neo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "shared/source/os_interface/linux/pci_path.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include "shared/source/os_interface/linux/system_info.h"
#include "shared/source/os_interface/linux/system_info_impl.h"
#include "shared/source/os_interface/os_environment.h"
#include "shared/source/os_interface/os_interface.h"
#include "shared/source/utilities/directory.h"
Expand Down Expand Up @@ -752,4 +753,35 @@ int Drm::getTimestampFrequency(int &frequency) {
return getParamIoctl(I915_PARAM_CS_TIMESTAMP_FREQUENCY, &frequency);
}

bool Drm::querySystemInfo() {
auto length = 0;

auto deviceBlobQuery = this->query(DRM_I915_QUERY_HWCONFIG_TABLE, DrmQueryItemFlags::empty, length);
auto deviceBlob = reinterpret_cast<uint32_t *>(deviceBlobQuery.get());
if (!deviceBlob) {
PRINT_DEBUG_STRING(DebugManager.flags.PrintDebugMessages.get(), stdout, "%s", "INFO: System Info query failed!\n");
return false;
}
this->systemInfo.reset(new SystemInfoImpl(deviceBlob, length));

return true;
}

void Drm::setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo) {
GT_SYSTEM_INFO *gtSysInfo = &hwInfo->gtSystemInfo;
gtSysInfo->ThreadCount = gtSysInfo->EUCount * sysInfo->getNumThreadsPerEu();
gtSysInfo->L3CacheSizeInKb = sysInfo->getL3CacheSizeInKb();
gtSysInfo->L3BankCount = sysInfo->getL3BankCount();
gtSysInfo->MaxFillRate = sysInfo->getMaxFillRate();
gtSysInfo->TotalVsThreads = sysInfo->getTotalVsThreads();
gtSysInfo->TotalHsThreads = sysInfo->getTotalHsThreads();
gtSysInfo->TotalDsThreads = sysInfo->getTotalDsThreads();
gtSysInfo->TotalGsThreads = sysInfo->getTotalGsThreads();
gtSysInfo->TotalPsThreadsWindowerRange = sysInfo->getTotalPsThreads();
gtSysInfo->MaxEuPerSubSlice = sysInfo->getMaxEuPerDualSubSlice();
gtSysInfo->MaxSlicesSupported = sysInfo->getMaxSlicesSupported();
gtSysInfo->MaxSubSlicesSupported = sysInfo->getMaxDualSubSlicesSupported();
gtSysInfo->MaxDualSubSlicesSupported = sysInfo->getMaxDualSubSlicesSupported();
}

} // namespace NEO
6 changes: 0 additions & 6 deletions shared/source/os_interface/linux/drm_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
return 0;
}

bool Drm::querySystemInfo() {
return false;
}

void Drm::setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo) {}

bool Drm::queryEngineInfo(bool isSysmanEnabled) {
auto length = 0;
auto dataQuery = this->query(DRM_I915_QUERY_ENGINE_INFO, DrmQueryItemFlags::empty, length);
Expand Down
6 changes: 0 additions & 6 deletions shared/source/os_interface/linux/drm_query_dg1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ int Drm::getMaxGpuFrequency(HardwareInfo &hwInfo, int &maxGpuFrequency) {
return 0;
}

bool Drm::querySystemInfo() {
return false;
}

void Drm::setupSystemInfo(HardwareInfo *hwInfo, SystemInfo *sysInfo) {}

bool Drm::queryEngineInfo(bool isSysmanEnabled) {
auto length = 0;
auto dataQuery = this->query(DRM_I915_QUERY_ENGINE_INFO, DrmQueryItemFlags::empty, length);
Expand Down
73 changes: 73 additions & 0 deletions shared/source/os_interface/linux/system_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/os_interface/linux/system_info_impl.h"
namespace NEO {

SystemInfoImpl::SystemInfoImpl(const uint32_t *blobData, int32_t blobSize) {
this->parseDeviceBlob(blobData, blobSize);
}

void SystemInfoImpl::parseDeviceBlob(const uint32_t *data, int32_t size) {

uint32_t i = 0;
while (i < (size / sizeof(uint32_t))) {
DEBUG_BREAK_IF(data[i + 1] < 1);

/* Attribute IDs range */
DEBUG_BREAK_IF(data[i] < 1);

if (INTEL_HWCONFIG_MAX_SLICES_SUPPORTED == data[i]) {
maxSlicesSupported = data[i + 2];
}
if (INTEL_HWCONFIG_MAX_DUAL_SUBSLICES_SUPPORTED == data[i]) {
maxDualSubSlicesSupported = data[i + 2];
}
if (INTEL_HWCONFIG_MAX_NUM_EU_PER_DSS == data[i]) {
maxEuPerDualSubSlice = data[i + 2];
}
if (INTEL_HWCONFIG_L3_CACHE_SIZE_IN_KB == data[i]) {
L3CacheSizeInKb = data[i + 2];
}
if (INTEL_HWCONFIG_L3_BANK_COUNT == data[i]) {
L3BankCount = data[i + 2];
}
if (INTEL_HWCONFIG_NUM_THREADS_PER_EU == data[i]) {
numThreadsPerEu = data[i + 2];
}
if (INTEL_HWCONFIG_TOTAL_VS_THREADS == data[i]) {
totalVsThreads = data[i + 2];
}
if (INTEL_HWCONFIG_TOTAL_HS_THREADS == data[i]) {
totalHsThreads = data[i + 2];
}
if (INTEL_HWCONFIG_TOTAL_DS_THREADS == data[i]) {
totalDsThreads = data[i + 2];
}
if (INTEL_HWCONFIG_TOTAL_GS_THREADS == data[i]) {
totalGsThreads = data[i + 2];
}
if (INTEL_HWCONFIG_TOTAL_PS_THREADS == data[i]) {
totalPsThreads = data[i + 2];
}
if (INTEL_HWCONFIG_MAX_FILL_RATE == data[i]) {
maxFillRate = data[i + 2];
}
if (INTEL_HWCONFIG_MAX_RCS == data[i]) {
maxRCS = data[i + 2];
}
if (INTEL_HWCONFIG_MAX_CCS == data[i]) {
maxCCS = data[i + 2];
}
/* Skip to next attribute */
auto blobLength = 2 + data[i + 1];
i += blobLength;
}
}

} // namespace NEO
11 changes: 11 additions & 0 deletions shared/source/os_interface/linux/system_info_external.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "shared/source/os_interface/linux/system_info_impl.h"
namespace NEO {
void checkSysInfoMismatch(HardwareInfo *hwInfo) {}
} // namespace NEO
56 changes: 38 additions & 18 deletions shared/source/os_interface/linux/system_info_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,49 @@
#pragma once
#include "shared/source/os_interface/linux/system_info.h"

#include "drm/i915_drm.h"
#include "drm/intel_hwconfig_types.h"

namespace NEO {
struct HardwareInfo;
struct SystemInfoImpl : public SystemInfo {
~SystemInfoImpl() override = default;

SystemInfoImpl(const uint32_t *data, int32_t length) {
}

uint32_t getMaxSlicesSupported() const override { return 0; }
uint32_t getMaxDualSubSlicesSupported() const override { return 0; }
uint32_t getMaxEuPerDualSubSlice() const override { return 0; }
uint64_t getL3CacheSizeInKb() const override { return 0; }
uint32_t getL3BankCount() const override { return 0; }
uint32_t getNumThreadsPerEu() const override { return 0; }
uint32_t getTotalVsThreads() const override { return 0; }
uint32_t getTotalHsThreads() const override { return 0; }
uint32_t getTotalDsThreads() const override { return 0; }
uint32_t getTotalGsThreads() const override { return 0; }
uint32_t getTotalPsThreads() const override { return 0; }
uint32_t getMaxFillRate() const override { return 0; }
uint32_t getMaxRCS() const override { return 0; }
uint32_t getMaxCCS() const override { return 0; }
void checkSysInfoMismatch(HardwareInfo *hwInfo) override {}
SystemInfoImpl(const uint32_t *data, int32_t length);

uint32_t getMaxSlicesSupported() const override { return maxSlicesSupported; }
uint32_t getMaxDualSubSlicesSupported() const override { return maxDualSubSlicesSupported; }
uint32_t getMaxEuPerDualSubSlice() const override { return maxEuPerDualSubSlice; }
uint64_t getL3CacheSizeInKb() const override { return L3CacheSizeInKb; }
uint32_t getL3BankCount() const override { return L3BankCount; }
uint32_t getNumThreadsPerEu() const override { return numThreadsPerEu; }
uint32_t getTotalVsThreads() const override { return totalVsThreads; }
uint32_t getTotalHsThreads() const override { return totalHsThreads; }
uint32_t getTotalDsThreads() const override { return totalDsThreads; }
uint32_t getTotalGsThreads() const override { return totalGsThreads; }
uint32_t getTotalPsThreads() const override { return totalPsThreads; }
uint32_t getMaxFillRate() const override { return maxFillRate; }
uint32_t getMaxRCS() const override { return maxRCS; }
uint32_t getMaxCCS() const override { return maxCCS; }
void checkSysInfoMismatch(HardwareInfo *hwInfo) override;

protected:
void parseDeviceBlob(const uint32_t *data, int32_t size);

uint32_t maxSlicesSupported = 0;
uint32_t maxDualSubSlicesSupported = 0;
uint32_t maxEuPerDualSubSlice = 0;
uint64_t L3CacheSizeInKb = 0;
uint32_t L3BankCount = 0;
uint32_t numThreadsPerEu = 0;
uint32_t totalVsThreads = 0;
uint32_t totalHsThreads = 0;
uint32_t totalDsThreads = 0;
uint32_t totalGsThreads = 0;
uint32_t totalPsThreads = 0;
uint32_t maxFillRate = 0;
uint32_t maxRCS = 0;
uint32_t maxCCS = 0;
};

} // namespace NEO