How to find the size of the L1 cache line size with IO timing measurements?

后端 未结 8 682
深忆病人
深忆病人 2021-01-30 09:10

As a school assignment, I need to find a way to get the L1 data cache line size, without reading config files or using api calls. Supposed to use memory accesses read/write timi

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 09:37

    You can use the CPUID function in assembler, although non portable, it will give you what you want.

    For Intel Microprocessors, the Cache Line Size can be calculated by multiplying bh by 8 after calling cpuid function 0x1.

    For AMD Microprocessors, the data Cache Line Size is in cl and the instruction Cache Line Size is in dl after calling cpuid function 0x80000005.

    I took this from this article here.

提交回复
热议问题