For benchmarking purposes, I'm using rdtsc
to determine how much pseudo-time I have spent executing some chunks of code inside a critical loop. Since my code can be rescheduled between processes at any moment, I would like to minimize the noise by just dumping the data if I find out that I have changed CPU between the start and the stop of the micro-measure.
Is there an x86 instruction I could use to identify on which CPU/core I'm running? Something that would give me either a unique identifier, or a CPU# and a core#, etc.
Apparently, cpuid
doesn't provide the information anymore, so I'm looking for an alternative.