News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

GetCpuFrequency Tests

Started by dedndave, October 13, 2015, 08:34:58 PM

Previous topic - Next topic

jj2007

Since I've not yet fully understood the meaning of the results, I rolled my own:
Intel(R) Core(TM) i5-2450M CPU @ 2.50GHz
Heating up...
RDTSC in ... out, 2.552 GHz
RDTSC in ... out, 2.517 GHz
RDTSC in ... out, 2.518 GHz
RDTSC in ... out, 2.536 GHz
RDTSC in ... out, 2.542 GHz


Intel(R) Celeron(R) CPU  N2840  @ 2.16GHz
Heating up...
RDTSC in ... out, 2.201 GHz
RDTSC in ... out, 2.202 GHz
RDTSC in ... out, 2.201 GHz
RDTSC in ... out, 2.204 GHz
RDTSC in ... out, 2.203 GHz


Farabi

Why not meassure it in direct memory transfer within looping in 1 gigs loop. It  will force the vendor design better.

mov ecx,some_pointer

mov ecx,1000000000
break_vendor_credibilitty:
mov eax,[some_pointer]
jecxz break_vendor_credibility


:greenclp:
http://farabidatacenter.url.ph/MySoftware/
My 3D Game Engine Demo.

Contact me at Whatsapp: 6283818314165

TWell

AMD 2.8 GHz
AMD Athlon(tm) II X2 220 Processor
Heating up...
RDTSC in ... out, 2.807 GHz
RDTSC in ... out, 2.901 GHz
RDTSC in ... out, 2.851 GHz
RDTSC in ... out, 2.817 GHz
RDTSC in ... out, 2.894 GHz
with simple versionRDTSC in ... out, 2.903 GHz
RDTSC in ... out, 2.868 GHz
RDTSC in ... out, 2.831 GHz
RDTSC in ... out, 2.823 GHz
RDTSC in ... out, 2.858 GHz

.686
.model flat,stdcall

ExitProcess PROTO :DWORD
GetTickCount PROTO
INCLUDELIB kernel32.lib

printf PROTO CDECL :VARARG
INCLUDELIB msvcrt.lib

.data
msg1 DB "RDTSC in ... ",0
msg2 DB "out",0
msg3 DB ", %4.3f GHz",13,10,0
m1 QWORD 0.000000001
pf QWORD ?

.code
main PROC
xor ecx, ecx
.Repeat
inc ecx
.Until Sign?
REPEAT 5
invoke printf, addr msg1
cpuid
rdtsc
push edx
push eax
invoke GetTickCount
add eax, 1000 ; one second
push eax
xor esi, esi
.Repeat
inc esi
test esi, 0ffffffh
.if Zero?
invoke GetTickCount ; ca. 93 calls per run
.endif
.Until eax>[esp]
pop edx
invoke printf, offset msg2
rdtsc
push edx
push eax
fild qword ptr [esp]
add esp, qword
fild qword ptr [esp]
add esp, qword
fsub
fmul qword ptr m1
fst pf
invoke printf, offset msg3, pf
ENDM
INVOKE ExitProcess,0
main ENDP
END main

FORTRANS

Hi,

   Doesn't work on the P-III as expected.  Here are the Pentium M
results.  First to screen, second redirected to a file.

Intel(R) Pentium(R) M processor 1.70GHz
Heating up...
RDTSC in ... out, 1.705 GHz
RDTSC in ... out, 1.704 GHz
RDTSC in ... out, 1.736 GHz
RDTSC in ... out, 1.732 GHz
RDTSC in ... out, 1.721 GHz

Intel(R) Pentium(R) M processor 1.70GHz
Heating up...
RDTSC in ... out, 1.702 GHz
RDTSC in ... out, 1.708 GHz
RDTSC in ... out, 1.705 GHz
RDTSC in ... out, 1.706 GHz
RDTSC in ... out, 1.706 GHz


Regards,

Steve N.

