gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] caching patch


From: Gunnar Farneback
Subject: [gnugo-devel] caching patch
Date: Fri, 22 Feb 2002 17:27:19 +0100
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)

Currently the TRACE_READ_RESULT compile option (defined at the top of
cache.h) is broken. Fixed by this patch.

- caching code revised to once more work with TRACE_READ_RESULT enabled

/Gunnar

Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.11
diff -u -r1.11 cache.h
--- engine/cache.h      9 Feb 2002 16:11:29 -0000       1.11
+++ engine/cache.h      22 Feb 2002 16:19:51 -0000
@@ -189,7 +189,15 @@
       gprintf("%o%s %1m %d %d %1m (cached) ", read_function_name, \
              q, stackp, \
              rr_get_result(rr), \
-             rr_get_result_move(rr)); \
+             rr_get_move(rr)); \
+      dump_stack();
+
+#define TRACE_CACHED_RESULT2(rr) \
+      gprintf("%o%s %1m %1m %d %d %d %1m (cached) ", read_function_name, \
+             q1, q2, stackp, \
+             rr_get_result1(rr), \
+             rr_get_result2(rr), \
+             rr_get_move(rr)); \
       dump_stack();
 
 #define SETUP_TRACE_INFO(name, str) \
@@ -204,6 +212,7 @@
 #else
 
 #define TRACE_CACHED_RESULT(rr)
+#define TRACE_CACHED_RESULT2(rr)
 
 #define SETUP_TRACE_INFO(name, str) \
   const char *read_function_name = name; \
@@ -283,6 +292,15 @@
     return; \
   } while (0)
 
+#define READ_RETURN_CONN(read_result, point, move, value) \
+  do { \
+    if ((value) != 0 && (point) != 0) *(point) = (move); \
+    if (read_result) { \
+      rr_set_result_move(*(read_result), (value), (move)); \
+    } \
+    return (value); \
+  } while (0)
+
 #else
 
 #define READ_RETURN0(read_result) \
