News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

This is too slow

Started by frktons, November 18, 2010, 03:10:21 AM

Previous topic - Next topic

ramguru

sry, the dot confused me, I meant the number before dot 35.571
I guess that would be 1000 to 4000 cycles, the precision ..

frktons

Quote from: ramguru on November 22, 2010, 03:01:36 PM
sry, the dot confused me, I meant the number before dot 35.571
I guess that would be 1000 to 4000 cycles, the precision ..

1,000 - 4,000 cycles are about nothing, like millionth os seconds. Quite  normal I guess.
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

no - not normal
it helps if you restrict execution to a single core during the tests
        INVOKE  GetCurrentProcess
        INVOKE  SetProcessAffinityMask,eax,1

you may want to use GetProcessAffinityMask to restore it when an algo is not running

also - not sure which priority you are running with - HIGH_PRIORITY_CLASS usually works well

frktons

Quote from: dedndave on November 22, 2010, 03:16:48 PM
no - not normal
it helps if you restrict execution to a single core during the tests
        INVOKE  GetCurrentProcess
        INVOKE  SetProcessAffinityMask,eax,1

you may want to use GetProcessAffinityMask to restore it when an algo is not running

also - not sure which priority you are running with - HIGH_PRIORITY_CLASS usually works well

I'm using Michael Timing Macros, and the program uses:

counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS

I'm not sure about:

        INVOKE  GetCurrentProcess
        INVOKE  SetProcessAffinityMask,eax,1


You should know better than me what the default settings of Michael Macros are.

Mind is like a parachute. You know what to do in order to use it :-)

dedndave

well - Michael's macros don't mess with the affinity mask
i can tell you this from experience   :P
my machine is known to jump around on timing numbers
i think it has something to do with Media Center

frktons

Quote from: dedndave on November 22, 2010, 07:04:55 PM
well - Michael's macros don't mess with the affinity mask
i can tell you this from experience   :P
my machine is known to jump around on timing numbers
i think it has something to do with Media Center

What if I leave the default settings in Michael Macros?
Mind is like a parachute. You know what to do in order to use it :-)

Antariy

Quote from: frktons on November 22, 2010, 03:07:10 PM
Quote from: ramguru on November 22, 2010, 03:01:36 PM
sry, the dot confused me, I meant the number before dot 35.571
I guess that would be 1000 to 4000 cycles, the precision ..

1,000 - 4,000 cycles are about nothing, like millionth os seconds. Quite  normal I guess.

For 1000 cycles, 4 cycles of difference is 0.4% of flow. Almost all instruments allow flow +/- 3%. So, timings is quite stable  :lol

frktons

Quote from: Antariy on November 22, 2010, 10:00:31 PM
Quote from: frktons on November 22, 2010, 03:07:10 PM
Quote from: ramguru on November 22, 2010, 03:01:36 PM
sry, the dot confused me, I meant the number before dot 35.571
I guess that would be 1000 to 4000 cycles, the precision ..

1,000 - 4,000 cycles are about nothing, like millionth os seconds. Quite  normal I guess.

For 1000 cycles, 4 cycles of difference is 0.4% of flow. Almost all instruments allow flow +/- 3%. So, timings is quite stable  :lol


I told them  :lol
Mind is like a parachute. You know what to do in order to use it :-)

dedndave

the affinity mask has nothing to do with Michael's macros   :bg
you are simply selecting a single core to run the test

Antariy

Quote from: frktons on November 22, 2010, 08:30:02 AM
Alex is rightly proud of his flexible "Algo Manager", but I had not time to rearrange the code in order to use it.

"Proud" is the too strong therm :P

Well, if I'm incorporate the Manager into your latest release, and *if you will  use this tweaked release* for further development - that's will not hard.
It's just impossible to add manager into each new release :P, so, if you will stop for an moment, and accept a manager as "standard" - then things will be simpler. Since at current moment Manager is not "standard" (I have insert in manually) - that's not simple to made this for each step of development.

Antariy

Frank, would be better to implement selection of the one core to test.
If thread of the testbed would be switched to other core after first RDTSC, the timings will not fair, because cores have different counters of clocks.

frktons

Quote from: Antariy on November 22, 2010, 10:05:06 PM
Well, if I'm incorporate the Manager into your latest release, and *if you will  use this tweaked release*
for further development - that's will not hard.
It's just impossible to add manager into each new release :P, so, if you will stop for an moment,
and accept a manager as "standard" - then things will be simpler. Since at current moment Manager
is not "standard" (I have insert in manually) - that's not simple to made this for each step of development.

I'll be far from my pc for 4-5 days, so maybe this is the right moment to do it, if you want.
After that, I'll make new improvements using your Algo Manager as the standard. It'll
be easy when I have the complete program, with all the algos [6 up to now] already transformed
to work with the Manager, to add other PROCs. options, and algo as well.  :U

