Skip to content

Commit 6d613d9

Browse files
committed
Minimize footprint of Polyfish changes to the original SF code
1 parent 8706b1f commit 6d613d9

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

src/search.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,15 @@ Search::Worker::Worker(SharedState& sharedState,
163163
std::unique_ptr<ISearchManager> sm,
164164
size_t thread_id) :
165165
// Unpack the SharedState struct into member variables
166-
#if defined(POLYFISH)
167166
thread_idx(thread_id),
168167
manager(std::move(sm)),
169-
options(sharedState.options),
170-
threads(sharedState.threads),
171-
tt(sharedState.tt),
168+
#if defined(POLYFISH)
172169
bookMan(sharedState.bookMan),
173-
evalFiles(sharedState.evalFiles) {
174-
#else
175-
thread_idx(thread_id),
176-
manager(std::move(sm)),
170+
evalFiles(sharedState.evalFiles),
171+
#endif
177172
options(sharedState.options),
178173
threads(sharedState.threads),
179-
tt(sharedState.tt) {
180-
#endif
174+
tt(sharedState.tt){
181175
clear();
182176
}
183177

src/search.h

+11-14
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,23 @@ struct LimitsType {
127127
// This struct is used to easily forward data to the Search::Worker class.
128128
struct SharedState {
129129
#if defined(POLYFISH)
130-
SharedState(const OptionsMap& o, ThreadPool& tp, TranspositionTable& t, BookManager& bm, Eval::NNUE::EvalFiles& ef) :
131-
options(o),
132-
threads(tp),
133-
tt(t),
130+
SharedState(BookManager& bm, Eval::NNUE::EvalFiles& ef, const OptionsMap& o, ThreadPool& tp, TranspositionTable& t) :
134131
bookMan(bm),
135-
evalFiles(ef) {}
132+
evalFiles(ef),
136133
#else
137134
SharedState(const OptionsMap& o, ThreadPool& tp, TranspositionTable& t) :
135+
#endif
138136
options(o),
139137
threads(tp),
140138
tt(t) {}
141-
#endif
142139

143-
const OptionsMap& options;
144-
ThreadPool& threads;
145-
TranspositionTable& tt;
146140
#if defined(POLYFISH)
147-
BookManager& bookMan;
141+
BookManager& bookMan;
148142
Eval::NNUE::EvalFiles& evalFiles;
149143
#endif
144+
const OptionsMap& options;
145+
ThreadPool& threads;
146+
TranspositionTable& tt;
150147
};
151148

152149
class Worker;
@@ -255,13 +252,13 @@ class Worker {
255252
// The main thread has a SearchManager, the others have a NullSearchManager
256253
std::unique_ptr<ISearchManager> manager;
257254

258-
const OptionsMap& options;
259-
ThreadPool& threads;
260-
TranspositionTable& tt;
261255
#if defined(POLYFISH)
262-
BookManager& bookMan;
256+
BookManager& bookMan;
263257
Eval::NNUE::EvalFiles& evalFiles;
264258
#endif
259+
const OptionsMap& options;
260+
ThreadPool& threads;
261+
TranspositionTable& tt;
265262

266263
friend class Polyfish::ThreadPool;
267264
friend class Polyfish::UCI;

src/uci.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ UCI::UCI(int argc, char** argv) :
5757

5858
options["Threads"] << Option(1, 1, 1024, [this](const Option&) {
5959
#if defined(POLYFISH)
60-
threads.set({options, threads, tt, bookMan, evalFiles });
60+
threads.set({bookMan, evalFiles, options, threads, tt});
6161
#else
6262
threads.set({options, threads, tt});
6363
#endif
@@ -99,7 +99,7 @@ UCI::UCI(int argc, char** argv) :
9999
});
100100

101101
#if defined(POLYFISH)
102-
threads.set({options, threads, tt, bookMan, evalFiles });
102+
threads.set({bookMan, evalFiles, options, threads, tt});
103103
#else
104104
threads.set({options, threads, tt});
105105
#endif

0 commit comments

Comments
 (0)