Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the gcc cpu-type that includes support for RDTSCP?

Tags:

x86

gcc

intel

rdtsc

I am using RDTSCP to replace LFENCE;RDTSC sequences and also get the processor ID back so that I know when I'm comparing TSC values after the thread was rescheduled to another CPU.

To ensure I don't run RDTSCP on a too old machine I fallback to RDTSC after a CPUID check (using libcpuid). I'd like to try using the gcc multiple target attribute functionality instead of a CPUID call:

int core2_func (void) __attribute__ ((__target__ ("arch=core2")));

The gcc manual lists a number of cpu families (haswell, skylake, ...). How would I find which cpu family first introduced RDTSCP?

like image 913
Peeter Joot Avatar asked Nov 27 '25 08:11

Peeter Joot


1 Answers

All AMD processors since the K8 Hammer support RDTSCP.

On Intel processors, RDTSCP is supported on Nehalem and later, Silvermont and later, and Knights Landing and later.

like image 186
Hadi Brais Avatar answered Nov 29 '25 17:11

Hadi Brais