My Project
ybwc.h
Go to the documentation of this file.
1
12#ifndef EDAX_YBWC_H
13#define EDAX_YBWC_H
14
15#include "util.h"
16#include "const.h"
17#include "settings.h"
18
19#include <stdbool.h>
20
21struct Search;
22struct Move;
23struct MoveList;
24struct Task;
25
29typedef struct Task {
30 volatile bool loop;
31 volatile bool run;
32 volatile bool is_helping;
33 struct Search *search;
34 struct Node *node;
35 struct Move *move;
36 Thread thread;
37 unsigned long long n_calls;
38 unsigned long long n_nodes;
39 Lock lock;
40 Condition cond;
43
48typedef struct Node {
49 volatile int bestmove;
50 volatile int bestscore;
51 volatile int alpha;
52 int beta;
53 bool pv_node;
54 volatile int n_slave;
55 volatile bool stop_point;
56 volatile bool is_waiting;
57 int depth;
58 int height;
59 struct Search *search;
61 struct Node *parent;
62 struct Move *move;
63 volatile int n_moves_done;
64 volatile int n_moves_todo;
65 volatile bool is_helping;
67 Lock lock;
68 Condition cond;
70
71/* node function declaration */
72void node_init(Node*, struct Search*, const int, const int, const int, const int, Node*);
73void node_free(Node*);
74bool node_split(Node*, struct Move*);
77void node_update(Node*, struct Move*);
78struct Move * node_first_move(Node*, struct MoveList*);
79struct Move * node_next_move(Node*);
80
81/* task function declaration */
82void* task_loop(void*);
83void* task_help(void*);
84void task_init(Task*);
85void task_free(Task*);
87void task_search(Task *task);
88
93typedef struct TaskStack {
94 SpinLock spin;
97 int n;
98 int n_idle;
100
101/* task stack function declaration */
102void task_stack_init(TaskStack*, const int);
104void task_stack_resize(TaskStack*, const int);
110
111#endif
112
Stop
Definition: const.h:70
#define SPLIT_MAX_SLAVES
Definition: settings.h:107
Definition: move.h:29
Definition: move.h:20
Definition: ybwc.h:48
volatile int n_slave
Definition: ybwc.h:54
struct Node * parent
Definition: ybwc.h:61
int beta
Definition: ybwc.h:52
volatile bool is_waiting
Definition: ybwc.h:56
bool pv_node
Definition: ybwc.h:53
volatile bool is_helping
Definition: ybwc.h:65
struct Search * search
Definition: ybwc.h:59
int height
Definition: ybwc.h:58
struct Move * move
Definition: ybwc.h:62
volatile int n_moves_done
Definition: ybwc.h:63
volatile int alpha
Definition: ybwc.h:51
struct Search * slave[SPLIT_MAX_SLAVES]
Definition: ybwc.h:60
Task help[1]
Definition: ybwc.h:66
volatile int bestscore
Definition: ybwc.h:50
Lock lock
Definition: ybwc.h:67
volatile bool stop_point
Definition: ybwc.h:55
volatile int bestmove
Definition: ybwc.h:49
Condition cond
Definition: ybwc.h:68
int depth
Definition: ybwc.h:57
volatile int n_moves_todo
Definition: ybwc.h:64
Definition: search.h:95
Definition: ybwc.h:93
Task ** stack
Definition: ybwc.h:96
int n
Definition: ybwc.h:97
SpinLock spin
Definition: ybwc.h:94
Task * task
Definition: ybwc.h:95
int n_idle
Definition: ybwc.h:98
Definition: ybwc.h:29
struct Node * node
Definition: ybwc.h:34
struct Move * move
Definition: ybwc.h:35
unsigned long long n_calls
Definition: ybwc.h:37
Condition cond
Definition: ybwc.h:40
volatile bool is_helping
Definition: ybwc.h:32
unsigned long long n_nodes
Definition: ybwc.h:38
struct Search * search
Definition: ybwc.h:33
volatile bool loop
Definition: ybwc.h:30
Thread thread
Definition: ybwc.h:36
Lock lock
Definition: ybwc.h:39
volatile bool run
Definition: ybwc.h:31
struct TaskStack * container
Definition: ybwc.h:41
Miscellaneous utilities header.
void node_update(Node *, struct Move *)
Update a node.
Definition: ybwc.c:261
Task * task_stack_get_idle_task(TaskStack *)
Return, if available, an idle task.
Definition: ybwc.c:638
void task_stack_clear(TaskStack *)
void * task_help(void *)
void task_stack_stop(TaskStack *, const Stop)
void task_stack_init(TaskStack *, const int)
Initialize the stack of tasks.
Definition: ybwc.c:560
void task_free(Task *)
Free resources used by a task.
Definition: ybwc.c:540
void node_init(Node *, struct Search *, const int, const int, const int, const int, Node *)
Initialize a node.
Definition: ybwc.c:59
void node_stop_slaves(Node *)
void node_free(Node *)
Free Resources allocated by a node.
Definition: ybwc.c:95
bool node_split(Node *, struct Move *)
Node split.
Definition: ybwc.c:167
void task_stack_put_idle_task(TaskStack *, Task *)
Put back an idle task after using it.
Definition: ybwc.c:661
struct Move * node_first_move(Node *, struct MoveList *)
Get the first move of the move list.
Definition: ybwc.c:297
void task_update(Task *)
void task_stack_resize(TaskStack *, const int)
Resize the stack of tasks.
Definition: ybwc.c:626
struct Move * node_next_move(Node *)
Get the next move of the move list.
Definition: ybwc.c:345
void task_search(Task *task)
A parallel search within a Task structure.
Definition: ybwc.c:362
void node_wait_slaves(Node *)
Wait for slaves termination.
Definition: ybwc.c:212
void task_stack_free(TaskStack *)
Free resources used by the stack of tasks.
Definition: ybwc.c:607
unsigned long long task_stack_count_nodes(TaskStack *)
void task_init(Task *)
Initialize a task.
Definition: ybwc.c:520
void * task_loop(void *)
The main loop runned by a task.
Definition: ybwc.c:453