Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ You can use it with any User Interface that support UCI protocol, like:
* **tests**: Engine tests source files
* config: Engine configuration file.

## Dependencies
OPENMP needs to be installed to use parallelism

As root, run:
* apt-get install libgomp1

## Build and run engine

* make -C engine/
Expand Down
4 changes: 2 additions & 2 deletions engine/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
EXEC = jupiter

CFLAGS = -c -fPIC -std=c99 -Wall -Werror
CFLAGS = -c -fPIC -std=c99 -Wall -Werror -fopenmp
DBCFLAGS = -c -g -fPIC -std=c99 -Wall -Werror -lgcov --coverage
LDFLAGS =
LDFLAGS = -fopenmp
DBLDFLAGS = -lgcov --coverage

CSOURCES = $(wildcard *.c) $(wildcard pieces/*.c)
Expand Down
8 changes: 8 additions & 0 deletions engine/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "search.h"
#include "fen.h"
#include "logging.h"
#include <omp.h>

static void (*log_func)(const char *info) = NULL;

Expand All @@ -26,6 +27,7 @@ static void generate_nodes(Node_t *node)

while(aux != NULL) {
if (aux->child != NULL) {
#pragma omp task
generate_nodes(aux->child);
} else {
get_moves(aux);
Expand All @@ -41,8 +43,14 @@ static engine_info_t engine_think(Node_t *node)

start = get_clock_ms();

omp_set_num_threads(omp_get_max_threads());

#pragma omp parallel
#pragma omp single nowait
{
generate_nodes(node);
get_best_move(node, info.mov);
}

end = get_clock_ms();
info.time = clock_diff_ms(end, start);
Expand Down
2 changes: 2 additions & 0 deletions engine/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "notation.h"
#include "board.h"
#include "logging.h"
#include <omp.h>

static int32_t get_minimax(Node_t *node)
{
Expand All @@ -29,6 +30,7 @@ static void search(Node_t *root)
if (aux->child->child == NULL) {
aux->value = get_minimax(aux);
} else {
#pragma omp task
search(aux->child);
aux->value = get_minimax(aux);
}
Expand Down