-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorenrnbuild
executable file
·116 lines (93 loc) · 4.61 KB
/
corenrnbuild
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
#!/usr/bin/python
#the prerequisite for the -bluewaters arg is
'''
module swap PrgEnv-cray PrgEnv-pgi
module load cmake/3.1.3
module load cudatoolkit
module load craype-accel-nvidia35
#for profiling
module unload darshan
module load perftools-base
module load perftools-lite-gpu
'''
pgdir='/gpfs/bbp.cscs.ch/apps/viz/tools/pgi/16.5/linux86-64/2016'
pgdir='/opt/pgi/linux86-64/16.9'
pgdir='/opt/pgi/linux86-64/2016'
pgdir2 = pgdir
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-m", metavar='moddir', help='folder containing modfiles (relative to cwd unless begins with /) (default ".")', default='.')
parser.add_argument("-b", metavar='builddir', help='will contain bin/coreneuron_exec (relative to cwd unless begins with /) (default "buildgpu")', default='buildgpu')
parser.add_argument("-s", metavar='srcdir', help='top level source folder (default "$HOME/bbgpu/coreneuron")', default='$HOME/bbgpu/coreneuron')
parser.add_argument("-i", metavar='dir', help='install dir for mod2c(default "$HOME/bbgpu/install_viz")', default='$HOME/bbgpu/install_viz')
parser.add_argument("-aos", action='store_true', help='AoS layout (otherwise, SoA)', default=False)
parser.add_argument("-nopg", action='store_true', help='PG compiler not available', default=False)
parser.add_argument("-cflags", metavar='cflags', help='extra space separated flags without the -, e.g. DNRN_PRCELLSTATE=1', default=None)
parser.add_argument("-ieee", action='store_true', help='consistent with IEEE floating point', default=False)
parser.add_argument("-debug", action='store_true', help='nothing optimized out', default=False)
parser.add_argument("-bluewaters", action='store_true', help='Cray build on NCSA Blue Waters', default=False)
args = parser.parse_args()
import sys
import os
import subprocess
'''
original example
cmake .. -DADDITIONAL_MECHPATH=/gpfs/bbp.cscs.ch/home/hines/models/nrntraub/modcore
-DCMAKE_INSTALL_PREFIX=/gpfs/bbp.cscs.ch/home/hines/bbgpu/install_viz
-DCMAKE_C_FLAGS:STRING="-I/gpfs/bbp.cscs.ch/apps/viz/tools/pgi/15.10/linux86-64/2015/include -acc -Minfo=acc -Minline=size:200,levels:10
-O3 -DSWAP_ENDIAN_DISABLE_ASM -DLAYOUT=0 -DDISABLE_HOC_EXP -DADDITIONAL_MECHS"
-DCMAKE_CXX_FLAGS:STRING="-I/gpfs/bbp.cscs.ch/apps/viz/tools/pgi/15.10/linux86-64/2015/include -acc -Minfo=acc -Minline=size:200,levels:10
-O3 -DSWAP_ENDIAN_DISABLE_ASM -DLAYOUT=0 -DDISABLE_HOC_EXP -DADDITIONAL_MECHS"
-DCOMPILE_LIBRARY_TYPE=STATIC
-DCUDA_HOST_COMPILER=`which gcc` -DCUDA_PROPAGATE_HOST_FLAGS=OFF -DENABLE_SELECTIVE_GPU_PROFILING=ON
'''
cwd = os.getcwd()
if args.bluewaters:
pgdir='/opt/pgi/16.3.0/linux86-64/16.3'
pgdir2='/opt/pgi/15.7.0/linux86-64/15.7'
cmakedebug = '-DCMAKE_BUILD_TYPE=DEBUG' if args.debug else ''
corenrndir = args.s
builddir = '%s/%s' % (cwd, args.b) if args.b[0:1] != "/" else args.b
moddir = '%s/%s' % (cwd, args.m) if args.m[0:1] != "/" else args.m
#prepend '-' and replace all ' ' with ' -'
xtflags = ('-' + ' -'.join(args.cflags.split())) if args.cflags else ''
cmd = 'mkdir -p %s' % builddir
if subprocess.call(cmd , shell = True) != 0:
print "could not %s" % cmd
sys.exit(1)
ieee = '-Mnofma -Kieee -ta=tesla:nofma,noflushz' if args.ieee else ""
mc = '-ta=tesla:cuda7.5'
installdir = args.i
pgflags = '-I%s/include -acc %s -Minfo=acc -Minline=size:200,levels:10 %s' % (pgdir2,mc,ieee)
pgflags2 = '-DSWAP_ENDIAN_DISABLE_ASM -DDISABLE_HOC_EXP -DADDITIONAL_MECHS'
profile = '-DCUDA_HOST_COMPILER=`which gcc` -DCUDA_PROPAGATE_HOST_FLAGS=OFF -DENABLE_SELECTIVE_GPU_PROFILING=OFF'
extra1 = '-DCOMPILE_LIBRARY_TYPE=STATIC -DDISABLE_NRN_TIMEOUT=ON'
expCC=''
expCXX=''
enable_openacc=''
if args.nopg:
pgflags = ''
profile = '-DENABLE_SELECTIVE_GPU_PROFILING=OFF'
else:
expCC='export CC=%s/bin/pgcc' % pgdir
expCXX='export CXX=%s/bin/pgc++' % pgdir
enable_openacc='-DENABLE_OPENACC=ON'
if args.bluewaters:
expCC='export CC=cc'
expCXX='export CXX=CC'
pgflags = ' %s -I%s/include' % (pgflags, pgdir2)
layout='-DLAYOUT=1' if args.aos else '-DLAYOUT=0'
cflags = '-DCMAKE_C_FLAGS:STRING="-DCORENEURON_BUILD=1 %s %s %s %s"' % (pgflags, pgflags2, layout, xtflags)
cxxflags = '-DCMAKE_CXX_FLAGS:STRING="%s %s %s %s"' % (pgflags, pgflags2, layout, xtflags)
addmechpath = '-DADDITIONAL_MECHPATH=' + moddir
cmakeinstall = '-DCMAKE_INSTALL_PREFIX=' + installdir
cmake = 'cmake %s %s %s %s %s %s %s %s %s' % (enable_openacc, corenrndir, cmakedebug, cmakeinstall, addmechpath, cflags, cxxflags, extra1, profile)
build = '''( cd %s
%s
%s
%s ; make formatbuild ; make -j 6 VERBOSE=1)''' % (builddir, expCC, expCXX, cmake)
print build
f = open(builddir + "/buildcmd", "w")
f.write(build + '\n\n')
f.close
subprocess.call(build, shell = True)