一部の Intel CPU にはハイパースレッディングがあり、レジスタ EDX のビット 28 を CPUID から読み取ることで検出できます。AMD CPU にはハイパースレッディングはありませんが、一部の CPU には 2 つの整数ユニットと 1 つの浮動小数点ユニットを持つモジュールがあります。CPUID などを使用して、CPU にモジュールがあるかどうかを検出する方法はありますか?
編集:Jesterの回答に基づいて、「計算ユニット」(別名モジュール)あたりのコア数を決定するために、次のテストされていない関数(AMDプロセッサにアクセスできません)を思いつきました。
// input: eax = functionnumber, ecx = 0
// output: eax = output[0], ebx = output[1], ecx = output[2], edx = output[3]
//static inline void cpuid (int output[4], int functionnumber)
void coresPerComputeUnit() {
int abcd[4];
int cores = 1;
cpuid(abcd,0x80000000);
if(abcd[0]<0x8000001E) return; // Fn8000_001E not available
cpuid(abcd,0x8000001E);
cores += (abcd[1] & 0xff00) >> 8; //ebx bit 15:8 CoresPerComputeUnit
}
http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2012/10/42301_15h_Mod_00h-0Fh_BKDG1.pdf