Move query topology method to new file

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-01-25 19:11:42 +01:00
committed by Compute-Runtime-Automation
parent 992e69592b
commit e4c8db2159
3 changed files with 55 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2020 Intel Corporation
# Copyright (C) 2019-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -31,6 +31,7 @@ set(NEO_CORE_OS_INTERFACE_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/drm_memory_operations_handler_default.cpp
${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_device_id.h
${CMAKE_CURRENT_SOURCE_DIR}/hw_device_id_linux.cpp

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -440,44 +440,6 @@ std::unique_ptr<uint8_t[]> Drm::query(uint32_t queryId, uint32_t queryItemFlags,
return data;
}
bool Drm::queryTopology(int &sliceCount, int &subSliceCount, int &euCount) {
int32_t length;
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology, length);
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.get());
if (!data) {
return false;
}
sliceCount = 0;
subSliceCount = 0;
euCount = 0;
for (int x = 0; x < data->max_slices; x++) {
bool isSliceEnable = (data->data[x / 8] >> (x % 8)) & 1;
if (!isSliceEnable) {
continue;
}
sliceCount++;
for (int y = 0; y < data->max_subslices; y++) {
bool isSubSliceEnabled = (data->data[data->subslice_offset + x * data->subslice_stride + y / 8] >> (y % 8)) & 1;
if (!isSubSliceEnabled) {
continue;
}
subSliceCount++;
for (int z = 0; z < data->max_eus_per_subslice; z++) {
bool isEUEnabled = (data->data[data->eu_offset + (x * data->max_subslices + y) * data->eu_stride + z / 8] >> (z % 8)) & 1;
if (!isEUEnabled) {
continue;
}
euCount++;
}
}
}
return (sliceCount && subSliceCount && euCount);
}
bool Drm::createVirtualMemoryAddressSpace(uint32_t vmCount) {
for (auto i = 0u; i < vmCount; i++) {
uint32_t id = 0;

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "drm_query_flags.h"
namespace NEO {
bool Drm::queryTopology(int &sliceCount, int &subSliceCount, int &euCount) {
int32_t length;
auto dataQuery = this->query(DRM_I915_QUERY_TOPOLOGY_INFO, DrmQueryItemFlags::topology, length);
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.get());
if (!data) {
return false;
}
sliceCount = 0;
subSliceCount = 0;
euCount = 0;
for (int x = 0; x < data->max_slices; x++) {
bool isSliceEnable = (data->data[x / 8] >> (x % 8)) & 1;
if (!isSliceEnable) {
continue;
}
sliceCount++;
for (int y = 0; y < data->max_subslices; y++) {
bool isSubSliceEnabled = (data->data[data->subslice_offset + x * data->subslice_stride + y / 8] >> (y % 8)) & 1;
if (!isSubSliceEnabled) {
continue;
}
subSliceCount++;
for (int z = 0; z < data->max_eus_per_subslice; z++) {
bool isEUEnabled = (data->data[data->eu_offset + (x * data->max_subslices + y) * data->eu_stride + z / 8] >> (z % 8)) & 1;
if (!isEUEnabled) {
continue;
}
euCount++;
}
}
}
return (sliceCount && subSliceCount && euCount);
}
} // namespace NEO