c++如何获得cpu缓存信息

cpuid我能查到的资料,并不能判断我现在电脑的缓存配置了
我现在电脑的三级缓存是,3MB,12WAY 64BYTELINE,我查的资料没有这个
而且一级二级返回的和资料上查的不对,但是不知道为什么cpuid不能获得正确信息。
求最新的cpuid资料

以下我的代码
map > mCache;
mCache[0x06] = make_pair(1, 8);
mCache[0x08] = make_pair(1, 16);
mCache[0x0a] = make_pair(1, 8);
mCache[0x0c] = make_pair(1, 16);
mCache[0x0d] = make_pair(1, 16);
mCache[0x2c] = make_pair(1, 32);
mCache[0x30] = make_pair(1, 32);
mCache[0x60] = make_pair(1, 16);
mCache[0x66] = make_pair(1, 8);
mCache[0x67] = make_pair(1, 16);
mCache[0x68] = make_pair(1, 32);
mCache[0x39] = make_pair(2, 128);
mCache[0x3a] = make_pair(2, 192);
mCache[0x3b] = make_pair(2, 128);
mCache[0x3c] = make_pair(2, 256);
mCache[0x3d] = make_pair(2, 384);
mCache[0x3e] = make_pair(2, 512);
mCache[0x41] = make_pair(2, 128);
mCache[0x42] = make_pair(2, 256);
mCache[0x43] = make_pair(2, 512);
mCache[0x44] = make_pair(2, 1024);
mCache[0x45] = make_pair(2, 2048);
mCache[0x46] = make_pair(3, 4096);
mCache[0x47] = make_pair(2, 8192);
mCache[0x48] = make_pair(2, 3072);
mCache[0x49] = make_pair(3, 3072);
mCache[0x4a] = make_pair(3, 6144);
mCache[0x4b] = make_pair(3, 3072);
mCache[0x4c] = make_pair(3, 12288);
mCache[0x79] = make_pair(2, 128);
mCache[0x7a] = make_pair(2, 256);
mCache[0x7b] = make_pair(2, 512);
mCache[0x7c] = make_pair(2, 1024);
mCache[0x82] = make_pair(2, 256);
mCache[0x83] = make_pair(2, 512);
mCache[0x84] = make_pair(2, 1024);
mCache[0x85] = make_pair(2, 2048);
mCache[0x86] = make_pair(2, 512);
mCache[0x87] = make_pair(2, 1024);
mCache[0x22] = make_pair(3, 512);
mCache[0x23] = make_pair(3, 1024);
mCache[0x25] = make_pair(3, 2048);
mCache[0x29] = make_pair(3, 4096);

unsigned char byteReg[17] = { '\0' };
unsigned int dEbx, dEdx, dEcx, dEax;
__asm
{
    mov eax, 2
    cpuid
    mov dEbx, ebx
    mov dEdx, edx
    mov dEcx, ecx
    mov dEax, eax
}
memcpy(byteReg, &dEax, 4);
memcpy(byteReg + 4, &dEbx, 4);
memcpy(byteReg + 8, &dEcx, 4);
memcpy(byteReg + 12, &dEdx, 4);

for (int i = 1;i != 16;++i)
{
    if (mCache.find(byteReg[i]) == mCache.end())
        continue;
    if (mCache[byteReg[i]].first >= 1 && mCache[byteReg[i]].first <= 3)
        cpuCacheInfo[mCache[byteReg[i]].first] = mCache[byteReg[i]].second;
}
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问