我試着在我的電腦上運行下面的程序(Fedora 17 32bit)。我怎樣才能使我的系統支持popcnt
快速人口計數指令?如何在計算機上啓用對POPCNT指令/內在的支持?
#include <stdio.h>
#include <smmintrin.h>
int main(void)
{
int pop = _mm_popcnt_u32(0xf0f0f0f0ULL);
printf("pop = %d\n", pop);
return 0;
}
我編譯程序,並運行它,但有以下異常:
[[email protected] tmp]$ gcc -Wall -march=corei7 -m32 -msse4.2 popcnt.c -o popcnt
[[email protected] tmp]$ ./popcnt
Illegal instruction (core dumped)
以下是我的處理器的信息:
[[email protected] tmp]$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 15
model name : Intel(R) Pentium(R) Dual CPU T2370 @ 1.73GHz
stepping : 13
microcode : 0xa4
cpu MHz : 800.000
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm dtherm
bogomips : 3458.20
clflush size : 64
cache_alignment : 64
address sizes : 36 bits physical, 48 bits virtual
power management:
[... repeated for 2nd core ...]
的確。換言之,'popcnt'作爲SSE4的一部分添加(並且OP的T2370僅支持補充SSE3)。 –
'POPCNT'與SSE4.2同時引入,但不是它的一部分。它有它自己的'CPUID'位。 –
儘管出現舊學校的危險,IBM POWER5已經推出了「POPCNT」。 http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.alangref/idalangref_popcntbd.htm?lang=it – jupp0r