gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] cache patch


From: Gunnar Farneback
Subject: [gnugo-devel] cache patch
Date: Sun, 07 Apr 2002 14:21:05 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

One valid reason for platform dependencies is that a given amount of
memory may suffice for different amounts of reading cache nodes, since
certain data types, including pointers, tend to be larger on 64-bit
platforms than on 32-bit ones.

Ideally, of course, the cache shouldn't make any difference so it
shouldn't matter what size it is. This is not quite true though. As
Arend pointed out in a message some time ago, the count of tactical
nodes is used in the persistent caches and this number may depend on
how recently the non-persistent cache was cleared (because it had been
filled). Actually I don't think this is very likely to have visible
effects, but it could lead to platform dependencies.

What does give visible effects is that the cache entries don't keep
track of all involved depth values. Obviously it's unreasonable to
store a large number of such values with each entry, it would simply
require too much space. What does pay off, though, is to store
depth-stackp instead of stackp in the cache entries, since this is
what we really should do (the persistent caches already do this). This
patch implements this and therebysolves an observed platform
dependency for Alpha (with Linux).

/Gunnar

Index: engine/cache.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v
retrieving revision 1.12
diff -u -r1.12 cache.c
--- engine/cache.c      25 Mar 2002 04:47:27 -0000      1.12
+++ engine/cache.c      4 Apr 2002 09:24:39 -0000
@@ -311,9 +311,11 @@
     int stackp;
     int routine;
 
-    stackp = rr_get_stackp(*current_result);
+    stackp = depth - rr_get_stackp(*current_result);
     if (stackp > 19)
       stackp = 19;
+    if (stackp < 0)
+      stackp = 0;
 
     routine = rr_get_routine(*current_result);
     gg_assert(routine >= 0 && routine < NUM_ROUTINES);
@@ -321,7 +323,7 @@
 
     if (rr_get_status(*current_result) == 2
        && ((1 << rr_get_routine(*current_result)) & exclusions) == 0
-       && rr_get_stackp(*current_result) >= stackplimit) {
+       && depth - rr_get_stackp(*current_result) >= stackplimit) {
       if (previous_result == NULL)
        node->results = current_result->next;
       else
@@ -534,7 +536,8 @@
   unsigned int search_for1;
   unsigned int search_for2;
 
-  search_for1 = rr_input_data1(routine, komaster, kom_pos, str1, stackp);
+  search_for1 = rr_input_data1(routine, komaster, kom_pos, str1,
+                              depth - stackp);
   search_for2 = rr_input_data2(str2);
 
   for (result = node->results; result != NULL; result = result->next) {
@@ -577,7 +580,8 @@
   node->results = result;
 
   /* Now, put the input data into it. This also sets status to open. */
-  rr_set_input_data2(*result, routine, komaster, kom_pos, str1, str2, stackp);
+  rr_set_input_data2(*result, routine, komaster, kom_pos, str1, str2,
+                    depth - stackp);
 
   stats.read_result_entered++;
   return result;
Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.16
diff -u -r1.16 cache.h
--- engine/cache.h      25 Mar 2002 07:39:18 -0000      1.16
+++ engine/cache.h      4 Apr 2002 09:24:39 -0000
@@ -52,7 +52,10 @@
  * kom_pos : 10 bits (allows MAX_BOARD up to 31)
  * routine :  4 bits (currently 10 different choices)
  * str1    : 10 bits
- * stackp  :  5 bits
+ * stackp  :  5 bits (actually remaining depth, depth - stackp)
+ *
+ * FIXME: Rename stackp to something like remaining_depth at some
+ *        appropriate time.
  *
  * The data2 field packs into 32 bits the following
  * fields:
@@ -86,7 +89,7 @@
 /* Set corresponding parts. */
 #define rr_input_data1(routine, komaster, kom_pos, str1, stackp) \
        (((((((((komaster) << 10) | (kom_pos)) << 4) \
-         | (routine)) << 10) | (str1)) << 5) | stackp);
+         | (routine)) << 10) | (str1)) << 5) | (stackp));
 #define rr_input_data2(str2) (str2) \
 
 /* Set input data fields and at the same time set status to open. */



reply via email to

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