Move query topology translation logic to new method

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-01-26 11:02:17 +00:00
committed by Compute-Runtime-Automation
parent 98ef17dceb
commit 4ffcf88a92
3 changed files with 35 additions and 28 deletions

View File

@@ -465,6 +465,38 @@ uint32_t Drm::getVirtualMemoryAddressSpace(uint32_t vmId) {
return 0;
}
bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, int &sliceCount, int &subSliceCount, int &euCount) {
sliceCount = 0;
subSliceCount = 0;
euCount = 0;
for (int x = 0; x < queryTopologyInfo->max_slices; x++) {
bool isSliceEnable = (queryTopologyInfo->data[x / 8] >> (x % 8)) & 1;
if (!isSliceEnable) {
continue;
}
sliceCount++;
for (int y = 0; y < queryTopologyInfo->max_subslices; y++) {
size_t yOffset = (queryTopologyInfo->subslice_offset + x * queryTopologyInfo->subslice_stride + y / 8);
bool isSubSliceEnabled = (queryTopologyInfo->data[yOffset] >> (y % 8)) & 1;
if (!isSubSliceEnabled) {
continue;
}
subSliceCount++;
for (int z = 0; z < queryTopologyInfo->max_eus_per_subslice; z++) {
size_t zOffset = (queryTopologyInfo->eu_offset + (x * queryTopologyInfo->max_subslices + y) * queryTopologyInfo->eu_stride + z / 8);
bool isEUEnabled = (queryTopologyInfo->data[zOffset] >> (z % 8)) & 1;
if (!isEUEnabled) {
continue;
}
euCount++;
}
}
}
return (sliceCount && subSliceCount && euCount);
}
Drm::~Drm() {
destroyVirtualMemoryAddressSpace();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
* Copyright (C) 2017-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -161,6 +161,7 @@ class Drm {
protected:
int getQueueSliceCount(drm_i915_gem_context_param_sseu *sseu);
bool translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, int &sliceCount, int &subSliceCount, int &euCount);
std::string generateUUID();
std::string generateElfUUID(const void *data);
bool sliceCountChangeSupported = false;

View File

@@ -20,33 +20,7 @@ bool Drm::queryTopology(int &sliceCount, int &subSliceCount, int &euCount) {
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);
return translateTopologyInfo(data, sliceCount, subSliceCount, euCount);
}
} // namespace NEO