libcpuid.h Veselin Georgiev Oct 2008 0.2.2
Version history:
- 0.1.0 (2008-10-15): initial adaptation from wxfractgui sources
- 0.1.1 (2009-07-06): Added intel_fn11 fields to cpu_raw_data_t to handle new processor topology enumeration required on Core i7
- 0.1.2 (2009-09-26): Added support for MSR reading through self-extracting kernel driver on Win32.
- 0.1.3 (2010-04-20): Added support for greater more accurate CPU clock measurements with cpu_clock_by_ic()
- 0.2.0 (2011-10-11): Support for AMD Bulldozer CPUs, 128-bit SSE unit size checking. A backwards-incompatible change, since the sizeof cpu_id_t is now different.
- 0.2.1 (2012-05-26): Support for Ivy Bridge, and detecting the presence of the RdRand instruction.
- 0.2.2 (2015-11-04): Support for newer processors up to Haswell and Vishera. Fix clock detection in cpu_clock_by_ic() for Bulldozer. More entries supported in cpu_msrinfo(). *BSD and Solaris support (unofficial).
- 0.2.3 : Support for Skylake; MSR ops in FreeBSD; INFO_VOLTAGE for AMD CPUs.
LibCPUID provides CPU identification and access to the CPUID and RDTSC instructions on the x86.
To execute CPUID, use cpu_exec_cpuid
To execute RDTSC, use cpu_rdtsc
To fetch the CPUID info needed for CPU identification, use cpuid_get_raw_data
To make sense of that data (decode, extract features), use cpu_identify
To detect the CPU speed, use either cpu_clock, cpu_clock_by_os, cpu_tsc_mark + cpu_tsc_unmark + cpu_clock_by_mark, cpu_clock_measure or cpu_clock_by_ic. Read carefully for pros/cons of each method.
To read MSRs, use cpu_msr_driver_open to get a handle, and then cpu_rdmsr for querying abilities. Some MSR decoding is available on recent CPUs, and can be queried through cpu_msrinfo; the various types of queries are described in cpu_msrinfo_request_t.