mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
Create a wrapper for drm_i915_query_topology_info
Related-To: NEO-6852 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
d9858bf206
commit
3be31b821b
@@ -255,15 +255,15 @@ int drmQueryItem(drm_i915_query *query) {
|
||||
auto queryItemArg = reinterpret_cast<NEO::QueryItem *>(query->items_ptr);
|
||||
if (queryItemArg->length == 0) {
|
||||
if (queryItemArg->queryId == DRM_I915_QUERY_TOPOLOGY_INFO) {
|
||||
queryItemArg->length = sizeof(drm_i915_query_topology_info) + 1;
|
||||
queryItemArg->length = sizeof(NEO::QueryTopologyInfo) + 1;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (queryItemArg->queryId == DRM_I915_QUERY_TOPOLOGY_INFO) {
|
||||
auto topologyArg = reinterpret_cast<drm_i915_query_topology_info *>(queryItemArg->dataPtr);
|
||||
topologyArg->max_slices = 1;
|
||||
topologyArg->max_subslices = 1;
|
||||
topologyArg->max_eus_per_subslice = 3;
|
||||
auto topologyArg = reinterpret_cast<NEO::QueryTopologyInfo *>(queryItemArg->dataPtr);
|
||||
topologyArg->maxSlices = 1;
|
||||
topologyArg->maxSubslices = 1;
|
||||
topologyArg->maxEusPerSubslice = 3;
|
||||
topologyArg->data[0] = 0xFF;
|
||||
return failOnEuTotal || failOnSubsliceTotal;
|
||||
}
|
||||
|
||||
@@ -754,7 +754,7 @@ void Drm::setNewResourceBoundToVM(uint32_t vmHandleId) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, QueryTopologyData &data, TopologyMapping &mapping) {
|
||||
bool Drm::translateTopologyInfo(const QueryTopologyInfo *queryTopologyInfo, QueryTopologyData &data, TopologyMapping &mapping) {
|
||||
int sliceCount = 0;
|
||||
int subSliceCount = 0;
|
||||
int euCount = 0;
|
||||
@@ -763,7 +763,7 @@ bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopolog
|
||||
std::vector<int> sliceIndices;
|
||||
sliceIndices.reserve(maxSliceCount);
|
||||
|
||||
for (int x = 0; x < queryTopologyInfo->max_slices; x++) {
|
||||
for (int x = 0; x < queryTopologyInfo->maxSlices; x++) {
|
||||
bool isSliceEnable = (queryTopologyInfo->data[x / 8] >> (x % 8)) & 1;
|
||||
if (!isSliceEnable) {
|
||||
continue;
|
||||
@@ -772,10 +772,10 @@ bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopolog
|
||||
sliceCount++;
|
||||
|
||||
std::vector<int> subSliceIndices;
|
||||
subSliceIndices.reserve(queryTopologyInfo->max_subslices);
|
||||
subSliceIndices.reserve(queryTopologyInfo->maxSubslices);
|
||||
|
||||
for (int y = 0; y < queryTopologyInfo->max_subslices; y++) {
|
||||
size_t yOffset = (queryTopologyInfo->subslice_offset + x * queryTopologyInfo->subslice_stride + y / 8);
|
||||
for (int y = 0; y < queryTopologyInfo->maxSubslices; y++) {
|
||||
size_t yOffset = (queryTopologyInfo->subsliceOffset + x * queryTopologyInfo->subsliceStride + y / 8);
|
||||
bool isSubSliceEnabled = (queryTopologyInfo->data[yOffset] >> (y % 8)) & 1;
|
||||
if (!isSubSliceEnabled) {
|
||||
continue;
|
||||
@@ -783,8 +783,8 @@ bool Drm::translateTopologyInfo(const drm_i915_query_topology_info *queryTopolog
|
||||
subSliceCount++;
|
||||
subSliceIndices.push_back(y);
|
||||
|
||||
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);
|
||||
for (int z = 0; z < queryTopologyInfo->maxEusPerSubslice; z++) {
|
||||
size_t zOffset = (queryTopologyInfo->euOffset + (x * queryTopologyInfo->maxSubslices + y) * queryTopologyInfo->euStride + z / 8);
|
||||
bool isEUEnabled = (queryTopologyInfo->data[zOffset] >> (z % 8)) & 1;
|
||||
if (!isEUEnabled) {
|
||||
continue;
|
||||
@@ -1164,7 +1164,7 @@ bool Drm::queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &topologyD
|
||||
success = false;
|
||||
break;
|
||||
}
|
||||
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.data());
|
||||
auto data = reinterpret_cast<QueryTopologyInfo *>(dataQuery.data());
|
||||
|
||||
QueryTopologyData tileTopologyData = {};
|
||||
TopologyMapping mapping;
|
||||
@@ -1180,7 +1180,7 @@ bool Drm::queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &topologyD
|
||||
|
||||
topologyData.maxSliceCount = std::max(topologyData.maxSliceCount, tileTopologyData.maxSliceCount);
|
||||
topologyData.maxSubSliceCount = std::max(topologyData.maxSubSliceCount, tileTopologyData.maxSubSliceCount);
|
||||
topologyData.maxEuCount = std::max(topologyData.maxEuCount, static_cast<int>(data->max_eus_per_subslice));
|
||||
topologyData.maxEuCount = std::max(topologyData.maxEuCount, static_cast<int>(data->maxEusPerSubslice));
|
||||
|
||||
this->topologyMap[i] = mapping;
|
||||
}
|
||||
@@ -1199,11 +1199,11 @@ bool Drm::queryTopology(const HardwareInfo &hwInfo, QueryTopologyData &topologyD
|
||||
if (dataQuery.empty()) {
|
||||
return false;
|
||||
}
|
||||
auto data = reinterpret_cast<drm_i915_query_topology_info *>(dataQuery.data());
|
||||
auto data = reinterpret_cast<QueryTopologyInfo *>(dataQuery.data());
|
||||
|
||||
TopologyMapping mapping;
|
||||
auto retVal = translateTopologyInfo(data, topologyData, mapping);
|
||||
topologyData.maxEuCount = data->max_eus_per_subslice;
|
||||
topologyData.maxEuCount = data->maxEusPerSubslice;
|
||||
|
||||
this->topologyMap.clear();
|
||||
this->topologyMap[0] = mapping;
|
||||
|
||||
@@ -257,7 +257,7 @@ class Drm : public DriverModel {
|
||||
Drm(std::unique_ptr<HwDeviceIdDrm> &&hwDeviceIdIn, RootDeviceEnvironment &rootDeviceEnvironment);
|
||||
|
||||
int getQueueSliceCount(GemContextParamSseu *sseu);
|
||||
bool translateTopologyInfo(const drm_i915_query_topology_info *queryTopologyInfo, QueryTopologyData &data, TopologyMapping &mapping);
|
||||
bool translateTopologyInfo(const QueryTopologyInfo *queryTopologyInfo, QueryTopologyData &data, TopologyMapping &mapping);
|
||||
std::string generateUUID();
|
||||
std::string generateElfUUID(const void *data);
|
||||
std::string getSysFsPciPath();
|
||||
|
||||
@@ -63,4 +63,15 @@ static_assert(offsetof(GemContextParamSseu, subsliceMask) == offsetof(drm_i915_g
|
||||
static_assert(offsetof(GemContextParamSseu, minEusPerSubslice) == offsetof(drm_i915_gem_context_param_sseu, min_eus_per_subslice));
|
||||
static_assert(offsetof(GemContextParamSseu, maxEusPerSubslice) == offsetof(drm_i915_gem_context_param_sseu, max_eus_per_subslice));
|
||||
|
||||
static_assert(sizeof(QueryTopologyInfo) == sizeof(drm_i915_query_topology_info));
|
||||
static_assert(offsetof(QueryTopologyInfo, flags) == offsetof(drm_i915_query_topology_info, flags));
|
||||
static_assert(offsetof(QueryTopologyInfo, maxSlices) == offsetof(drm_i915_query_topology_info, max_slices));
|
||||
static_assert(offsetof(QueryTopologyInfo, maxSubslices) == offsetof(drm_i915_query_topology_info, max_subslices));
|
||||
static_assert(offsetof(QueryTopologyInfo, maxEusPerSubslice) == offsetof(drm_i915_query_topology_info, max_eus_per_subslice));
|
||||
static_assert(offsetof(QueryTopologyInfo, subsliceOffset) == offsetof(drm_i915_query_topology_info, subslice_offset));
|
||||
static_assert(offsetof(QueryTopologyInfo, subsliceStride) == offsetof(drm_i915_query_topology_info, subslice_stride));
|
||||
static_assert(offsetof(QueryTopologyInfo, euOffset) == offsetof(drm_i915_query_topology_info, eu_offset));
|
||||
static_assert(offsetof(QueryTopologyInfo, euStride) == offsetof(drm_i915_query_topology_info, eu_stride));
|
||||
static_assert(offsetof(QueryTopologyInfo, data) == offsetof(drm_i915_query_topology_info, data));
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -71,4 +71,16 @@ struct GemContextParamSseu {
|
||||
uint16_t maxEusPerSubslice;
|
||||
};
|
||||
|
||||
struct QueryTopologyInfo {
|
||||
uint16_t flags;
|
||||
uint16_t maxSlices;
|
||||
uint16_t maxSubslices;
|
||||
uint16_t maxEusPerSubslice;
|
||||
uint16_t subsliceOffset;
|
||||
uint16_t subsliceStride;
|
||||
uint16_t euOffset;
|
||||
uint16_t euStride;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -248,18 +248,18 @@ int DrmMock::ioctl(unsigned long request, void *arg) {
|
||||
|
||||
if (queryItemArg->length == 0) {
|
||||
if (queryItemArg->queryId == DRM_I915_QUERY_TOPOLOGY_INFO) {
|
||||
queryItemArg->length = static_cast<int32_t>(sizeof(drm_i915_query_topology_info) + dataSize);
|
||||
queryItemArg->length = static_cast<int32_t>(sizeof(QueryTopologyInfo) + dataSize);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (queryItemArg->queryId == DRM_I915_QUERY_TOPOLOGY_INFO) {
|
||||
auto topologyArg = reinterpret_cast<drm_i915_query_topology_info *>(queryItemArg->dataPtr);
|
||||
auto topologyArg = reinterpret_cast<QueryTopologyInfo *>(queryItemArg->dataPtr);
|
||||
if (this->failRetTopology) {
|
||||
return -1;
|
||||
}
|
||||
topologyArg->max_slices = this->storedSVal;
|
||||
topologyArg->max_subslices = this->storedSVal ? (this->storedSSVal / this->storedSVal) : 0;
|
||||
topologyArg->max_eus_per_subslice = this->storedSSVal ? (this->storedEUVal / this->storedSSVal) : 0;
|
||||
topologyArg->maxSlices = this->storedSVal;
|
||||
topologyArg->maxSubslices = this->storedSVal ? (this->storedSSVal / this->storedSVal) : 0;
|
||||
topologyArg->maxEusPerSubslice = this->storedSSVal ? (this->storedEUVal / this->storedSSVal) : 0;
|
||||
|
||||
if (this->disableSomeTopology) {
|
||||
memset(topologyArg->data, 0xCA, dataSize);
|
||||
|
||||
@@ -364,21 +364,21 @@ bool DrmMockPrelimContext::handlePrelimQueryItem(void *arg) {
|
||||
static_cast<uint16_t>(std::ceil(maxSlices / 8.0));
|
||||
|
||||
if (queryItem->length == 0) {
|
||||
queryItem->length = static_cast<int32_t>(sizeof(drm_i915_query_topology_info) + dataSize);
|
||||
queryItem->length = static_cast<int32_t>(sizeof(QueryTopologyInfo) + dataSize);
|
||||
break;
|
||||
} else {
|
||||
auto topologyArg = reinterpret_cast<drm_i915_query_topology_info *>(queryItem->dataPtr);
|
||||
auto topologyArg = reinterpret_cast<QueryTopologyInfo *>(queryItem->dataPtr);
|
||||
if (failRetTopology) {
|
||||
return false;
|
||||
}
|
||||
topologyArg->max_slices = maxSlices;
|
||||
topologyArg->max_subslices = maxSubslices;
|
||||
topologyArg->max_eus_per_subslice = maxEuPerSubslice;
|
||||
topologyArg->maxSlices = maxSlices;
|
||||
topologyArg->maxSubslices = maxSubslices;
|
||||
topologyArg->maxEusPerSubslice = maxEuPerSubslice;
|
||||
|
||||
topologyArg->subslice_stride = static_cast<uint16_t>(std::ceil(maxSubslices / 8.0));
|
||||
topologyArg->eu_stride = static_cast<uint16_t>(std::ceil(maxEuPerSubslice / 8.0));
|
||||
topologyArg->subslice_offset = static_cast<uint16_t>(std::ceil(maxSlices / 8.0));
|
||||
topologyArg->eu_offset = static_cast<uint16_t>(std::ceil(maxSubslices / 8.0)) * maxSlices;
|
||||
topologyArg->subsliceStride = static_cast<uint16_t>(std::ceil(maxSubslices / 8.0));
|
||||
topologyArg->euStride = static_cast<uint16_t>(std::ceil(maxEuPerSubslice / 8.0));
|
||||
topologyArg->subsliceOffset = static_cast<uint16_t>(std::ceil(maxSlices / 8.0));
|
||||
topologyArg->euOffset = static_cast<uint16_t>(std::ceil(maxSubslices / 8.0)) * maxSlices;
|
||||
|
||||
int threadData = (threadsPerEu == 8) ? 0xff : 0x7f;
|
||||
|
||||
@@ -390,9 +390,9 @@ bool DrmMockPrelimContext::handlePrelimQueryItem(void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(ptrDiff(data, topologyArg->data) != topologyArg->subslice_offset);
|
||||
DEBUG_BREAK_IF(ptrDiff(data, topologyArg->data) != topologyArg->subsliceOffset);
|
||||
|
||||
data = ptrOffset(topologyArg->data, topologyArg->subslice_offset);
|
||||
data = ptrOffset(topologyArg->data, topologyArg->subsliceOffset);
|
||||
for (uint32_t sliceId = 0; sliceId < maxSlices; sliceId++) {
|
||||
for (uint32_t i = 0; i < maxSubslices; i++) {
|
||||
data[0] |= 1 << (i % 8);
|
||||
@@ -403,9 +403,9 @@ bool DrmMockPrelimContext::handlePrelimQueryItem(void *arg) {
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_BREAK_IF(ptrDiff(data, topologyArg->data) != topologyArg->eu_offset);
|
||||
auto size = dataSize - topologyArg->eu_offset;
|
||||
memset(ptrOffset(topologyArg->data, topologyArg->eu_offset), threadData, size);
|
||||
DEBUG_BREAK_IF(ptrDiff(data, topologyArg->data) != topologyArg->euOffset);
|
||||
auto size = dataSize - topologyArg->euOffset;
|
||||
memset(ptrOffset(topologyArg->data, topologyArg->euOffset), threadData, size);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
@@ -51,9 +51,9 @@ struct QueryTopologyTests : ::testing::Test {
|
||||
auto dataSize = static_cast<size_t>(std::ceil(realEuCount / 8.0));
|
||||
|
||||
if (queryItem->length == 0) {
|
||||
queryItem->length = static_cast<int32_t>(sizeof(drm_i915_query_topology_info) + dataSize);
|
||||
queryItem->length = static_cast<int32_t>(sizeof(QueryTopologyInfo) + dataSize);
|
||||
} else {
|
||||
auto topologyArg = reinterpret_cast<drm_i915_query_topology_info *>(queryItem->dataPtr);
|
||||
auto topologyArg = reinterpret_cast<QueryTopologyInfo *>(queryItem->dataPtr);
|
||||
|
||||
uint16_t finalSVal = queryComputeSlicesSCount;
|
||||
uint16_t finalSSVal = queryComputeSlicesSSCount;
|
||||
@@ -65,9 +65,9 @@ struct QueryTopologyTests : ::testing::Test {
|
||||
finalEUVal /= 2;
|
||||
}
|
||||
|
||||
topologyArg->max_slices = finalSVal;
|
||||
topologyArg->max_subslices = (finalSSVal / finalSVal);
|
||||
topologyArg->max_eus_per_subslice = (finalEUVal / finalSSVal);
|
||||
topologyArg->maxSlices = finalSVal;
|
||||
topologyArg->maxSubslices = (finalSSVal / finalSVal);
|
||||
topologyArg->maxEusPerSubslice = (finalEUVal / finalSSVal);
|
||||
|
||||
memset(topologyArg->data, 0xFF, dataSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user