Please leave the columns as they are now, don't change them  :eek

Quote from: Antariy on November 22, 2010, 10:11:50 PM
Frank, would be better to implement selection of the one core to test.
If thread of the testbed would be switched to other core after first RDTSC, the timings will not fair,
because cores have different counters of clocks.

What and where should I insert the code?
Mind is like a parachute. You know what to do in order to use it :-)

Antariy

I'll be far from my pc for 4-5 days, so maybe this is the right moment to do it, if you want.

Maybe :P

with all the algos [6 up to now] already transformed to work with the Manager

My latest this http://www.masm32.com/board/index.php?topic=14871.msg125063#msg125063" release contain all 16 files, which is ready for algos inclusion and testing  :lol

Please leave the columns as they are now, don't change them  :eek

I'm not changed them at previous insertion, what is up??? :eek

What and where should I insert the code?

Some post above, Dave post code with "GetCurrentProcess" - that it is.

dedndave

selecting a single core is simple
it is also a good idea to do this when reading CPUID values to identify a processor

a good idea to:
1) select a single core
2) insure that CPUID is supported
3) insure that RDTSC is supported

that way, you know that Michael's timing macro will work on the machine
i assume that Alex's code verifies that

        .DATA?

hProc   dd ?       ;current process handle
dwPMask dd ?       ;process affinity mask
dwSMask dd ?       ;system affinity mask

        .CODE

;------------------------------------------------------------------------------
;initialization code section
;------------------------------------------------------------------------------

;get and save current process handle

        INVOKE  GetCurrentProcess
        mov     hProc,eax

;get and save system and process affinity masks

        INVOKE  GetProcessAffinityMask,hProc,offset dwPMask,offset dwSMask

;------------------------------------------------------------------------------

;------------------------------------------------------------------------------
;run timing test code section
;------------------------------------------------------------------------------

;restrict execution to a single core (mask = 1 selects core 0)

        INVOKE  SetProcessAffinityMask,hProc,1

;
;timing test code goes here
;

;restore original process affinity mask

        INVOKE  SetProcessAffinityMask,hProc,dwPMask

;------------------------------------------------------------------------------

frktons

This is the display my version produces:


┌─────────────────────────────────────────────────────────────[22-Nov-2010 at 22:28 GMT]─┐
│OS  : Microsoft Windows 7 Ultimate Edition, 64-bit (build 7600)                         │
│CPU : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz with 2 logical core(s) with SSSE3           │
├──────────────────────────────────┬─────────┬──────────┬──────────┬──────────┬──────────┤
│        Algorithm notes           │Proc Size│ Test # 1 │ Test # 2 │ Test # 3 │ Test # 4 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│01 ustrv$ + GetNumberFormat       │    95   │   44.362 │   44.218 │   44.254 │   44.123 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│02 udw2str + GetNumberFormat      │    65   │   44.190 │   43.981 │   44.181 │   43.973 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│03 wsprintf + GetNumberFormat     │    73   │   50.618 │   50.611 │   50.737 │   50.675 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│04 Clive - IDIV and Stack         │   120   │    3.068 │    3.068 │    3.053 │    3.063 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│05 Clive - reciprocal IMUL        │   157   │    2.024 │    2.006 │    1.970 │    1.972 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│06 Hutch ustr$ + format algo      │   159   │    5.563 │    5.623 │    5.565 │    5.539 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤


This is your version:


┌─────────────────────────────────────────────────────────────[22 Nov 2010 at 22:29 GMT]─┐
│OS  : Microsoft Windows 7 Ultimate Edition, 64-bit (build 7600)                         │
│CPU : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz with 2 logical core(s) with SSSE3           │
├──────────────────────────────────┬─────────┬──────────┬──────────┬──────────┬──────────┤
│        Algorithm notes           │Proc Size│ Test # 1 │ Test # 2 │ Test # 3 │ Test # 4 │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│01 Alex / MMX                     │  55     │ 5.415    │ 5.409    │ 5.411    │ 5.407    │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│02 Frank / SSE2                   │  45     │ 4.465    │ 4.464    │ 4.464    │ 4.464    │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│03 Here can be your advertisement │  0      │          │          │          │          │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│04 Here can be your advertisement │  0      │          │          │          │          │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│05 Here can be your advertisement │  0      │          │          │          │          │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│06 Here can be your advertisement │  0      │          │          │          │          │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤
│07 Here can be your advertisement │  0      │          │          │          │          │
├──────────────────────────────────┼─────────┼──────────┼──────────┼──────────┼──────────┤


look carefully and see what I mean.

I would like to know where to put the :


       INVOKE  GetCurrentProcess
       INVOKE  SetProcessAffinityMask,eax,1





Mind is like a parachute. You know what to do in order to use it :-)