Siekmanski

Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz
Heating up...
RDTSC in ... out, 3.439 GHz
RDTSC in ... out, 3.440 GHz
RDTSC in ... out, 3.473 GHz
RDTSC in ... out, 3.440 GHz
RDTSC in ... out, 3.474 GHz
Creative coders use backward thinking techniques as a strategy.

HSE

Hi Dave!


Doszip Macro Assembler Version 2.14, BETA  09/11/15
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.

Assembling: Getcpufrequency.asm

***********
ASCII build
***********

Getcpufrequency.asm(138) : error A2084: constant value too large
_
Assembly Error
Presione una tecla para continuar . . .



JWasm v2.13, Aug  8 2015, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.


***********
ASCII build
***********

GetCpuFrequency.asm(138) : Error A2239: Constant value too large: 1F4000000h
GetCpuFrequency.asm: 466 lines, 1 passes, 136 ms, 0 warnings, 1 errors


Modification:
__CountExponent = 22

Results:


AMD A6-3500 APU with Radeon(tm) HD Graphics

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 KHz

Press any key to continue ...

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 KHz

Press any key to continue ...



Modification:
__CountExponent = 12

Result:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2101141 KHz



__CountExponent = 8

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2859 KHz



AMD A6-3500 APU with Radeon(tm) HD Graphics
Heating up...
RDTSC in ... out, 2.124 GHz
RDTSC in ... out, 2.120 GHz
RDTSC in ... out, 2.202 GHz
RDTSC in ... out, 2.157 GHz
RDTSC in ... out, 2.142 GHz

Equations in Assembly: SmplMath

dedndave

1 SHL 23 is 1000 0000 0000 0000 0000 0000 binary, or 800000h - that should fit in 32 bits   :redface:

HSE

Ok. Ml compile with 1 SHL 23, but result  0 Khz. Work well with 1 SHL 12 (and others like 18).
Equations in Assembly: SmplMath

nidud

#38
deleted

dedndave

thanks HSE and nidud - that is definately a bug that i missed   :t
it probably happened, as i increased the __CountExponent, without checking the range of 1000X - oops

that does solve a few problems - like the case where the routine takes too long
it doesn't make sense to me that it causes a 0 result, though - have to look into that   :redface:

dedndave

that one was easy to fix

            mov     edx,_dwQPFreqHi
            mov     eax,__CountLength
            mov     ebx,_dwQPFreqLo
            bsr     ecx,edx
            .if !ZERO?
                inc     ecx
                shrd    ebx,edx,cl
                adc     ebx,0
                xor     edx,edx
                shr     eax,cl
                adc     eax,edx
            .endif
            .if ebx
                mov     edx,1000
                mul     edx
                div     ebx


load the unmultiplied value - then MUL by 1000 just before DIV

HSE

Ok with __CountExponent = 20
Equations in Assembly: SmplMath

dedndave

ok - ready to try again.....

QueryPerformanceFrequency: 00000000_B2D0FA40h
            EFlags Toggle: 00240000h
                CPUID TSC: Supported
               RDTSC Test: Pass
          GetCpuidSupport: 00240010h
              dwSleepTime: 1
             dwMultiplier: 1536020480
                 Measured: 8389545, 8389215, 8388772, 8389125, 8389433
                   Sorted: 8388772, 8389125, 8389215, 8389433, 8389545

          GetCpuFrequency: 3000241 KHz

Press any key to continue ...


test program and source attached...

sinsi


QueryPerformanceFrequency: 00000000_00342787h
            EFlags Toggle: 00240000h
                CPUID TSC: Supported
               RDTSC Test: Pass
          GetCpuidSupport: 00240010h
              dwSleepTime: 2451
             dwMultiplier: 1750011
                 Measured: 890, 1006, 166412, 879, 1019
                   Sorted: 879, 890, 1006, 1019, 166412

          GetCpuFrequency: 0 KHz


dedndave

thanks John   :t

guess i have to re-think that calculation, altogether   :lol: