[computer-go] Precise clock cycles measurements

Łukasz Lew lukasz.lew at gmail.com
Fri Sep 1 05:59:55 PDT 2006


On 9/1/06, Chaslot G (MICC) <G.Chaslot at micc.unimaas.nl> wrote:
> Łukasz, thanks a lot for this code, this is a great way to measure speed!

I'm very happy :)

>
> Mango's stats, for playing the most stupid games:
>
> Nb of cc per game: 105035
> Nb of moves per game: 105.497
> Nb of games per second: 26062
>
> So around 996 cc per move in average.
>
> By the way:
> Nb of cc per sec = 105035 x 26062 = 2.74 G
> The computer being a 2.8 Ghz, this makes sense!
>
> If it plays less stupid games, it is slower: with the current settings about 17000 games per second.
>
> Best,
>
> Guillaume
>
>
> Ps1: The macro seems to have a very strange problem with fast things. When measuring the speed of rand(), it gave me an absurd result. I put then 30 rand() instead of one and the result was consistent. Maybe a problem with the "-43"? If we imagine that this -43 would only be true in average, this would explain the strange behavior that I observed.

Te constant "43" must be adapted to a particular hardware.
To do it just call
cc_time_of(cc_time, );
printf("overhead=%d\n", cc_time);

For me it prints 43 all the time.
Btw.
cc_time_of(cc_time, cc_time_of(tmp, );
printf("overhead=%d\n", cc_time);
prints 86 for me, because rtdsc is called twice.

>
> Ps2: The classical rand()on an opteron using linux seems to use only 30cc.
It seems strange.

Best Regards,
Łukasz

>
>
>
> -----Original Message-----
> From: computer-go-bounces at computer-go.org [mailto:computer-go-bounces at computer-go.org] On Behalf Of Lukasz Lew
> Sent: Thursday, August 31, 2006 3:06 PM
> To: computer-go
> Subject: [computer-go] Precise clock cycles measurements
>
> IMHO this is a way better than profiler.
> To measure clock cycles accurately of function call
>
> play(color, move)
>
> you may use
>
> unsigned long cc_time;
> cc_time_of(cc_time, play(color, move));
>
> Use this macro, (works for g++):
> [ Can someone port it to other compilers? ]
> ---
>
> #define get_cc_cnt(tsc)  __asm__ __volatile__("rdtsc" : "=A" (tsc) : : "edx")
>
> #define cc_time_of(t ,instr) \
>   do {\
>     unsigned int cc_start, cc_stop;\
>     get_cc_cnt(cc_start);\
>     instr;\
>     get_cc_cnt(cc_stop);\
>     t = cc_stop - cc_start - 43;\
>   } while (0)
>
> ---
>
> So what are Your average cc times of playing:
> one move?
> playout?
>
> Best regards,
> Łukasz
> _______________________________________________
> computer-go mailing list
> computer-go at computer-go.org
> http://www.computer-go.org/mailman/listinfo/computer-go/
>


More information about the computer-go mailing list