[Top][All Lists]
[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
- Re: [gnugo-devel] engine/influence.c (and DFA), (continued)
- Re: [gnugo-devel] engine/influence.c (and DFA), Gunnar Farneback, 2002/09/03
- Re: [gnugo-devel] engine/influence.c (and DFA), bump, 2002/09/06
- Re: [gnugo-devel] engine/influence.c (and DFA),
Dave Denholm <=
- Re: [gnugo-devel] engine/influence.c (and DFA), bump, 2002/09/06
- Re: [gnugo-devel] engine/influence.c (and DFA), Dave Denholm, 2002/09/06
- Re: [gnugo-devel] engine/influence.c (and DFA), bump, 2002/09/06
- Re: [gnugo-devel] engine/influence.c (and DFA), Arend Bayer, 2002/09/12
- Re: [gnugo-devel] engine/influence.c (and DFA), Dave Denholm, 2002/09/12
- Re: [gnugo-devel] engine/influence.c (and DFA), Arend Bayer, 2002/09/12
- Re: [gnugo-devel] engine/influence.c, Arend Bayer, 2002/09/20
- Re: [gnugo-devel] engine/influence.c, Gunnar Farneback, 2002/09/21
- Re: [gnugo-devel] engine/influence.c, Arend Bayer, 2002/09/23
- Re: [gnugo-devel] engine/influence.c, Arend Bayer, 2002/09/24