Sure,

A lot faster is ranrot in 64 bits, at K8 2.2ghz with old GCC it is about 3.3 ns for each number, so i assume it's quite a tad faster than that for core2. Note it's quite slow at itanium, about 9-10 nanoseconds a number, as it appeared later itanium has no rotate hardware instructions :)

Here is how i rewrote it:

/* define parameters (R1 and R2 must be smaller than the integer size): */
#define KK  17
#define JJ  10
#define R1   5
#define R2   3
#define BITBOARD (unsigned long long)

/* global variables Ranrot */
BITBOARD randbuffer[KK+3] = { /* history buffer filled with some random numbers */ 0x92930cb295f24dab, 0x0d2f2c860b685215,0x4ef7b8f8e76ccae7,0x03519154af3ec239,0x195e36fe715fa d23, 0x86f2729c24a590ad,0x9ff2414a69e4b5ef, 0x631205a6bf456141,0x6de386f196bc1b7b,0x5db2d651a7bdf825, 0x0d2f2c86c1de75b7,0x5f72ed908858a9c9,0xfb2629812da87693,0xf3088fedb657f 9dd,0x00d47d10ffdc8a9f, 0xd9e323088121da71,0x801600328b823ecb, 0x93c300e4885d05f5,0x096d1f3b4e20cd47,0x43d64ed75a9ad5d9 /*0xa05a7755512c0c03,0x960880d9ea857ccd,0x7d9c520a4cc1d30f, 0x73b1eb7d8891a8a1,0x116e3fc3a6b7aadb*/
};
int r_p1, r_p2;          /* indexes into history buffer */

/******************************************************** AgF 1999-03-03 * * Random Number generator 'RANROT' type B * * by Agner Fog * * * * This is a lagged-Fibonacci type of random number generator with * * rotation of bits. The algorithm is: * * X[n] = ((X[n-j] rotl r1) + (X[n-k] rotl r2)) modulo 2^b * * * * The last k values of X are stored in a circular buffer named * * randbuffer. * * * * This version works with any integer size: 16, 32, 64 bits etc. * * The integers must be unsigned. The resolution depends on the integer * * size. * * * * Note that the function RanrotAInit must be called before the first * * call to RanrotA or iRanrotA * * * * The theory of the RANROT type of generators is described at * * www.agner.org/random/ ranrot.htm * * * ************************************************************************ */

FORCEINLINE BITBOARD rotl(BITBOARD x,int r) {return(x<<r)|(x>>(64-r));}

/* returns a random number of 64 bits unsigned */
FORCEINLINE BITBOARD RanrotA(void) {
  /* generate next random number */
BITBOARD x = randbuffer[r_p1] = rotl(randbuffer[r_p2],R1) + rotl (randbuffer[r_p1], R2);
  /* rotate list pointers */
  if( --r_p1 < 0)
    r_p1 = KK - 1;
  if( --r_p2 < 0 )
    r_p2 = KK - 1;
  return x;
}

/* this function initializes the random number generator.      */
void RanrotAInit(void) {
  int i;

/* one can fill the randbuffer here with possible other values here */
  randbuffer[0] = 0x92930cb295f24000 | (BITBOARD)ProcessNumber;
  randbuffer[1] = 0x0d2f2c860b000215 | ((BITBOARD)ProcessNumber<<12);

  /* initialize pointers to circular buffer */
  r_p1 = 0;
  r_p2 = JJ;

  /* randomize */
  for( i = 0; i < 300; i++ )
    (void)RanrotA();
}

Please note there is faster RNG's than ranrot, with some shifting here and there. But maybe ranrot is what is sufficient. You won't search enough nodes coming 10
years to get in trouble with it :)

Note that the parameter 'processnumber' is the process number of each process (or thread)
of search. Safely works up to 4096 cores :)

On Oct 10, 2008, at 12:36 AM, Don Dailey wrote:

On Thu, 2008-10-09 at 15:20 -0400, [EMAIL PROTECTED] wrote:
Computers + random = can of worms.

Has anyone seen this:

 http://home.southernct.edu/~pasqualonia1/ca/report.html#files

They are claiming impressive speed and high quality for a random number generator. The code is compact and small, much nicer than mt19937 and
the speed seems to blow mt19937 out of the water.

I haven't looked at any papers on this and I'm wondering how good it is.

 Here is quote:


        The cellular automaton outperforms the GSL random number
        generators, being more than three times as fast as the GSL
        generators.

        The following table shows the mean time for 10 runs of each
        generator, with each run producing 10 million integers. Source
code for both the GSL generators and the cellular automaton was compiled using GCC version 4.1.0 with the -O2 optimization flag.

RNG: Mean time to produce 10 million integers:

        cellular automaton        0.062000 seconds
        gsl_rng_taus              0.200000 seconds
        gsl_rng_gfsr4             0.200000 seconds
        gsl_rng_mt19937           0.223000 seconds
        gsl_rng_ranlxd1           2.652000 seconds


- Don

_______________________________________________
computer-go mailing list
[email protected]
http://www.computer-go.org/mailman/listinfo/computer-go/

_______________________________________________
computer-go mailing list
[email protected]
http://www.computer-go.org/mailman/listinfo/computer-go/

Reply via email to