On 05/07/2010 19:43, Joern Rennecke wrote:
> Quoting Béla MIHALIK <bela.miha...@gmail.com>:
> 
>> If I compile it with mingw32 compiler, or VisualC++ then it gives good
>> result.
>> 
>> Here are my results for memory bandwith test:
>> 
>> Linux: 373.574249 MB/s Win32: 4468.297363 MB/s
> 
> I don't think that has anything to do with the code generated by the 
> compiler; rather, I think the random function you use on Windows is broken.

  It's fine, it's just that the testcase doesn't account for RAND_MAX, which
is only 0x7fff in MSVC runtime, so it only ever ends up swapping entries in
the first 32k (array elements, not bytes) of each block:

>       const int       nofElems = 64 * 1024 * 1024;

>       for ( i=0; i<nofMoves; i++ )
>       {
>               memRand1[i] = rand() % nofElems;
>               memRand2[i] = rand() % nofElems;
>       }

>       for ( i=0; i<nofMoves; i++ )
>       {
>               mem1[ memRand1[i] ] = mem2[ memRand2[i] ];
>       }


  In the GLIBC runtime, RAND_MAX is 0x7fffffff, so that's big enough to cover
the entire span of the nofElems-sized arrays.

  Since there's no compiler bug, this is gcc-help@ material; please send any
follow-ups to that list.

    cheers,
      DaveK

Reply via email to