Skip to content

Commit

Permalink
Fix unique nodes
Browse files Browse the repository at this point in the history
Pass -Ofast for more accurate benchmark
Solves #63
  • Loading branch information
ErinvanderVeen committed May 15, 2019
1 parent 73d43c4 commit 5119f12
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 0 additions & 4 deletions ai/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ parallel: oooo
paralleldebug: CFLAGS += -fopenmp -g -DPARALLEL -DDEBUG
paralleldebug: oooo

# Passing this flag will enable performance metrics
metrics: CFLAGS += -fopenmp -Ofast -DPARALLEL -DMETRICS
metrics: oooo

oooo: oooo.cpp ai state_t eval_hashmap
$(CC) $(CFLAGS) oooo.cpp ai.o ../lib/state_t.o ../lib/eval_hashmap.o -o oooo.out

Expand Down
9 changes: 7 additions & 2 deletions ai/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ static uint64_t branches_evaluated = 0;
static uint64_t levels_evaluated = 0;
static uint64_t nr_moves = 0;
static uint64_t unique_nodes = 0;
static uint64_t nodes_evaluated = 0;
#endif

static uint64_t nodes = 0;
Expand Down Expand Up @@ -148,6 +149,9 @@ double negamax(board_t board, uint64_t depth, double alpha, double beta, int8_t

// Lookup board in hash table (again)
eval = find_eval(board);
#ifdef METRICS
nodes_evaluated++;
#endif
if (eval != NULL && eval->depth >= depth) {
return eval->value;
} else if (eval == NULL) {
Expand Down Expand Up @@ -250,8 +254,9 @@ void print_ai_metrics(void) {
printf(" Branches pruned: %" PRIu64 "\n", branches - branches_evaluated);
printf(" Branch factor: %f\n", (double) branches / (double) nodes);
printf(" %% Pruned: %f\n", 100.0 * ((double) branches - (double) branches_evaluated) / branches);
printf(" Nodes evaluated: %" PRIu64 "\n", nodes);
printf(" Nodes considered: %" PRIu64 "\n", nodes);
printf(" Nodes evaluated: %" PRIu64 "\n", nodes_evaluated);
printf(" Unique nodes evaluated: %" PRIu64 "\n", unique_nodes);
printf(" %% Unique nodes : %f\n", 100 * (double) unique_nodes / (double) nodes);
printf(" %% Unique nodes : %f\n", 100 * (double) unique_nodes / (double) nodes_evaluated);
#endif
}
4 changes: 2 additions & 2 deletions benchmark/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CC = g++
CFLAGS = -Wall -Wextra -march=native -fPIC -lm -std=c++17 -lstdc++ -DMETRICS
CFLAGS = -Wall -Wextra -march=native -fPIC -lm -std=c++17 -lstdc++ -DMETRICS -Ofast

serial: benchmark

parallel: CFLAGS += -fopenmp -DPARALLEL -DMETRICS
parallel: CFLAGS += -fopenmp -DPARALLEL
parallel: benchmark

benchmark: benchmark.cpp ai state_t eval_hashmap
Expand Down

0 comments on commit 5119f12

Please sign in to comment.