On Mon, 23 Oct 2006, Tom Lane wrote:

> Hmm.  Maybe store the CRCs into a global array somewhere?
>
>       uint32 results[NTESTS];
>
>       for ...
>       {
>               INIT/COMP/FIN_CRC32...
>               results[j] = mycrc;
>       }
>
> This still adds a bit of overhead to the outer loop, but not much.
>

That seems to have worked.

            Std crc     Slice-8 crc

Intel P4 Xeon 2.8Ghz (Gentoo, gcc-3.4.5, -O2)

8192 bytes  26.765317   10.511143
1024 bytes  3.357843    1.280890
64 bytes    0.223213    0.103767

Intel P4 Xeon 2.8Ghz (Gentoo, icc-9.0.032, -O2 -xN -ipo -parallel)

8192 bytes  29.495836   0.007107
1024 bytes  3.708665    0.012183
64 bytes    0.242579    0.008700


So the gcc times are reasonable, but the icc times for the slice-by-8 are
still too fast to be believed.  I will have to take a look at the
generated assembly later and see what gives.

My changed testcrc.c is attached, again.


-- 
"I'd love to go out with you, but I did my own thing and now I've got
to undo it."
#include "postgres.h"

#include <time.h>
#include <sys/time.h>

#include "pg_crc.h"

int
main()
{
        volatile char   buffer[TESTSIZE];
        pg_crc32        results[NTESTS];
        pg_crc32        mycrc;
        int                     j;
        struct timeval tstart;
        struct timeval tstop;
        
    srand(time(NULL));
    for (j = 0; j < TESTSIZE; ++j)
                buffer[j] = (char) (255 * (rand() / (RAND_MAX + 1.0)));

        gettimeofday(&tstart, NULL);

        for (j = 0; j < NTESTS; j++)
        {
                INIT_CRC32(mycrc);
                COMP_CRC32(mycrc, buffer, TESTSIZE);
                FIN_CRC32(mycrc);
                results[j] = mycrc;
        }

        gettimeofday(&tstop, NULL);

        if (tstop.tv_usec < tstart.tv_usec)
        {
                tstop.tv_sec--;
                tstop.tv_usec += 1000000;
        }

        printf("bufsize = %d, loops = %d, elapsed = %ld.%06ld\n",
                   TESTSIZE, NTESTS,
                   (long) (tstop.tv_sec - tstart.tv_sec),
                   (long) (tstop.tv_usec - tstart.tv_usec));

        return 0;
}
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to