gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] influence cleanup - arend_3_11.1c


From: Arend Bayer
Subject: [gnugo-devel] influence cleanup - arend_3_11.1c
Date: Wed, 30 Oct 2002 13:12:56 -0500 (EST)

The previous patch had very small performance impact on
accumulate_influence(), but this is more than made up for by the
optimzation below. (Basically, i and j were, in the inner loop, only used
to compute (i-m) and (j - n) for the cos2phi computation, so we store
this difference instead of i and j.

Arend

diff -u engine/influence.c engine/influence.c
--- engine/influence.c  30 Oct 2002 15:41:49 -0000
+++ engine/influence.c  30 Oct 2002 15:42:48 -0000
@@ -99,12 +99,14 @@
 #if EXPLICIT_LOOP_UNROLLING
 /* In addition to the parameters, this macro expects
  *  m,n = original source of influence
- *  i,j = point influence is being spread from
+ *  ii = point influence is being spread from
+ *  delta_i = I(ii) - m
+ *  delta_j = J(ii) - n
  *  current_strength combines strength and damping factor
  *  b is 1/(square of distance from m,n to i,j) ; or halved
  *    for diagonals
  *
- *  arg_i is i + arg_di ; arg_j is j + arg_dj
+ *  arg is i + arg_di ; arg_j is j + arg_dj
  *  arg_d is 1 for diagonal movement
  *
  */
@@ -112,7 +114,7 @@

 #define code1(arg_di, arg_dj, arg, arg_d) do { \
       if (q->p[arg] == EMPTY \
-         && ((arg_di)*(i-m) + (arg_dj)*(j-n) > 0 \
+         && ((arg_di)*(delta_i) + (arg_dj)*(delta_j) > 0 \
              || queue_start == 1)) { \
        float contribution; \
        float permeability = permeability_array[ii]; \
@@ -124,7 +126,7 @@
        } \
        contribution = current_strength * permeability; \
        if (queue_start != 1) { \
-         int a = (arg_di)*(i-m) + (arg_dj)*(j-n); \
+         int a = (arg_di)*(delta_i) + (arg_dj)*(delta_j); \
          contribution *= (a*a) * b; /* contribution *= cos(phi) */ \
        } \
        if (contribution <= INFLUENCE_CUTOFF) \
@@ -198,11 +200,11 @@
   /* Spread influence until the stack is empty. */
   while (queue_start < queue_end) {
     float current_strength;
-    int i, j;
+    int delta_i, delta_j;

     ii = q->queue[queue_start];
-    i = I(ii);
-    j = J(ii);
+    delta_i = I(ii) - m;
+    delta_j = J(ii) - n;
     queue_start++;
     if (permeability_array[ii] == 0.0)
       continue;
@@ -212,7 +214,7 @@
     if (queue_start == 1)
       b = 1.0;
     else
-      b = 1.0 / ((i-m)*(i-m) + (j-n)*(j-n));
+      b = 1.0 / ((delta_i)*(delta_i) + (delta_j)*(delta_j));

     current_strength = working[ii] * inv_attenuation;







reply via email to

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