For CPU´s with SSE, but not SSE2:
Code: Select all
#Tries = 100000000
z.f
time = GetTickCount_()
For I = 0 To #Tries
;z = I
!cvtsi2ss xmm1,[v_I]
!sqrtss xmm0,xmm1
Next
!movss [v_z],xmm0
MessageRequester("SSE", Str(GetTickCount_()-time)+#CRLF$+StrF(z))
Code: Select all
;- CPU-SIMD-Test, "Helle" Klaus Helbing, 20.12.2006, PB4.02
Global mmx.c = $2d ;"-"
Global dnow.c = $2d
Global ednow.c = $2d
Global cmov.c = $2d
Global sse.c = $2d
Global sse2.c = $2d
Global sse3.c = $2d
Global ssse3.c = $2d
Global Bit0.l = $1 ;for SSE3
Global Bit9.l = $200 ;for SSSE3
Global Bit15.l = $8000 ;for CMOVcc
Global Bit21.l = $200000 ;for EFlag
Global Bit23.l = $800000 ;for MMX
Global Bit25.l = $2000000 ;for SSE
Global Bit26.l = $4000000 ;for SSE2
Global Bit30.l = $40000000 ;for extended 3DNow!
Global Bit31.l = $80000000 ;for 3DNow!
Global Name$ = "The tested CPU supported :"
Global MMX$ = "MMX : "
Global DNOW$ = "3DNow! : "
Global EDNOW$ = "ext3DNow! : "
Global CMOV$ = "CMOVcc : "
Global SSE$ = "SSE : "
Global SSE2$ = "SSE2 : "
Global SSE3$ = "SSE3 : "
Global SSSE3$ = "SSSE3 : "
;-------- Test, if CPUID is possible
!pushfd ;EFlag-Register (32-Bit) on the Stack
!pop eax ;copy to EAX
!mov edx,eax ;save EAX
!xor edx,[v_Bit21] ;toggle Bit21
!push edx
!popfd ;write in EFlag
!pushfd ;back to Stack
!pop edx
!push eax ;EAX back
!popfd
!cmp eax,edx
!jne l_iscpuid ;not equal -> CPUID is supported
MessageRequester("Status", "The tested CPU give no support for CPUID; no MMX or SSE !")
End
IsCPUID:
;------------------------------------------------------------------------------
;-------- Test of MMX, SSE, SSE2, SSE3 and SSSE3
!mov eax,1h
!cpuid
!test edx,[v_Bit23] ;MMX
!jz l_nommx
!mov [v_mmx],2bh ;"+"
NOMMX:
!test edx,[v_Bit25] ;SSE
!jz l_nosse
!mov [v_sse],2bh
NOSSE:
!test edx,[v_Bit26] ;SSE2
!jz l_nosse2
!mov [v_sse2],2bh
NOSSE2:
!test ecx,[v_Bit0] ;SSE3
!jz l_nosse3
!mov [v_sse3],2bh
NOSSE3:
!test ecx,[v_Bit9] ;SSSE3 ("old" SSE4)
!jz l_nossse3
!mov [v_ssse3],2bh
NOSSSE3:
;-------- Test of CMOVcc (conditional move)
!test edx,[v_Bit15]
!jz l_nocmov
!mov [v_cmov],2bh
NOCMOV:
;------------------------------------------------------------------------------
;-------- value of extended levels (for 3DNow!-Test)
;-------- back-value in EAX (-80000000h) = value of extended level
!mov eax,80000000h
!cpuid
!cmp eax,80000000h
!jbe l_noext ;no extended levels, no 3DNow!
;------------------------------------------------------------------------------
;-------- Test of 3DNow! and extended 3DNow!
!mov eax,80000001h ;80000001h is the first extended level, no supported from Intel-CPU´s!
!cpuid ;Intel-CPU´s gives EAX=0 return
!or eax,eax
!je l_noext ;is Intel-Prozessor
!test edx,[v_Bit31] ;3DNow!
!jz l_noext
!mov [v_dnow],2bh
!test edx,[v_Bit30] ;extended 3DNow!
!jz l_noext
!mov [v_ednow],2bh
NOEXT:
;------------------------------------------------------------------------------
MessageRequester(Name$,MMX$+Chr(mmx)+Chr(10)+DNOW$+Chr(dnow)+Chr(10)+EDNOW$+Chr(ednow)+Chr(10)+CMOV$+Chr(cmov)+Chr(10)+SSE$+Chr(sse)+Chr(10)+SSE2$+Chr(sse2)+Chr(10)+SSE3$+Chr(sse3)+Chr(10)+SSSE3$+Chr(ssse3))
End
Helle
Edit 10.01.2007: New detection for SSE3