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: Arend Bayer
Subject: Re: [gnugo-devel] engine/influence.c (and DFA)
Date: Thu, 12 Sep 2002 12:54:16 +0200 (CEST)

On 6 Sep 2002, Dave Denholm wrote:

> <address@hidden> writes:
> >
> > 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.
>
> 2) Change the order in which the unrolled loop invokes the
>   macro to match the order of deltai[] and deltaj[]

I have tried out 1), and got
* exactly the same regression delta as Dan posted it a couple of days
ago
* unfortunately, a big slowdown:
Running on safety.tst (which contains only early game positions):

Profile of cvs:
 time   seconds   seconds    calls  ms/call  ms/call  name
 10.57      7.82     7.82    21833     0.36     0.36  accumulate_influence
  7.88     13.65     5.83    14234     0.41     0.46  compute_primary_domains
  6.29     18.30     4.65  3702272     0.00     0.00  scan_for_patterns
  4.10     21.33     3.03     8311     0.36     0.36  do_push_owl
  4.08     24.35     3.02  4273229     0.00     0.00  check_pattern_light
  3.04     26.60     2.25  4514435     0.00     0.00  fastlib

Profile with this change:
 22.31     17.24    17.24    23074     0.75     0.75  accumulate_influence
  6.29     22.10     4.86    12088     0.40     0.44  compute_primary_domains
  4.72     25.75     3.65  3127560     0.00     0.00  scan_for_patterns
  3.52     28.47     2.72     7067     0.38     0.38  do_push_owl
  3.39     31.09     2.62  3631585     0.00     0.00  check_pattern_light
  2.86     33.30     2.21  4146203     0.00     0.00  fastlib

In other words, we should do s.th. about the performance. Also, we
should look at the FAILs to get an impression whether this can be
improved.

I haven't done 2), because I think if anything we should fix the fact
that the order makes a difference. (I think I can also explain why this
does make a difference, in case anybody is interested -- I believe it is
a rare problem and not much worth worrying about.)

For the record, below is the patch.

Arend


Index: engine/influence.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v
retrieving revision 1.60
diff -u -r1.60 influence.c
--- engine/influence.c  10 Sep 2002 15:05:42 -0000      1.60
+++ engine/influence.c  12 Sep 2002 10:55:04 -0000
@@ -101,6 +101,7 @@
 #if EXPLICIT_LOOP_UNROLLING

 #define code1(arg_di, arg_dj, arg_i, arg_j, arg_d) \
+    do { \
       if (q->p[arg_i][arg_j] == EMPTY \
          && ((arg_di)*(i-m) + (arg_dj)*(j-n) > 0 \
              || queue_start == 1)) { \
@@ -132,7 +133,8 @@
          queue_end++; \
        } \
        q->w[arg_i][arg_j] += contribution; \
-      }
+      } \
+    } while (0)
 #endif

 static void





reply via email to

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