Is there an `x86` instruction to tell which core the instruction is being run on?

前端 未结 5 1558
一向
一向 2020-12-29 08:55

When I cat /proc/cpuinfo, I see 8 cores, with ID\'s from 0 to 7.

Is there an x86 instruction that will report th

5条回答
  •  自闭症患者
    2020-12-29 09:18

    Except already described CPUID and RDTSCP instructions also there is new one RDPID instruction (Intel SDM download page) exactly for this purpose.

    Description

    Reads the value of the IA32_TSC_AUX MSR (address C0000103H) into the destination register. The value of CS.D and operand-size prefixes (66H and REX.W) do not affect the behavior of the RDPID instruction.

    Notes:

    RDPID reads processor core id as uint32_r or uint64_r, so read value will not in sequential range [0,MAX_CPU_COUNT]

    RDPID is new instruction so it is not widely supported by hardware

提交回复
热议问题