Questions tagged [cpuid]

CPUID is an Intel x86 and x86_64 processor instruction that returns the processor type and the presence of particular features.

Originally introduced by Intel, the CPUID instruction returns the processor type and the presence of features such as MMX/SSE.

163 questions
5
votes
1 answer

How do I find the cpu the current thread is running on, for Mac and BSD?

I'm looking for a function on Mac OS and BSD that's equivalent to Linux's sched_getcpu(), and Windows' GetCurrentProcessorNumberEx() in order to implement a library for cpu-local storage. It's clearly possible to emulate this with the cpuid or…
Jeffrey Yasskin
  • 5,171
  • 2
  • 27
  • 39
4
votes
1 answer

Using CPUID to get cache size in Ryzen CPU

I wanted to use the CPUID instruction to get the size for each cache level (L1, L2, L3). I've been reading "AMD64 Architecture Programmer’s Manual Volume 3: General-Purpose and System Instructions". In page 613 there is the information relevant for…
tuket
  • 3,232
  • 1
  • 26
  • 41
4
votes
2 answers

CPUID: Why must MISC_ENABLE.LCMV be set to 0 for some functions? Can I temporarily overwrite it?

I'm trying to use CPUID, but there are some strings attached. According to sandpile.org's CPUID page, CPUID standard functions 0000_0004h and up will only work if the MISC_ENABLE.LCMV flag is set to 0. This flag is bit 22 of model-specific…
Mike S
  • 531
  • 4
  • 14
4
votes
1 answer

What calling convention should I use to make things portable?

I am writing a C interface for CPU's cpuid instruction. I'm just doing this as kind of an exercise: I don't want to use compiler-depended headers such as cpuid.h for GCC or intrin.h for MSVC. Also, I'm aware that using C inline assembly would be a…
Giuppox
  • 1,393
  • 9
  • 35
4
votes
1 answer

How to ensure that RDTSC is accurate?

I've read that RDTSC can gives false readings and should not be relied upon. Is this true and if so what can be done about it?
Johan
  • 74,508
  • 24
  • 191
  • 319
4
votes
4 answers

Detecting CPU capability without assembly

I've been looking at ways to determine the CPU, and its capabilities (e.g. SEE, SSE2, etc). However all the ways I've found involved assembly code using the cpuid instruction. Given the different ways of doing assembly in C/C++ between compilers and…
Fire Lancer
  • 29,364
  • 31
  • 116
  • 182
4
votes
2 answers

Getting CPU ID code from C# to be in C++

I have this C# code to get Processor ID but I'm not able to pass it to C++, I tried a lot but I really can't, I just started in C++ and I would like to be able to get the CPU ID with C++ like I used to get with C# This is the code I have in…
Luiza Nunes
  • 43
  • 1
  • 1
  • 3
3
votes
1 answer

In which cases GetSystemInfo/GetLogicalProcessorInformationEx returns different processor count within the same program run?

There are Windows API functions to obtain CPU and CPU Cache topology. GetSystemInfo fills SYSTEM_INFO with dwActiveProcessorMask and dwNumberOfProcessors. GetLogicalProcessorInformationEx can be used to have more precise information about each…
Alex Guteniev
  • 12,039
  • 2
  • 34
  • 79
3
votes
1 answer

Will CPUID serialize speculative data caching?

I found the description of a speculative data caching procedure from multiple instruction entries in Intel Vol.2. For example, the lfence: Processors are free to fetch and cache data speculatively from regions of system memory that use the WB,…
3
votes
3 answers

Getting CPU ID on virtual machine

I am trying to use this code: public string GetCPUId() { string cpuInfo = String.Empty; string temp = String.Empty; ManagementClass mc = new ManagementClass("Win32_Processor"); ManagementObjectCollection moc = mc.GetInstances(); …
heresma
  • 293
  • 2
  • 4
  • 14
3
votes
1 answer

Determining x86 MONITOR instruction address range using CPUID instruction

Intel's documentation of MONITOR says: The MONITOR instruction arms address monitoring hardware using an address specified in EAX (the address range that the monitoring hardware checks for store operations can be determined by using CPUID). A store…
zviadm
  • 1,045
  • 9
  • 12
3
votes
2 answers

Valgrind changes CPUID value

Valgrind is changing the values returned by the CPUID opcode instruction. Simply put, how can I make Valgrind respect the actual CPUID instruction? For reference, this was discovered when running into strange errors when detecting aes-ni support on…
cegfault
  • 6,442
  • 3
  • 27
  • 49
3
votes
1 answer

How to use CPUID as a serializing instruction?

CPUID can be used as a serializing instruction as described here and here. What is the minimal/simplest asm syntax to use it in that way in C++? // Is that enough? // What to do with registers and memory? // Is volatile necessary? asm…
Vincent
  • 57,703
  • 61
  • 205
  • 388
3
votes
1 answer

"Not found" exception generated while trying to get CPU ID via WMI

I'm using this code to fetch the processor id: public static string getProcessorId() { var mc = new ManagementClass("Win32_Processor"); var moc = mc.GetInstances(); foreach (var mo in moc) { …
invarbrass
  • 2,023
  • 4
  • 20
  • 23
3
votes
1 answer

C/C++ How to get Processor Serial Number on linux

I was wondering how to reliably obtain the Processor Serial Number (PSN) on GNU Linux. For now I'm using this #include #include unsigned int level = 1; unsigned eax = 3 /* processor serial number */, ebx = 0, ecx = 0, edx =…
anni
  • 1,403
  • 1
  • 24
  • 33
1 2
3
10 11