From d1ee42a2530c1fbf067f43c420e2b9cafeb4f9ce Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 4 Apr 2010 19:33:51 +0200 Subject: [PATCH] UCT spawn_ctx -> uct_thread_ctx --- uct/search.c | 20 ++++++++++---------- uct/search.h | 6 +++--- uct/uct.c | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/uct/search.c b/uct/search.c index 542479a..25ea2f5 100644 --- a/uct/search.c +++ b/uct/search.c @@ -81,7 +81,7 @@ static pthread_mutex_t finish_serializer = PTHREAD_MUTEX_INITIALIZER; static void * spawn_worker(void *ctx_) { - struct spawn_ctx *ctx = ctx_; + struct uct_thread_ctx *ctx = ctx_; /* Setup */ fast_srandom(ctx->seed); thread_id = ctx->tid; @@ -108,7 +108,7 @@ static void * spawn_thread_manager(void *ctx_) { /* In thread_manager, we use only some of the ctx fields. */ - struct spawn_ctx *mctx = ctx_; + struct uct_thread_ctx *mctx = ctx_; struct uct *u = mctx->u; struct tree *t = mctx->t; bool shared_tree = u->parallel_tree; @@ -128,7 +128,7 @@ spawn_thread_manager(void *ctx_) /* Spawn threads... */ for (int ti = 0; ti < u->threads; ti++) { - struct spawn_ctx *ctx = malloc2(sizeof(*ctx)); + struct uct_thread_ctx *ctx = malloc2(sizeof(*ctx)); ctx->u = u; ctx->b = mctx->b; ctx->color = mctx->color; mctx->t = ctx->t = shared_tree ? t : tree_copy(t); ctx->tid = ti; ctx->seed = fast_random(65536) + ti; @@ -147,7 +147,7 @@ spawn_thread_manager(void *ctx_) continue; } /* ...and gather its remnants. */ - struct spawn_ctx *ctx; + struct uct_thread_ctx *ctx; pthread_join(threads[finish_thread], (void **) &ctx); played_games += ctx->games; joined++; @@ -202,15 +202,15 @@ uct_search_start(struct uct *u, struct board *b, enum stone color, * spawn the searching threads. */ assert(u->threads > 0); assert(!thread_manager_running); - static struct spawn_ctx mctx; - mctx = (struct spawn_ctx) { .u = u, .b = b, .color = color, .t = t, .seed = fast_random(65536) }; + static struct uct_thread_ctx mctx; + mctx = (struct uct_thread_ctx) { .u = u, .b = b, .color = color, .t = t, .seed = fast_random(65536) }; s->ctx = &mctx; pthread_mutex_lock(&finish_mutex); pthread_create(&thread_manager, NULL, spawn_thread_manager, s->ctx); thread_manager_running = true; } -struct spawn_ctx * +struct uct_thread_ctx * uct_search_stop(void) { assert(thread_manager_running); @@ -222,7 +222,7 @@ uct_search_stop(void) pthread_mutex_unlock(&finish_mutex); /* Collect the thread manager. */ - struct spawn_ctx *pctx; + struct uct_thread_ctx *pctx; thread_manager_running = false; pthread_join(thread_manager, (void **) &pctx); return pctx; @@ -234,7 +234,7 @@ uct_search_progress(struct uct *u, struct board *b, enum stone color, struct tree *t, struct time_info *ti, struct uct_search_state *s, int i) { - struct spawn_ctx *ctx = s->ctx; + struct uct_thread_ctx *ctx = s->ctx; /* Adjust dynkomi? */ if (ctx->t->use_extra_komi && u->dynkomi->permove @@ -377,7 +377,7 @@ uct_search_check_stop(struct uct *u, struct board *b, enum stone color, struct tree *t, struct time_info *ti, struct uct_search_state *s, int i) { - struct spawn_ctx *ctx = s->ctx; + struct uct_thread_ctx *ctx = s->ctx; /* Never consider stopping if we played too few simulations. * Maybe we risk losing on time when playing in super-extreme diff --git a/uct/search.h b/uct/search.h index 630da98..0605f21 100644 --- a/uct/search.h +++ b/uct/search.h @@ -33,7 +33,7 @@ extern __thread int thread_id; extern bool thread_manager_running; /* Search thread context */ -struct spawn_ctx { +struct uct_thread_ctx { int tid; struct uct *u; struct board *b; @@ -60,13 +60,13 @@ struct uct_search_state { bool print_fullmem; struct time_stop stop; - struct spawn_ctx *ctx; + struct uct_thread_ctx *ctx; }; int uct_search_games(struct uct_search_state *s); void uct_search_start(struct uct *u, struct board *b, enum stone color, struct tree *t, struct time_info *ti, struct uct_search_state *s); -struct spawn_ctx *uct_search_stop(void); +struct uct_thread_ctx *uct_search_stop(void); void uct_search_progress(struct uct *u, struct board *b, enum stone color, struct tree *t, struct time_info *ti, struct uct_search_state *s, int i); diff --git a/uct/uct.c b/uct/uct.c index d1a6731..5ebe382 100644 --- a/uct/uct.c +++ b/uct/uct.c @@ -290,7 +290,7 @@ uct_search(struct uct *u, struct board *b, struct time_info *ti, enum stone colo break; } - struct spawn_ctx *ctx = uct_search_stop(); + struct uct_thread_ctx *ctx = uct_search_stop(); if (UDEBUGL(2)) tree_dump(t, u->dumpthres); if (UDEBUGL(2)) fprintf(stderr, "(avg score %f/%d value %f/%d)\n", @@ -334,7 +334,7 @@ uct_pondering_stop(struct uct *u) return; /* Stop the thread manager. */ - struct spawn_ctx *ctx = uct_search_stop(); + struct uct_thread_ctx *ctx = uct_search_stop(); if (UDEBUGL(1)) { if (u->pondering) fprintf(stderr, "(pondering) "); uct_progress_status(u, ctx->t, ctx->color, ctx->games); -- 2.11.4.GIT