|
1 | 1 | /* |
2 | | - * Copyright (C) 2022-2023 Intel Corporation |
| 2 | + * Copyright (C) 2022-2024 Intel Corporation |
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | * |
|
15 | 15 | #include "shared/source/helpers/hw_info.h" |
16 | 16 | #include "shared/source/os_interface/linux/drm_neo.h" |
17 | 17 | #include "shared/source/os_interface/linux/drm_wrappers.h" |
| 18 | +#include "shared/source/os_interface/product_helper.h" |
18 | 19 |
|
19 | 20 | #include <array> |
| 21 | +#include <iterator> |
20 | 22 |
|
21 | 23 | namespace NEO { |
22 | 24 | namespace DrmEngineMappingHelper { |
@@ -47,8 +49,38 @@ void assignLinkCopyEngine(std::vector<EngineInfo::EngineToInstanceMap> &tileToEn |
47 | 49 | UNRECOVERABLE_IF(bcsInfoMask.test(engineMaskIndex)); |
48 | 50 | bcsInfoMask.set(engineMaskIndex, true); |
49 | 51 | } |
| 52 | + |
| 53 | +auto getCopyEnginesMappingIterator(const NEO::RootDeviceEnvironment &rootDeviceEnvironment) { |
| 54 | + auto mappingCopyEngineIt = DrmEngineMappingHelper::engineMapping.begin(); |
| 55 | + if (const auto defaultCopyEngine = rootDeviceEnvironment.getProductHelper().getDefaultCopyEngine(); defaultCopyEngine != *mappingCopyEngineIt) { |
| 56 | + mappingCopyEngineIt++; |
| 57 | + } // Note that BCS0 may not be enabled |
| 58 | + return mappingCopyEngineIt; |
| 59 | +} |
| 60 | + |
| 61 | +uint32_t getBcsEngineMaskIndex(const aub_stream::EngineType *mappingCopyEngineIt) { |
| 62 | + if (*mappingCopyEngineIt == aub_stream::EngineType::ENGINE_BCS) { |
| 63 | + return 0u; |
| 64 | + } else |
| 65 | + return *mappingCopyEngineIt - aub_stream::EngineType::ENGINE_BCS1 + 1; |
| 66 | +} |
50 | 67 | } // namespace |
51 | 68 |
|
| 69 | +void EngineInfo::mapEngine(const NEO::IoctlHelper *ioctlHelper, const EngineClassInstance &engine, BcsInfoMask &bcsInfoMask, const NEO::RootDeviceEnvironment &rootDeviceEnvironment, |
| 70 | + const aub_stream::EngineType *&mappingCopyEngineIt, uint32_t &computeEnginesCounter, uint32_t tileId) { |
| 71 | + |
| 72 | + tileToEngineMap.emplace(tileId, engine); |
| 73 | + if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassRender)) { |
| 74 | + tileToEngineToInstanceMap[tileId][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)] = engine; |
| 75 | + } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCopy)) { |
| 76 | + tileToEngineToInstanceMap[tileId][*(mappingCopyEngineIt)] = engine; |
| 77 | + bcsInfoMask.set(getBcsEngineMaskIndex(mappingCopyEngineIt++), true); |
| 78 | + } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCompute)) { |
| 79 | + tileToEngineToInstanceMap[tileId][static_cast<aub_stream::EngineType>(aub_stream::ENGINE_CCS + computeEnginesCounter)] = engine; |
| 80 | + computeEnginesCounter++; |
| 81 | + } |
| 82 | +} |
| 83 | + |
52 | 84 | EngineInfo::EngineInfo(Drm *drm, const std::vector<EngineCapabilities> &engineInfos) : engines(engineInfos), tileToEngineToInstanceMap(1) { |
53 | 85 | auto computeEngines = 0u; |
54 | 86 | BcsInfoMask bcsInfoMask = 0; |
@@ -79,57 +111,40 @@ EngineInfo::EngineInfo(Drm *drm, const StackVec<std::vector<EngineClassInstance> |
79 | 111 | auto ioctlHelper = drm->getIoctlHelper(); |
80 | 112 | auto &rootDeviceEnvironment = drm->getRootDeviceEnvironment(); |
81 | 113 | auto computeEnginesPerTile = 0u; |
82 | | - auto copyEnginesPerTile = 0u; |
| 114 | + BcsInfoMask bcsInfoMask = {}; |
| 115 | + |
83 | 116 | for (auto tile = 0u; tile < engineClassInstancePerTile.size(); tile++) { |
84 | | - copyEnginesPerTile = 0u; |
85 | 117 | computeEnginesPerTile = 0u; |
| 118 | + auto copyEnginesMappingIt = getCopyEnginesMappingIterator(rootDeviceEnvironment); |
| 119 | + |
86 | 120 | for (const auto &engine : engineClassInstancePerTile[tile]) { |
87 | | - tileToEngineMap.emplace(tile, engine); |
88 | | - if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassRender)) { |
89 | | - tileToEngineToInstanceMap[tile][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)] = engine; |
90 | | - } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCopy)) { |
91 | | - tileToEngineToInstanceMap[tile][DrmEngineMappingHelper::engineMapping[copyEnginesPerTile]] = engine; |
92 | | - copyEnginesPerTile++; |
93 | | - } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCompute)) { |
94 | | - tileToEngineToInstanceMap[tile][static_cast<aub_stream::EngineType>(aub_stream::ENGINE_CCS + computeEnginesPerTile)] = engine; |
95 | | - computeEnginesPerTile++; |
96 | | - } |
| 121 | + mapEngine(ioctlHelper, engine, bcsInfoMask, rootDeviceEnvironment, copyEnginesMappingIt, computeEnginesPerTile, tile); |
97 | 122 | } |
98 | 123 | } |
99 | | - BcsInfoMask bcsInfoMask = maxNBitValue(copyEnginesPerTile); |
100 | 124 | setSupportedEnginesInfo(rootDeviceEnvironment, computeEnginesPerTile, bcsInfoMask); |
101 | 125 | } |
102 | 126 |
|
103 | 127 | EngineInfo::EngineInfo(Drm *drm, uint32_t tileCount, const std::vector<DistanceInfo> &distanceInfos, const std::vector<QueryItem> &queryItems, const std::vector<EngineCapabilities> &engineInfos) |
104 | 128 | : engines(engineInfos), tileToEngineToInstanceMap(tileCount) { |
105 | 129 | auto tile = 0u; |
106 | 130 | auto computeEnginesPerTile = 0u; |
107 | | - auto copyEnginesPerTile = 0u; |
108 | 131 | auto ioctlHelper = drm->getIoctlHelper(); |
109 | 132 | auto &rootDeviceEnvironment = drm->getRootDeviceEnvironment(); |
| 133 | + BcsInfoMask bcsInfoMask = {}; |
| 134 | + |
| 135 | + auto copyEnginesMappingIt = getCopyEnginesMappingIterator(rootDeviceEnvironment); |
110 | 136 | for (auto i = 0u; i < distanceInfos.size(); i++) { |
111 | 137 | if (i > 0u && distanceInfos[i].region.memoryInstance != distanceInfos[i - 1u].region.memoryInstance) { |
112 | 138 | tile++; |
113 | 139 | computeEnginesPerTile = 0u; |
114 | | - copyEnginesPerTile = 0u; |
| 140 | + copyEnginesMappingIt = getCopyEnginesMappingIterator(rootDeviceEnvironment); |
115 | 141 | } |
116 | | - if (queryItems[i].length < 0 || distanceInfos[i].distance != 0) |
| 142 | + if (queryItems[i].length < 0 || distanceInfos[i].distance != 0) { |
117 | 143 | continue; |
118 | | - |
119 | | - auto engine = distanceInfos[i].engine; |
120 | | - tileToEngineMap.emplace(tile, engine); |
121 | | - if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassRender)) { |
122 | | - tileToEngineToInstanceMap[tile][EngineHelpers::remapEngineTypeToHwSpecific(aub_stream::EngineType::ENGINE_RCS, rootDeviceEnvironment)] = engine; |
123 | | - } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCopy)) { |
124 | | - tileToEngineToInstanceMap[tile][DrmEngineMappingHelper::engineMapping[copyEnginesPerTile]] = engine; |
125 | | - copyEnginesPerTile++; |
126 | | - } else if (engine.engineClass == ioctlHelper->getDrmParamValue(DrmParam::engineClassCompute)) { |
127 | | - tileToEngineToInstanceMap[tile][static_cast<aub_stream::EngineType>(aub_stream::ENGINE_CCS + computeEnginesPerTile)] = engine; |
128 | | - computeEnginesPerTile++; |
129 | 144 | } |
| 145 | + auto engine = distanceInfos[i].engine; |
| 146 | + mapEngine(ioctlHelper, engine, bcsInfoMask, rootDeviceEnvironment, copyEnginesMappingIt, computeEnginesPerTile, tile); |
130 | 147 | } |
131 | | - |
132 | | - BcsInfoMask bcsInfoMask = maxNBitValue(copyEnginesPerTile); |
133 | 148 | setSupportedEnginesInfo(rootDeviceEnvironment, computeEnginesPerTile, bcsInfoMask); |
134 | 149 | } |
135 | 150 |
|
|
0 commit comments