キャッシュ情報を読み込み表示してみましょう。
#include <iostream> #include <intrin.h> using namespace std; int main() { int regs[4]; const unsigned int id = (unsigned int)0x80000006; __cpuid(regs, 0x80000000); if ((unsigned int)regs[0] >= id) { __cpuid(regs, 0x80000006); int nCacheLineSize = regs[2] & 0xff; int nL2Associativity = (regs[2] >> 12) & 0xf; int nCacheSizeK = (regs[2] >> 16) & 0xffff; cout << "Cache Line Size = " << nCacheLineSize << endl; cout << "L2 Associativity = " << nL2Associativity << endl; cout << "Cache Size = " << nCacheSizeK << "[Kb]" << endl; } }
実行例:
Cache Line Size = 64
L2 Associativity = 7
Cache Size = 256[Kb]