-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoonbird.nims
109 lines (85 loc) · 2.53 KB
/
Moonbird.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
import src/version
import std/[strutils, strformat]
#!fmt: off
# Default flags
--mm:arc
--define:useMalloc
--cc:clang
--threads:on
--styleCheck:hint
var threadPoolSize = 1024
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}")
proc lto() =
--passC:"-flto"
--passL:"-flto"
if defined(windows):
--passL:"-fuse-ld=lld"
proc highPerformance() =
--panics:on
--define:danger
lto()
proc lightDebuggerInfo() =
--passC:"-fno-omit-frame-pointer -g"
proc fullDebuggerInfo() =
lightDebuggerInfo()
--debugger:native
let
projectNimFile = "src/Moonbird.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 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 tests, "Runs tests":
--define:release
fullDebuggerInfo()
setBinaryName("tests")
setCommand "c", "tests/tests.nim"
task genData, "Generates training data by playing games":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
setBinaryName("genData")
setCommand "c", "src/tuning/generateTrainingData.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 tuneEvalParams, "Optimizes eval parameters":
highPerformance()
--passC:"-march=native"
--passC:"-mtune=native"
# --define:release
setBinaryName("tuneEvalParams")
setCommand "c", "src/tuning/optimization.nim"
task runWeatherFactory, "Optimizes search parameters":
--define:release
setBinaryName("runWeatherFactory")
setCommand "c", "src/tuning/runWeatherFactory.nim"
#!fmt: on