core2 popcnt

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

frankp
Posts: 228
Joined: Sun Mar 12, 2006 3:11 pm

core2 popcnt

Post by frankp »

Does the core2 (Yorkfield 45nm) have hardware popcount, or is it only the i7 Nahalem - and later cores?
Nick C

Re: core2 popcnt

Post by Nick C »

Does the core2 (Yorkfield 45nm) have hardware popcount, or is it only the i7 Nahalem - and later cores?
The latter, unfortunately my QX9650 (Yorkfield 45nm) does not have POPCNT. The AMD 10h processor range has POPCNT also.
trojanfoe

Re: core2 popcnt

Post by trojanfoe »

During runtime you can test CPU capabilities using the 'cpuid' instruction:

Code: Select all

get_cpu_caps PROC
	mov eax, 01h
	cpuid					; ecx=feature info 1, edx=feature info 2

	xor eax, eax			; prepare return value

	test edx, 1 SHL 0
	jz not_fpu
	or eax, CPUCAP_FPU

not_fpu:
	test edx, 1 SHL 23

... blah blah blah ....

	test ecx, 1 SHL 23
	jz not_popcnt
	or eax, CPUCAP_POPCNT

not_popcnt:
	ret

get_cpu_caps ENDP