@@ -266,6 +266,67 @@ ur_result_t ur_platform_handle_t_::initialize() {
266
266
return UR_RESULT_SUCCESS;
267
267
}
268
268
269
+ // / Checks the version of the level-zero driver.
270
+ // / @param VersionMajor Major verion number to compare to.
271
+ // / @param VersionMinor Minor verion number to compare to.
272
+ // / @param VersionBuild Build verion number to compare to.
273
+ // / @return true is the version of the driver is higher than or equal to the
274
+ // / compared version
275
+ bool ur_platform_handle_t_::isDriverVersionNewerOrSimilar (
276
+ uint32_t VersionMajor, uint32_t VersionMinor, uint32_t VersionBuild) {
277
+ uint32_t DriverVersionMajor = 0 ;
278
+ uint32_t DriverVersionMinor = 0 ;
279
+ uint32_t DriverVersionBuild = 0 ;
280
+ if (!ZeDriverVersionString.Supported ) {
281
+ ZeStruct<ze_driver_properties_t > ZeDriverProperties;
282
+ ZE2UR_CALL (zeDriverGetProperties, (ZeDriver, &ZeDriverProperties));
283
+ uint32_t DriverVersion = ZeDriverProperties.driverVersion ;
284
+ DriverVersionMajor = (DriverVersion & 0xFF000000 ) >> 24 ;
285
+ DriverVersionMinor = (DriverVersion & 0x00FF0000 ) >> 16 ;
286
+ DriverVersionBuild = DriverVersion & 0x0000FFFF ;
287
+ } else {
288
+ std::string ZeDriverVersion;
289
+ size_t sizeOfDriverString = 0 ;
290
+ ZeDriverVersionString.getDriverVersionString (ZeDriverHandleExpTranslated,
291
+ nullptr , &sizeOfDriverString);
292
+ ZeDriverVersion.resize (sizeOfDriverString);
293
+ ZeDriverVersionString.getDriverVersionString (ZeDriverHandleExpTranslated,
294
+ ZeDriverVersion.data (),
295
+ &sizeOfDriverString);
296
+
297
+ // Intel driver version string is in the format:
298
+ // Major.Minor.Build+Hotfix where hotfix is optional.
299
+ std::stringstream VersionString (ZeDriverVersion);
300
+
301
+ std::string VersionValue;
302
+ std::vector<std::string> VersionValues;
303
+ char VersionDelim = ' .' ;
304
+ char HotfixDelim = ' +' ;
305
+
306
+ while (getline (VersionString, VersionValue, VersionDelim)) {
307
+ VersionValues.push_back (VersionValue);
308
+ }
309
+ // If the extension exists, but the string value comes by empty or
310
+ // malformed, assume this is a developer driver.
311
+ if (VersionValues.size () >= 3 ) {
312
+ DriverVersionMajor = atoi (VersionValues[0 ].c_str ());
313
+ DriverVersionMinor = atoi (VersionValues[1 ].c_str ());
314
+ std::stringstream HotfixString (VersionValues[2 ]);
315
+ std::vector<std::string> BuildHotfixVersionValues;
316
+ // Check to see if there is a hotfix value and strip it off.
317
+ while (getline (HotfixString, VersionValue, HotfixDelim)) {
318
+ BuildHotfixVersionValues.push_back (VersionValue);
319
+ }
320
+ DriverVersionBuild = atoi (BuildHotfixVersionValues[0 ].c_str ());
321
+ } else {
322
+ return true ;
323
+ }
324
+ }
325
+ return std::make_tuple (DriverVersionMajor, DriverVersionMinor,
326
+ DriverVersionBuild) >=
327
+ std::make_tuple (VersionMajor, VersionMinor, VersionBuild);
328
+ }
329
+
269
330
// Get the cached PI device created for the L0 device handle.
270
331
// Return NULL if no such PI device found.
271
332
ur_device_handle_t
0 commit comments