bug-gnubg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnubg] gcc 4.0 patch for 0.14.3


From: Øystein Johansen
Subject: Re: [Bug-gnubg] gcc 4.0 patch for 0.14.3
Date: Wed, 18 Jan 2006 21:56:37 +0100
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

At last I was able to look at this. No backgammon playing today. Just a
lazy wednesday. Really good!

Russ Allbery wrote:
> My guess is that this is already in CVS for 0.15, but just in case.
> 0.14.3 needed the following modifications to build with gcc 4.0.

Yes, some of these patches are already fixed.

> --- gnubg-0.14.3.orig/eval.c
> +++ gnubg-0.14.3/eval.c
> @@ -798,7 +798,11 @@
>           if( !fstat( h, &st ) &&
>               ( p = mmap( NULL, st.st_size, PROT_READ | PROT_WRITE,
>                           MAP_PRIVATE, h, 0 ) ) ) {
> -             ( (float *) p ) += 2; /* skip magic number and version */
> +                /* gcc 4 doesn't support casts as lvalues.
> +                   -- rra, 2006-01-14 */
> +                float *pf = p;
> +                pf += 2;              /* skip magic number and version */
> +                p = pf;
>               fReadWeights =
>                   ( p = NeuralNetCreateDirect( &nnContact, p ) ) &&
>                   ( p = NeuralNetCreateDirect( &nnRace, p ) ) &&

This snip of code has never been compiled at my system since it's now
inside a #if HAVE_MMAP && ! USE_SSE_VECTORIZE and of course I always use
the vectorization code. The patch is commited.

> --- gnubg-0.14.3.orig/rollout.c
> +++ gnubg-0.14.3/rollout.c
> @@ -219,7 +219,7 @@
>      nPermutationSeed = n;
>  }
>  
> -static int nSkip;
> +int nSkip;

Why this? I don't get any errors or warnings with my gcc-4.0.2

> --- gnubg-0.14.3.orig/lib/neuralnet.c
> +++ gnubg-0.14.3/lib/neuralnet.c
> @@ -385,14 +385,20 @@
>      return 0;
>  }
>  extern void *NeuralNetCreateDirect( neuralnet *pnn, void *p ) {
> - 
> -   pnn->cInput = *( ( (int *) p )++ );
> -   pnn->cHidden = *( ( (int *) p )++ );
> -   pnn->cOutput = *( ( (int *) p )++ );
> -   pnn->nTrained = *( ( (int *) p )++ );
> +   /* gcc 4 doesn't support casts as lvalues.  -- rra, 2006-01-14 */
> +   int *pi;
> +   float *pf;
> +
> +   pi = p;
> +   pnn->cInput = *( pi++ );
> +   pnn->cHidden = *( pi++ );
> +   pnn->cOutput = *( pi++ );
> +   pnn->nTrained = *( pi++ );
> +   p = pi;
>     pnn->fDirect = TRUE;
> -   pnn->rBetaHidden = *( ( (float *) p )++ );
> -   pnn->rBetaOutput = *( ( (float *) p )++ );
> +   pf = p;
> +   pnn->rBetaHidden = *( pf++ );
> +   pnn->rBetaOutput = *( pf++ );
>   
>     if( pnn->cInput < 1 || pnn->cHidden < 1 || pnn->cOutput < 1 ||
>       pnn->nTrained < 0 || pnn->rBetaHidden <= 0.0 ||
> @@ -402,14 +408,15 @@
>       return NULL;
>     }
>   
> -   pnn->arHiddenWeight = p;
> -   ( (float *) p ) += pnn->cInput * pnn->cHidden;
> -   pnn->arOutputWeight = p;
> -   ( (float *) p ) += pnn->cHidden * pnn->cOutput;
> -   pnn->arHiddenThreshold = p;
> -   ( (float *) p ) += pnn->cHidden;
> -   pnn->arOutputThreshold = p;
> -   ( (float *) p ) += pnn->cOutput;
> +   pnn->arHiddenWeight = pf;
> +   pf += pnn->cInput * pnn->cHidden;
> +   pnn->arOutputWeight = pf;
> +   pf += pnn->cHidden * pnn->cOutput;
> +   pnn->arHiddenThreshold = pf;
> +   pf += pnn->cHidden;
> +   pnn->arOutputThreshold = pf;
> +   pf += pnn->cOutput;
> +   p = pf;
>  
>     pnn->savedBase = malloc( pnn->cHidden * sizeof( float ) ); 
>     pnn->savedIBase = malloc( pnn->cInput * sizeof( float ) ); 

This has already been fixed in the cvs.

I really recommend trying a cvs build. Lots of things has been improved
since 0.14.3. Among those things are the sse vectorization which
increases the evaluation speed by about 50%.

-Øystein





reply via email to

[Prev in Thread] Current Thread [Next in Thread]