Skip to content

Commit 6123ca4

Browse files
committed
dcnn engine: added "threads" param
set number of threads for dcnn evaluation
1 parent 69e2b2e commit 6123ca4

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

dcnn/dcnn_engine.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,45 @@ dcnn_best_moves(engine_t *e, board_t *b, time_info_t *ti, enum stone color,
3939
get_dcnn_best_moves(b, r, best_c, best_r, nbest);
4040
}
4141

42+
#define option_error engine_setoption_error
43+
44+
static bool
45+
dcnn_engine_setoption(engine_t *e, board_t *b, const char *optname, char *optval,
46+
char **err, bool setup, bool *reset)
47+
{
48+
static_strbuf(ebuf, 256);
49+
50+
if (!strcasecmp(optname, "threads") && optval) {
51+
/* Set number of threads for dcnn evaluation */
52+
dcnn_set_threads(atoi(optval));
53+
}
54+
else
55+
option_error("dcnn: Invalid engine argument %s or missing value\n", optname);
56+
57+
return true;
58+
}
59+
4260
void
4361
dcnn_engine_init(engine_t *e, board_t *b)
4462
{
63+
e->name = (char*)"DCNN";
64+
e->comment = (char*)"I just select dcnn's best move.";
65+
e->genmove = dcnn_genmove;
66+
e->setoption = dcnn_engine_setoption;
67+
e->best_moves = dcnn_best_moves;
68+
69+
/* Process engine options. */
70+
char *err;
71+
options_t *options = &e->options;
72+
for (int i = 0; i < options->n; i++)
73+
if (!engine_setoption(e, b, &options->o[i], &err, true, NULL))
74+
die("%s", err);
75+
4576
dcnn_init(b);
4677
if (!caffe_ready()) {
4778
fprintf(stderr, "Couldn't initialize dcnn, aborting.\n");
4879
abort();
4980
}
5081

51-
e->name = (char*)"DCNN";
52-
e->comment = (char*)"I just select dcnn's best move.";
53-
e->genmove = dcnn_genmove;
54-
e->best_moves = dcnn_best_moves;
5582
}
5683

0 commit comments

Comments
 (0)