forked from jcosborn/qex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.nims
139 lines (121 loc) · 3.14 KB
/
configure.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
import osPaths
import strUtils
var params = newSeq[string](0)
template set(key,val: string) =
params.insert val
params.insert key
template `~`(key,val: untyped) =
set(astToStr(key), val)
var envs = newSeq[string](0)
let nim = paramStr(0)
NIM ~ nim
let script = paramStr(1)
#let qexdir = thisDir()
let (qexdir, _, _) = splitFile(script)
echo "Using QEXDIR ", qexdir
set "QEXDIR", qexdir
let home = getHomeDir()
when existsEnv("QMPDIR"):
const qmpdir = getEnv("QMPDIR")
else:
const qmpdir = home / "lqcd/install/qmp"
echo "Using QMPDIR ", qmpdir
set "QMPDIR", qmpdir
when existsEnv("QIODIR"):
const qiodir = getEnv("QIODIR")
else:
const qiodir = home / "lqcd/install/qio"
echo "Using QIODIR ", qiodir
set "QIODIR", qiodir
when existsEnv("QUDADIR"):
const qudadir = getEnv("QUDADIR")
else:
const qudadir = home / "lqcd/install/quda"
echo "Using QUDADIR ", qudadir
set "QUDADIR", qudadir
when existsEnv("CUDADIR"):
const cudadir = getEnv("CUDADIR")
else:
const cudadir = "/usr/local/cuda/lib64"
echo "Using CUDADIR ", cudadir
set "CUDADIR", cudadir
var machine = ""
CC ~ "mpicc"
CC_TYPE ~ "gcc"
CFLAGS_ALWAYS ~ "-Wall -std=gnu99 -march=native -fno-strict-aliasing -ldl"
CFLAGS_DEBUG ~ "-g3 -O0"
CFLAGS_SPEED ~ "-g -O3"
OMPFLAGS ~ "-fopenmp"
LD ~ ( "$CC" % params )
LDFLAGS ~ ( "$CFLAGS_ALWAYS" % params )
VERBOSITY ~ "1"
SIMD ~ ""
VLEN ~ "1"
if dirExists "/bgsys":
machine = "Blue Gene/Q"
CC ~ qexdir / "build/mpixlc2"
#CC ~ "mpixlc2"
CFLAGS_ALWAYS ~ "-qinfo=pro -qstrict=operationprecision"
CFLAGS_DEBUG ~ "-g3 -O0"
CFLAGS_SPEED ~ "-g -O3"
OMPFLAGS ~ "-qsmp=omp"
LD ~ ( "$CC" % params )
LDFLAGS ~ ( "$CFLAGS_ALWAYS" % params )
#VERBOSITY ~ "3"
SIMD ~ "QPX"
VLEN ~ "4"
envs.add "STATIC_UNROLL=1"
let uname = staticExec "uname"
if machine=="" and uname=="Darwin":
machine = "macOS"
let features = staticExec "sysctl -n machdep.cpu.features"
var simd = newSeq[string](0)
var vlen = 1
if features.contains("SSE4"):
simd.add "SSE"
vlen = 4
if features.contains("AVX"):
simd.add "AVX"
vlen = 8
if vlen>1:
SIMD ~ join(simd,",")
VLEN ~ $vlen
# cray/modules
if machine=="":
let mods = split(staticExec "module list -t 2>/dev/null", "\n")
if mods.len > 0: echo mods
if mods.contains "craype-mic-knl":
# assume cross-compiling for KNL
machine = "knl"
CC ~ "cc"
CFLAGS_ALWAYS ~ "-Wall -std=gnu99 -march=knl -fno-strict-aliasing -ldl"
LD ~ ( "$CC" % params )
LDFLAGS ~ ( "$CFLAGS_ALWAYS" % params )
SIMD ~ "SSE,AVX,AVX512"
VLEN ~ "16"
if machine=="" and fileExists "/proc/cpuinfo":
# assume compute nodes are same as build nodes
machine = "linux"
SIMD ~ "SSE,AVX"
VLEN ~ "8"
# KNL
# check on linux/mac/vesta/cooley/theta
# gcc/icc opt level
var es = ""
for e in envs:
es.add("envs.add \"" & e & "\"\n")
ENVS ~ es
proc confFile(fn: string) =
FILE ~ thisDir() / fn
var f = readFile(qexdir / fn & ".in")
f = replace(f, "$", "!DOLLAR!")
f = replace(f, "#", "!HASH!")
f = replace(f, "@@", "$")
f = f % params
f = replace(f, "!HASH!", "#")
f = replace(f, "!DOLLAR!", "$")
#echo f
writeFile(fn, f)
confFile("Makefile")
confFile("Makefile.nims")
confFile("config.nims")