@@ -81,20 +81,33 @@ class product_id {
8181 /* *
8282 * Construct product id from a GPU id.
8383 *
84- * @param gpu_id [in] GPU id to parse .
84+ * @param[in] raw_product_id Raw unmasked product id .
8585 */
86- explicit constexpr product_id (uint64_t gpu_id )
87- : product_id_(from_gpu_id(gpu_id )) {}
86+ explicit constexpr product_id (uint32_t raw_product_id )
87+ : product_id_(from_raw_product_id(raw_product_id )) {}
8888
8989 /* *
9090 * Construct product id using product/arch major versions pair.
9191 *
92- * @param arch_major [in] Arch major version.
93- * @param product_major [in] Product major version.
92+ * @param[in] arch_major Arch major version.
93+ * @param[in] product_major Product major version.
9494 */
9595 explicit constexpr product_id (uint32_t arch_major, uint32_t product_major)
9696 : product_id_(from_versions(arch_major, product_major)) {}
9797
98+ /* *
99+ * Construct product id from the raw GPU id value.
100+ *
101+ * @param gpu_id Raw gpu id.
102+ * @return Product id.
103+ */
104+ static constexpr product_id from_raw_gpu_id (uint64_t gpu_id) {
105+ constexpr uint64_t product_id_shift{16 };
106+ constexpr uint64_t product_id_mask{0xFFFF };
107+
108+ return product_id{static_cast <uint32_t >((gpu_id >> product_id_shift) & product_id_mask)};
109+ }
110+
98111 /* * @return Version style of the product ID. */
99112 constexpr version_style get_version_style () const { return get_version_style (product_id_); }
100113
@@ -156,40 +169,40 @@ class product_id {
156169 /* *
157170 * Get version style of a gpu_id or product_id value.
158171 *
159- * @param value [in] Value to get the style from.
172+ * @param[in] value Value to get the style from.
160173 * @return Version style of @p value.
161174 */
162175 constexpr static version_style get_version_style (uint32_t value) {
163176 if (value == product_id_t60x)
164177 return version_style::legacy_t60x;
165- else if (value < 0x1000 )
178+ else if (value < 0x1000U )
166179 return version_style::legacy_txxx;
167180 else
168181 return version_style::arch_product_major;
169182 }
170183
171184 /* *
172- * Get product id from a GPU id .
185+ * Get product id from a raw unmasked value .
173186 *
174- * @param gpu_id [in] GPU id to parse .
187+ * @param[in] raw_product_id Raw unmasked product id .
175188 * @return Product id value.
176189 */
177- static constexpr uint32_t from_gpu_id ( uint64_t gpu_id ) {
178- switch (get_version_style (gpu_id )) {
190+ static constexpr uint32_t from_raw_product_id ( uint32_t raw_product_id ) {
191+ switch (get_version_style (raw_product_id )) {
179192 case version_style::legacy_t60x:
180193 case version_style::legacy_txxx:
181- return gpu_id & product_id_mask_legacy;
194+ return raw_product_id & product_id_mask_legacy;
182195 case version_style::arch_product_major:
183196 default :
184- return gpu_id & product_id_mask_modern;
197+ return raw_product_id & product_id_mask_modern;
185198 }
186199 }
187200
188201 /* *
189202 * Get product id using product/arch major versions pair.
190203 *
191- * @param arch_major [in] Arch major version.
192- * @param product_major [in] Product major version.
204+ * @param[in] arch_major Arch major version.
205+ * @param[in] product_major Product major version.
193206 * @return Product id value.
194207 */
195208 static constexpr uint32_t from_versions (uint32_t arch_major, uint32_t product_major) {
0 commit comments