How to programmatically get the CPU cache page size in C++?

后端 未结 7 1581
渐次进展
渐次进展 2020-12-13 04:49

I\'d like my program to read the cache line size of the CPU it\'s running on in C++.

I know that this can\'t be done portably, so I will need a solution for Linux an

7条回答
  •  生来不讨喜
    2020-12-13 05:49

    For x86, the CPUID instruction. A quick google search reveals some libraries for win32 and c++. I have used CPUID via inline assembler as well.

    Some more info:

    • http://www.intel.com/Assets/PDF/appnote/241618.pdf
    • http://softpixel.com/~cwright/programming/simd/cpuid.php

提交回复
热议问题