diff --git a/shared/source/os_interface/linux/CMakeLists.txt b/shared/source/os_interface/linux/CMakeLists.txt index 384af4b0b0..9533e70b4e 100644 --- a/shared/source/os_interface/linux/CMakeLists.txt +++ b/shared/source/os_interface/linux/CMakeLists.txt @@ -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 diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index f8ed7648bc..a73509faee 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -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 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(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; diff --git a/shared/source/os_interface/linux/drm_query_extended.cpp b/shared/source/os_interface/linux/drm_query_extended.cpp new file mode 100644 index 0000000000..638f9f40a0 --- /dev/null +++ b/shared/source/os_interface/linux/drm_query_extended.cpp @@ -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(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