@@ -309,17 +327,29 @@
   
 #define READ_RETURN_SEMEAI(read_result, point, move, value_a, value_b) \
   do { \
-    if ((value) != 0 && (point) != 0) *(point) = (move); \
+    if ((value_a) != 0 && (point) != 0) *(point) = (move); \
     if (read_result) { \
       rr_set_result_move2(*(read_result), (value_a), (value_b), (move)); \
     } \
-    gprintf("%o%s %1m %d %d %d %d ", read_function_name, q, stackp, \
+    gprintf("%o%s %1m %1m %d %d %d %d ", read_function_name, q1, q2, stackp, \
            (value_a), (value_b), (move)); \
     dump_stack(); \
+    return; \
+  } while (0)
+
+#define READ_RETURN_CONN(read_result, point, move, value) \
+  do { \
+    if ((value) != 0 && (point) != 0) *(point) = (move); \
+    if (read_result) { \
+      rr_set_result_move(*(read_result), (value), (move)); \
+    } \
+    gprintf("%o%s %1m %1m %d %d %d ", read_function_name, q1, q2, stackp, \
+           (value), (move)); \
+    dump_stack(); \
     return (value); \
   } while (0)
 
- #endif
+#endif
 
 /* ================================================================ */
 /* Routine numbers. */
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.63
diff -u -r1.63 owl.c
--- engine/owl.c        22 Feb 2002 16:15:20 -0000      1.63
+++ engine/owl.c        22 Feb 2002 16:19:52 -0000
@@ -383,7 +383,7 @@
     found_read_result = get_read_result2(SEMEAI, EMPTY, 0,
                                        &apos, &bpos, &read_result);
     if (found_read_result) {
-      TRACE_CACHED_RESULT(*read_result);
+      TRACE_CACHED_RESULT2(*read_result);
       if (rr_get_result1(*read_result) != 0) {
        if (move)
          *move = rr_get_move(*read_result);
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.24
diff -u -r1.24 readconnect.c
--- engine/readconnect.c        21 Feb 2002 01:24:36 -0000      1.24
+++ engine/readconnect.c        22 Feb 2002 16:19:53 -0000
@@ -1748,7 +1748,7 @@
     found_read_result = get_read_result2(CONNECT, komaster, kom_pos, 
                                         &str1, &str2, &read_result);
     if (found_read_result) {
-      TRACE_CACHED_RESULT(*read_result);
+      TRACE_CACHED_RESULT2(*read_result);
       if (rr_get_result(*read_result) != 0)
        if (move)
          *move = rr_get_move(*read_result);
@@ -1761,7 +1761,7 @@
   
   if (trivial_connection(str1, str2, &xpos) == WIN) {
     SGFTRACE2(xpos, WIN, "trivial connection");
-    READ_RETURN(read_result, move, xpos, WIN);
+    READ_RETURN_CONN(read_result, move, xpos, WIN);
   }
   
   num_moves = find_connection_moves(str1, str2, color, moves, &distance);
@@ -1783,7 +1783,7 @@
        popgo();
        if (acode == 0) {
          SGFTRACE2(xpos, WIN, "connection effective");
-         READ_RETURN(read_result, move, xpos, WIN);
+         READ_RETURN_CONN(read_result, move, xpos, WIN);
        }
        /* if the move works with ko we save it, then look for something
         * better.
@@ -1804,16 +1804,16 @@
 
   if (num_moves == 0 && distance < 1.0) {
     SGFTRACE2(NO_MOVE, WIN, "no move, probably connected");
-    READ_RETURN(read_result, move, NO_MOVE, WIN);
+    READ_RETURN_CONN(read_result, move, NO_MOVE, WIN);
   }
   
   if (savecode != 0) {
     SGFTRACE2(savemove, savecode, "saved move");
-    READ_RETURN(read_result, move, savemove, savecode);
+    READ_RETURN_CONN(read_result, move, savemove, savecode);
   }
 
   SGFTRACE2(0, 0, NULL);
-  READ_RETURN0(read_result);
+  READ_RETURN_CONN(read_result, move, NO_MOVE, 0);
 }
 
 
@@ -1882,7 +1882,7 @@
     found_read_result = get_read_result2(DISCONNECT, komaster, kom_pos, 
                                         &str1, &str2, &read_result);
     if (found_read_result) {
-      TRACE_CACHED_RESULT(*read_result);
+      TRACE_CACHED_RESULT2(*read_result);
       if (rr_get_result(*read_result) != 0)
        if (move)
          *move = rr_get_move(*read_result);
@@ -1895,11 +1895,11 @@
   
   if (ladder_capture(str1, &xpos) == WIN) {
     SGFTRACE2(xpos, WIN, "first string capturable");
-    READ_RETURN(read_result, move, xpos, WIN);
+    READ_RETURN_CONN(read_result, move, xpos, WIN);
   }
   if (ladder_capture(str2, &xpos) == WIN) {
     SGFTRACE2(xpos, WIN, "second string capturable");
-    READ_RETURN(read_result, move, xpos, WIN);
+    READ_RETURN_CONN(read_result, move, xpos, WIN);
   }
 
   num_moves = find_connection_moves(str1, str2, other, moves, &distance);
@@ -1920,7 +1920,7 @@
        popgo();
        if (dcode == 0) {
          SGFTRACE2(xpos, WIN, "disconnection effective");
-         READ_RETURN(read_result, move, xpos, WIN);
+         READ_RETURN_CONN(read_result, move, xpos, WIN);
        }
        /* if the move works with ko we save it, then look for something
         * better.
@@ -1944,16 +1944,16 @@
       && (has_passed
          || !recursive_connect2(str1, str2, NULL, komaster, kom_pos, 1))) {
     SGFTRACE2(NO_MOVE, WIN, "no move, probably disconnected");
-    READ_RETURN(read_result, move, NO_MOVE, WIN);
+    READ_RETURN_CONN(read_result, move, NO_MOVE, WIN);
   }
   
   if (savecode != 0) {
     SGFTRACE2(savemove, savecode, "saved move");
-    READ_RETURN(read_result, move, savemove, savecode);
+    READ_RETURN_CONN(read_result, move, savemove, savecode);
   }
 
   SGFTRACE2(0, 0, NULL);
-  READ_RETURN0(read_result);
+  READ_RETURN_CONN(read_result, move, NO_MOVE, 0);
 }
 
 



reply via email to

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