Fix stupid issues with create() (kill me I'm an idiot)
This commit is contained in:
parent
5b3c244206
commit
53406cb94f
|
@ -4,4 +4,4 @@
|
||||||
--passL:"-flto -lmimalloc"
|
--passL:"-flto -lmimalloc"
|
||||||
--passC:"-flto -march=native -mtune=native"
|
--passC:"-flto -march=native -mtune=native"
|
||||||
-d:useMalloc
|
-d:useMalloc
|
||||||
--mm:atomicArc
|
--mm:arc
|
|
@ -145,9 +145,9 @@ proc newSearchManager*(position: Position, positions: seq[Position], transpositi
|
||||||
stopFlag: ptr Atomic[bool]
|
stopFlag: ptr Atomic[bool]
|
||||||
ponderFlag: ptr Atomic[bool]
|
ponderFlag: ptr Atomic[bool]
|
||||||
if mainWorker:
|
if mainWorker:
|
||||||
searchFlag = create(Atomic[bool], sizeof(Atomic[bool]))
|
searchFlag = create(Atomic[bool])
|
||||||
stopFlag = create(Atomic[bool], sizeof(Atomic[bool]))
|
stopFlag = create(Atomic[bool])
|
||||||
ponderFlag = create(Atomic[bool], sizeof(Atomic[bool]))
|
ponderFlag = create(Atomic[bool])
|
||||||
# If we're not the main worker, we expect the shared atomic metadata to be filled in by the
|
# If we're not the main worker, we expect the shared atomic metadata to be filled in by the
|
||||||
# main worker
|
# main worker
|
||||||
result = SearchManager(board: newChessboard(), transpositionTable: transpositions, stop: stopFlag,
|
result = SearchManager(board: newChessboard(), transpositionTable: transpositions, stop: stopFlag,
|
||||||
|
@ -788,8 +788,8 @@ proc search*(self: var SearchManager, timeRemaining, increment: int64, maxDepth:
|
||||||
for i in 0..<numWorkers - 1:
|
for i in 0..<numWorkers - 1:
|
||||||
# Copy the history and killers table, as those are meant to be thread-local
|
# Copy the history and killers table, as those are meant to be thread-local
|
||||||
var
|
var
|
||||||
history = create(HistoryTable, sizeof(HistoryTable))
|
history = create(HistoryTable)
|
||||||
killers = create(KillersTable, sizeof(KillersTable))
|
killers = create(KillersTable)
|
||||||
# Copy in the data
|
# Copy in the data
|
||||||
for color in PieceColor.White..PieceColor.Black:
|
for color in PieceColor.White..PieceColor.Black:
|
||||||
for i in Square(0)..Square(63):
|
for i in Square(0)..Square(63):
|
||||||
|
@ -801,7 +801,7 @@ proc search*(self: var SearchManager, timeRemaining, increment: int64, maxDepth:
|
||||||
# Create a new search manager to send off to a worker thread. We store it
|
# Create a new search manager to send off to a worker thread. We store it
|
||||||
# on the heap because we need to access its state from elsewhere for collecting
|
# on the heap because we need to access its state from elsewhere for collecting
|
||||||
# statistics
|
# statistics
|
||||||
self.children.add(create(SearchManager, sizeof(SearchManager)))
|
self.children.add(create(SearchManager))
|
||||||
self.children[i][] = newSearchManager(self.board.position, self.board.positions, self.transpositionTable, history, killers, false)
|
self.children[i][] = newSearchManager(self.board.position, self.board.positions, self.transpositionTable, history, killers, false)
|
||||||
# Fill in our shared atomic metadata
|
# Fill in our shared atomic metadata
|
||||||
self.children[i].stop = self.stop
|
self.children[i].stop = self.stop
|
||||||
|
@ -816,8 +816,7 @@ proc search*(self: var SearchManager, timeRemaining, increment: int64, maxDepth:
|
||||||
# necessary, but it's good practice and will catch bugs in our
|
# necessary, but it's good practice and will catch bugs in our
|
||||||
# "atomic stop" system
|
# "atomic stop" system
|
||||||
for i in 0..<numWorkers - 1:
|
for i in 0..<numWorkers - 1:
|
||||||
if workers[i][].running:
|
joinThread(workers[i][])
|
||||||
joinThread(workers[i][])
|
|
||||||
# If we set the atomics any earlier than this, our
|
# If we set the atomics any earlier than this, our
|
||||||
# search threads would never stop!
|
# search threads would never stop!
|
||||||
self.searching[].store(false)
|
self.searching[].store(false)
|
||||||
|
|
|
@ -355,11 +355,11 @@ proc startUCISession* =
|
||||||
# God forbid we try to use atomic ARC like it was intended. Raw pointers
|
# God forbid we try to use atomic ARC like it was intended. Raw pointers
|
||||||
# it is then... sigh
|
# it is then... sigh
|
||||||
var
|
var
|
||||||
transpositionTable = create(TTable, sizeof(TTable))
|
transpositionTable = create(TTable)
|
||||||
historyTable = create(HistoryTable, sizeof(HistoryTable))
|
historyTable = create(HistoryTable)
|
||||||
killerMoves = create(KillersTable, sizeof(KillersTable))
|
killerMoves = create(KillersTable)
|
||||||
transpositionTable[] = newTranspositionTable(session.hashTableSize * 1024 * 1024)
|
transpositionTable[] = newTranspositionTable(session.hashTableSize * 1024 * 1024)
|
||||||
session.searchState = create(SearchManager, sizeof(SearchManager))
|
session.searchState = create(SearchManager)
|
||||||
session.searchState[] = newSearchManager(session.position, session.history, transpositionTable, historyTable, killerMoves)
|
session.searchState[] = newSearchManager(session.position, session.history, transpositionTable, historyTable, killerMoves)
|
||||||
# This is only ever written to from the main thread and read from
|
# This is only ever written to from the main thread and read from
|
||||||
# the worker starting the search, so it doesn't need to be wrapped
|
# the worker starting the search, so it doesn't need to be wrapped
|
||||||
|
|
Loading…
Reference in New Issue