summing large arrays - or - performance of tight loops

Dave Dave_member at pathlink.com
Mon Apr 23 12:24:32 PDT 2007


Thomas Kuehne wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Dave schrieb am 2007-04-19:
>> Manfred Nowak wrote:
>>> Dave wrote
>>>> Mine were ran on a P4 chip and an AMD64 chip (original was
>>>> Turion). 
>>> It is disgusting to see, that three random benchmarkers all get 
>>> different results. Mine were run on an AMD64 X2 under WinXP32 and 
>>> compiled with DMD1.012.
>>>
>>> Quotients (foreach/other):
>>> Thomas: 200%
>>> Dave:   100%
>>> me:      85%
>>>
>>> What causes those huge differences?
>>>
>>> Here is my main:
> 
> <snip>
> 
>> I was using a simple 1024 x 1024 size array before.
>>
>> Using a 1024 x 1024 x 64 array, I got:
>>
>> P4:    97% (linux32 FC5)
>> AMD64: 92% (WinXP32)
>>
>> So, the array size seems to make some difference, at least on AMD machines.
> 
> The results strongly depend on the memory architecture and to a lesser

Yea, with "...the array size seems to make some difference...", I was referring to slight 
differences between tests on my machines.

> extend on the element values. I've put an updated version online that
> contains results for byte, short, int, long, float and double.
> 

I agree, I think the big (relative foreach/other) difference between machines is probably because of 
different cache sizes, or it could be alignment issues I guess. All this seems to indicate that the 
code generated for foreach is more sensitive to mem. arch. than the other loops.

That said, three of the four architectures spoken of in this thread had foreach perform as well as 
or better than the common while-loop anyway.

> The benchmarking was done as follows:
> 
> dmd sum.html -O -release -inline -version=benchmark
> ./sum 2> /dev/null
> 
> Thomas
> 
> 
> -----BEGIN PGP SIGNATURE-----
> 
> iD8DBQFGKhZsLK5blCcjpWoRAha5AJ40lu7apkLufJgfi8wFYiFfIuhWTACdGUJg
> 3MiQxN7N15GlC+J6OEilwuM=
> =dXko
> -----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list