@@ -127,6 +127,9 @@ static sycl::detail::ESIMDEmuPluginOpaqueData *PiESimdDeviceAccess;
127127// For PI_DEVICE_INFO_DRIVER_VERSION info
128128static char ESimdEmuVersionString[32 ];
129129
130+ // For PI_DEVICE_INFO_VERSION info
131+ static char CmEmuDeviceVersionString[32 ];
132+
130133using IDBuilder = sycl::detail::Builder;
131134
132135template <int NDims>
@@ -463,6 +466,23 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType,
463466
464467 int Result = cm_support::CreateCmDevice (CmDevice, Version);
465468
469+ // CM Device version info consists of two decimal numbers - major
470+ // and minor. Minor is single-digit. Version info is encoded into a
471+ // unsigned integer value = 100 * major + minor. Second from right
472+ // digit in decimal must be zero as it is used as 'dot'
473+ // REF - $CM_EMU/common/cm_version_defs.h - 'CURRENT_CM_VERSION'
474+ // e.g. CM version 7.3 => Device version = 703
475+
476+ if (((Version / 10 ) % 10 ) == 0 ) {
477+ if (PrintPiTrace) {
478+ std::cerr << " CM_EMU Device version info is incorrect" << std::endl;
479+ }
480+ return PI_INVALID_DEVICE;
481+ }
482+
483+ sprintf (CmEmuDeviceVersionString, " %d.%d" , (int )(Version / 100 ),
484+ (int )(Version % 10 ));
485+
466486 if (Result != cm_support::CM_SUCCESS) {
467487 return PI_INVALID_DEVICE;
468488 }
@@ -536,9 +556,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName,
536556 // cl_khr_int64_extended_atomics
537557 return ReturnValue (" " );
538558 case PI_DEVICE_INFO_VERSION:
539- // CM_EMU release version from
540- // https://github.com/intel/cm-cpu-emulation/releases
541- return ReturnValue (" 1.0" );
559+ return ReturnValue (CmEmuDeviceVersionString);
542560 case PI_DEVICE_INFO_COMPILER_AVAILABLE:
543561 return ReturnValue (pi_bool{false });
544562 case PI_DEVICE_INFO_LINKER_AVAILABLE:
0 commit comments