gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] engine/influence.c (and DFA)


From: Dave Denholm
Subject: Re: [gnugo-devel] engine/influence.c (and DFA)
Date: 06 Sep 2002 16:55:40 +0100

<address@hidden> writes:

> > Noticed something odd about the unrolled loop in accumulate_influence(): it
> > still has 'continue' statements in it, which means, unless I'm missing
> > something obvious, the behaviour is different when the loop is unrolled or
> > not.
> > 
> > When the loop is not unrolled, the continue means to go and do the
> > next direction.
> > 
> > But when the loop is unrolled, the same continue statement means
> > abandon this queue entry entirely, and go on to the next one.
> 
> Here are the test results after defining
> 
> #define EXPLICIT_LOOP_UNROLLING 0
> 
> in influence.c. Test results are current, so the unexpected results are
> ALL due to this change.
> 


There are two changes required to make the unrolled version
exactly the same as the loop :



1) add  do { ... } while(0)  around the whole of the macro defn,
  so that continue means the correct thing.

  Wrapping complex macros in this way is usually considered good
  practise.

#define code1(arg_di, arg_dj, arg_i, arg_j, arg_d) do {\
    if (q->p[arg_i][arg_j] == EMPTY \
    ... { \
      ...
          q->w[arg_i][arg_j] += contribution; \
     } } while(0)




2) Change the order in which the unrolled loop invokes the
  macro to match the order of deltai[] and deltaj[]

By my reckoning, that's

    if (i<board_size-1)
      code1( 1, 0, i+1, j, 0);
    if (j>0)
      code1( 0,-1, i, j-1, 0);
    if (i>0)
      code1(-1, 0, i-1, j, 0);
    if (j<board_size-1)
      code1( 0, 1, i, j+1, 0);

    if (i<board_size-1 && j>0)
      code1( 1,-1, i+1, j-1, 1);
    if (i>0 && j>0)
      code1(-1,-1, i-1, j-1, 1);
    if (i>0 && j<board_size-1)
      code1(-1, 1, i-1, j+1, 1);
    if (i<board_size-1 && j<board_size-1)
      code1( 1, 1, i+1, j+1, 1);




With these two changes, I was getting exactly the same output
(in my limited testing) with loops rolled or unrolled.


dd
-- 
address@hidden          http://www.insignia.com




reply via email to

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