diff --git a/opencl/test/unit_test/linux/mock_os_layer.cpp b/opencl/test/unit_test/linux/mock_os_layer.cpp index d447fea6eb..dc091a038e 100644 --- a/opencl/test/unit_test/linux/mock_os_layer.cpp +++ b/opencl/test/unit_test/linux/mock_os_layer.cpp @@ -255,15 +255,15 @@ int drmQueryItem(drm_i915_query *query) { auto queryItemArg = reinterpret_cast(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(queryItemArg->dataPtr); - topologyArg->max_slices = 1; - topologyArg->max_subslices = 1; - topologyArg->max_eus_per_subslice = 3; + auto topologyArg = reinterpret_cast(queryItemArg->dataPtr); + topologyArg->maxSlices = 1; + topologyArg->maxSubslices = 1; + topologyArg->maxEusPerSubslice = 3; topologyArg->data[0] = 0xFF; return failOnEuTotal || failOnSubsliceTotal; } diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index ea7d65ddd2..c77023dfad 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -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 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 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(dataQuery.data()); + auto data = reinterpret_cast(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(data->max_eus_per_subslice)); + topologyData.maxEuCount = std::max(topologyData.maxEuCount, static_cast(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(dataQuery.data()); + auto data = reinterpret_cast(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; diff --git a/shared/source/os_interface/linux/drm_neo.h b/shared/source/os_interface/linux/drm_neo.h index 8e817609fc..4b168ce926 100644 --- a/shared/source/os_interface/linux/drm_neo.h +++ b/shared/source/os_interface/linux/drm_neo.h @@ -257,7 +257,7 @@ class Drm : public DriverModel { Drm(std::unique_ptr &&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(); diff --git a/shared/source/os_interface/linux/drm_wrappers.cpp b/shared/source/os_interface/linux/drm_wrappers.cpp index 42cae5b2c8..21cbed7a09 100644 --- a/shared/source/os_interface/linux/drm_wrappers.cpp +++ b/shared/source/os_interface/linux/drm_wrappers.cpp @@ -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 diff --git a/shared/source/os_interface/linux/drm_wrappers.h b/shared/source/os_interface/linux/drm_wrappers.h index 8cf838ce70..8726aa4c05 100644 --- a/shared/source/os_interface/linux/drm_wrappers.h +++ b/shared/source/os_interface/linux/drm_wrappers.h @@ -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 diff --git a/shared/test/common/libult/linux/drm_mock.cpp b/shared/test/common/libult/linux/drm_mock.cpp index 1fb71d6bc2..f58486a67d 100644 --- a/shared/test/common/libult/linux/drm_mock.cpp +++ b/shared/test/common/libult/linux/drm_mock.cpp @@ -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(sizeof(drm_i915_query_topology_info) + dataSize); + queryItemArg->length = static_cast(sizeof(QueryTopologyInfo) + dataSize); return 0; } } else { if (queryItemArg->queryId == DRM_I915_QUERY_TOPOLOGY_INFO) { - auto topologyArg = reinterpret_cast(queryItemArg->dataPtr); + auto topologyArg = reinterpret_cast(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); diff --git a/shared/test/common/libult/linux/drm_mock_prelim_context.cpp b/shared/test/common/libult/linux/drm_mock_prelim_context.cpp index 9ec7f46730..c8cf166f43 100644 --- a/shared/test/common/libult/linux/drm_mock_prelim_context.cpp +++ b/shared/test/common/libult/linux/drm_mock_prelim_context.cpp @@ -364,21 +364,21 @@ bool DrmMockPrelimContext::handlePrelimQueryItem(void *arg) { static_cast(std::ceil(maxSlices / 8.0)); if (queryItem->length == 0) { - queryItem->length = static_cast(sizeof(drm_i915_query_topology_info) + dataSize); + queryItem->length = static_cast(sizeof(QueryTopologyInfo) + dataSize); break; } else { - auto topologyArg = reinterpret_cast(queryItem->dataPtr); + auto topologyArg = reinterpret_cast(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(std::ceil(maxSubslices / 8.0)); - topologyArg->eu_stride = static_cast(std::ceil(maxEuPerSubslice / 8.0)); - topologyArg->subslice_offset = static_cast(std::ceil(maxSlices / 8.0)); - topologyArg->eu_offset = static_cast(std::ceil(maxSubslices / 8.0)) * maxSlices; + topologyArg->subsliceStride = static_cast(std::ceil(maxSubslices / 8.0)); + topologyArg->euStride = static_cast(std::ceil(maxEuPerSubslice / 8.0)); + topologyArg->subsliceOffset = static_cast(std::ceil(maxSlices / 8.0)); + topologyArg->euOffset = static_cast(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; diff --git a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp index aba1297e85..ebc73747ab 100644 --- a/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp +++ b/shared/test/unit_test/os_interface/linux/drm_query_topology_prelim_tests.cpp @@ -51,9 +51,9 @@ struct QueryTopologyTests : ::testing::Test { auto dataSize = static_cast(std::ceil(realEuCount / 8.0)); if (queryItem->length == 0) { - queryItem->length = static_cast(sizeof(drm_i915_query_topology_info) + dataSize); + queryItem->length = static_cast(sizeof(QueryTopologyInfo) + dataSize); } else { - auto topologyArg = reinterpret_cast(queryItem->dataPtr); + auto topologyArg = reinterpret_cast(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); }