From 378cc549ab442c845ac9d62cc8cef6977073fe4d Mon Sep 17 00:00:00 2001 From: Aargh Rai Date: Sat, 15 Aug 2026 13:55:35 +0530 Subject: md files --- include/engine/threads.h | 50 +++++++++++++++++++++++++++++++++++++---- include/uci/internals/command.h | 2 +- 2 files changed, 47 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/engine/threads.h b/include/engine/threads.h index 4815a4c..b5f2163 100644 --- a/include/engine/threads.h +++ b/include/engine/threads.h @@ -5,10 +5,43 @@ #include #include "bitboard.h" +#include "engine/ttable.h" #include "ipc/engine_message.h" #include "ipc/go_args.h" -struct thread_args { +enum { SPLITPOINT_STATE_FREE, SPLITPOINT_STATE_ACTIVE }; +enum { NODE_PV, NODE_CUT, NODE_ALL }; +typedef struct split_point { + atomic_int state; + atomic_int next_move_idx; + atomic_int alpha, beta; + atomic_int best_score; + atomic_int workers; + move_t best_score; + + struct split_point *parent; + int ply; + int node_type; + int confidence; + position_t position_snapshot; + moves_t moves; +} split_point_t; + +struct child_thread_args { + // signal sent by threads manager + atomic_int stop; + + // signal sent by thread + atomic_int finished; + + int id; + go_args_t *go_args; + + position_t position; + int sp_stack; + int +}; +struct root_thread_args { // signal sent by threads manager atomic_int stop; @@ -21,9 +54,14 @@ struct thread_args { engine_message_handler_t *message; }; +typedef union { + struct child_thread_args child_thread_args; + struct root_thread_args root_thread_args; +} thread_args_t; + struct threads { pthread_t *threads; - struct thread_args *args; + thread_args_t *args; size_t count; size_t capacity; @@ -31,11 +69,14 @@ struct threads { engine_messages_t *engine_messages; go_args_t *go_args; position_t *position; + + ttable_t ttable; + void* split_point_pool; }; #ifdef ENGINE_THREADS_INTERNAL void __threads_args_init( - struct thread_args* args, + thread_args_t* args, struct threads *handler, int i ); @@ -48,6 +89,7 @@ bool threads_go_loop(struct threads *handler); bool threads_all_done(struct threads *handler); void threads_cleanup(struct threads *handler); -void *engine_thread(void *args); +void *child_thread(void *args); +void *root_thread(void *args); #endif // ENGINE_THREADS_H diff --git a/include/uci/internals/command.h b/include/uci/internals/command.h index 2994b04..21df9c0 100644 --- a/include/uci/internals/command.h +++ b/include/uci/internals/command.h @@ -11,7 +11,7 @@ typedef struct { bool empty; } uci_cmd_t; -uci_cmd_t uci_cmd_init(); +void uci_cmd_init(uci_cmd_t *cmd); void uci_cmd_add(uci_cmd_t *cmd, const char *token); void uci_cmd_set_root(uci_cmd_t *cmd, const char *token); void uci_cmd_append_arg(uci_cmd_t *cmd, const char *token); -- cgit v1.2.3