-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNalwald.nims
146 lines (116 loc) · 3.68 KB
/
Nalwald.nims
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import src/version
import std/[strutils, strformat]
#!fmt: off
# Default flags
--mm:arc
--define:useMalloc
--cc:clang
--threads:on
--styleCheck:hint
var threadPoolSize = 128
doAssert defined(linux) or not (defined(halfCPU) or defined(almostFullCPU)), "Switches halfCPU and almostFullCPU are only supported on Linux"
if defined(halfCPU):
threadPoolSize = max(1, staticExec("nproc").parseInt div 2)
elif defined(almostFullCPU):
threadPoolSize = max(1, staticExec("nproc").parseInt - 2)
switch("define", fmt"ThreadPoolSize={threadPoolSize}")
func lto() =
--passC:"-flto"
--passL:"-flto"
if defined(windows):
--passL:"-fuse-ld=lld"
func highPerformance() =
--panics:on
--define:danger
lto()
func lightDebuggerInfo() =
--passC:"-fno-omit-frame-pointer -g"
func fullDebuggerInfo() =
lightDebuggerInfo()
--debugger:native
let
projectNimFile = "src/Nalwald.nim"
suffix = if defined(windows): ".exe" else: ""
binDir = "bin/"
proc setBinaryName(name: string) =
switch("o", binDir & name & suffix)
task debug, "debug compile":
--define:debug
--passC:"-O2"
fullDebuggerInfo()
setBinaryName(projectName() & "-debug")
setCommand "c", projectNimFile
task checks, "checks compile":
--define:release
fullDebuggerInfo()
setBinaryName(projectName() & "-checks")
setCommand "c", projectNimFile
task profile, "profile compile":
highPerformance()
fullDebuggerInfo()
setBinaryName(projectName() & "-profile")
setCommand "c", projectNimFile
task default, "default compile":
lightDebuggerInfo()
highPerformance()
setBinaryName(projectName())
setCommand "c", projectNimFile
task native, "native compile":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
setBinaryName(projectName() & "-native")
setCommand "c", projectNimFile
task modern, "BMI2 and POPCNT compile":
highPerformance()
--passC:"-mbmi2"
--passC:"-mpopcnt"
setBinaryName(projectName() & "-modern")
setCommand "c", projectNimFile
task genData, "Generates training data by playing games":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
# --define:release
setBinaryName("genData")
setCommand "c", "src/tuning/generateTrainingData.nim"
task dataFromPGNs, "Converts a number of PGN files into training data":
highPerformance()
setBinaryName("dataFromPGNs")
setCommand "c", "src/tuning/trainingDataFromPGNs.nim"
task tuneEvalParams, "Optimizes eval parameters":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
setBinaryName("tuneEvalParams")
setCommand "c", "src/tuning/optimization.nim"
task checkTuneEvalParams, "Optimizes eval parameters":
--define:release
setBinaryName("tuneEvalParams")
setCommand "c", "src/tuning/optimization.nim"
task runWeatherFactory, "Optimizes search parameters":
--define:tunableSearchParams
--define:release
setBinaryName("runWeatherFactory")
setCommand "c", "src/tuning/runWeatherFactory.nim"
task sprt, "Runs an SPRT test of the current branch against the main branch":
--define:release
setBinaryName("sprt")
setCommand "c", "src/testing/runSprtTest.nim"
task bench, "Runs a bench test of the current branch against a selected branch or commit":
--define:release
setBinaryName("bench")
setCommand "c", "src/testing/runBenchTestAgainstBranch.nim"
task tests, "Runs tests in release mode":
--define:release
switch("define", "maxNumPerftNodes=1_000_000")
setBinaryName("tests")
setCommand "c", "src/testing/tests.nim"
task testsDanger, "Runs tests in danger mode":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
switch("define", "maxNumPerftNodes=10_000_000")
setBinaryName("testsDanger")
setCommand "c", "src/testing/tests.nim"
#!fmt: on