core2 popcnt

Discussion of chess software programming and technical issues.

Moderators: Harvey Williamson, bob, hgm

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
frankp
Posts: 228
Joined: Sun Mar 12, 2006 2:11 pm

core2 popcnt

Post by frankp » Fri Feb 13, 2009 6:33 pm

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 » Fri Feb 13, 2009 7:43 pm

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 » Sat Feb 14, 2009 10:53 am

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


Post Reply