/// <summary> /// Init general device information. /// </summary> private void InitDeviceInfo() { // Resolve general device information Name = CurrentAPI.GetDeviceInfo( DeviceId, CLDeviceInfoType.CL_DEVICE_NAME); DeviceType = (CLDeviceType)CurrentAPI.GetDeviceInfo <long>( DeviceId, CLDeviceInfoType.CL_DEVICE_TYPE); DeviceVersion = CLDeviceVersion.TryParse( CurrentAPI.GetDeviceInfo( DeviceId, CLDeviceInfoType.CL_DEVICE_VERSION), out var deviceVersion) ? deviceVersion : CLDeviceVersion.CL10; // Resolve clock rate ClockRate = CurrentAPI.GetDeviceInfo <int>( DeviceId, CLDeviceInfoType.CL_DEVICE_MAX_CLOCK_FREQUENCY); // Resolve number of multiprocessors NumMultiprocessors = CurrentAPI.GetDeviceInfo <int>( DeviceId, CLDeviceInfoType.CL_DEVICE_MAX_COMPUTE_UNITS); }
/// <summary> /// Tries to parse the given string expression into an OpenCL C version. /// </summary> /// <param name="expression">The expression to parse.</param> /// <param name="version">The parsed version (if any).</param> /// <returns> /// True, if the given expression could be parsed into an OpenCL C version. /// </returns> public static bool TryParse(string expression, out CLDeviceVersion version) { version = default; var match = VersionRegex.Match(expression); if (!match.Success) { return(false); } version = new CLDeviceVersion( int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value)); return(true); }