@@ -73,8 +73,9 @@ static std::atomic_int n_collisions = {0};
7373static std::atomic_int n_terminals = {0 };
7474
7575/* Nodes and edges of tree*/
76- std::vector<Node*> Node::mem_[MAX_CPUS];
77- std::vector<uint16_t *> Edges::mem_[MAX_CPUS][MAX_MOVES_NN >> 3 ];
76+ std::vector<std::vector<Node*>> Node::mem_;
77+ std::vector<std::vector<Node*>> Node::gc;
78+ std::vector<std::array<std::vector<uint16_t *>, (MAX_MOVES_NN >> 3 )>> Edges::mem_;
7879std::atomic_uint Node::total_nodes = {0 };
7980unsigned int Node::max_tree_nodes = 0 ;
8081unsigned int Node::max_tree_depth = 0 ;
@@ -270,12 +271,12 @@ void Node::reset_bounds(Node* n) {
270271 }
271272}
272273
273- void Node::split (Node* n, std::vector<Node*>* pn, const int S, int & T) {
274+ void Node::split (Node* n, const int S, int & T) {
274275 static int id = 0 ;
275276 Node* current = n->child ;
276277 while (current) {
277278 if (current->visits <= (unsigned )S || !current->child ) {
278- pn [id].push_back (current);
279+ Node::gc [id].push_back (current);
279280 current->set_dead ();
280281
281282 T += current->visits ;
@@ -284,7 +285,7 @@ void Node::split(Node* n, std::vector<Node*>* pn, const int S, int& T) {
284285 if (++id >= PROCESSOR::n_processors) id = 0 ;
285286 }
286287 } else {
287- split (current,pn, S,T);
288+ split (current,S,T);
288289 }
289290 current = current->next ;
290291 }
@@ -1765,31 +1766,29 @@ void SEARCHER::search_mc(bool single, unsigned int nodes_limit) {
17651766/*
17661767Traverse tree in parallel
17671768*/
1768- static std::vector<Node*> gc[MAX_CPUS+1 ];
1769-
17701769void CDECL gc_thread_proc (void * seid_) {
17711770 int * seid = (int *)seid_;
17721771 for (int proc_id = seid[0 ]; proc_id < seid[1 ]; proc_id++) {
1773- for (unsigned int i = 0 ; i < gc[proc_id].size (); i++) {
1774- Node::reclaim (gc[proc_id][i],proc_id);
1772+ for (unsigned int i = 0 ; i < Node:: gc[proc_id].size (); i++) {
1773+ Node::reclaim (Node:: gc[proc_id][i],proc_id);
17751774 }
17761775 }
17771776}
17781777void CDECL rank_reset_thread_proc (void * seid_) {
17791778 int * seid = (int *)seid_;
17801779 for (int proc_id = seid[0 ]; proc_id < seid[1 ]; proc_id++) {
1781- for (unsigned int i = 0 ; i < gc[proc_id].size (); i++) {
1782- Node::rank_children (gc[proc_id][i]);
1783- Node::reset_bounds (gc[proc_id][i]);
1780+ for (unsigned int i = 0 ; i < Node:: gc[proc_id].size (); i++) {
1781+ Node::rank_children (Node:: gc[proc_id][i]);
1782+ Node::reset_bounds (Node:: gc[proc_id][i]);
17841783 }
17851784 }
17861785}
17871786
17881787void CDECL convert_score_thread_proc (void * seid_) {
17891788 int * seid = (int *)seid_;
17901789 for (int proc_id = seid[0 ]; proc_id < seid[1 ]; proc_id++) {
1791- for (unsigned int i = 0 ; i < gc[proc_id].size (); i++) {
1792- Node::convert_score (gc[proc_id][i]);
1790+ for (unsigned int i = 0 ; i < Node:: gc[proc_id].size (); i++) {
1791+ Node::convert_score (Node:: gc[proc_id][i]);
17931792 }
17941793 }
17951794}
@@ -1803,15 +1802,15 @@ void Node::parallel_job(Node* n, PTHREAD_PROC func, bool recursive) {
18031802 for (int i = 1 ;i < PROCESSOR::n_processors;i++)
18041803 PROCESSOR::park (i);
18051804
1806- Node::split (n, gc, S, T);
1805+ Node::split (n, S, T);
18071806
18081807 int * seid = new int [2 * ncores];
18091808 std::thread* tid = new std::thread[ncores];
18101809
18111810 if (!recursive)
1812- gc[0 ].push_back (n);
1811+ Node:: gc[0 ].push_back (n);
18131812 else {
1814- gc[nprocs].push_back (n);
1813+ Node:: gc[nprocs].push_back (n);
18151814 seid[0 ] = nprocs;
18161815 seid[1 ] = nprocs + 1 ;
18171816 tid[0 ] = t_create (*func,&seid[0 ]);
@@ -1830,10 +1829,10 @@ void Node::parallel_job(Node* n, PTHREAD_PROC func, bool recursive) {
18301829 delete[] tid;
18311830
18321831 for (int i = 0 ; i < nprocs;i++) {
1833- for (unsigned int j = 0 ; j < gc[i].size (); j++) {
1834- gc[i][j]->clear_dead ();
1832+ for (unsigned int j = 0 ; j < Node:: gc[i].size (); j++) {
1833+ Node:: gc[i][j]->clear_dead ();
18351834 }
1836- gc[i].clear ();
1835+ Node:: gc[i].clear ();
18371836 }
18381837
18391838 for (int i = 1 ;i < PROCESSOR::n_processors;i++)
0 commit comments