-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorenrnrun
executable file
·54 lines (40 loc) · 2.12 KB
/
corenrnrun
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
#!/usr/bin/python
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-p", action='store_true', help="profile using 'nvprof --profile-from-start off'", default=False)
parser.add_argument("-b", metavar='builddir', help="folder containing bin/coreneuron_exec (default buildgpu)", default="buildgpu")
parser.add_argument("-o", metavar='outdir', help='where to put output (default "1")', default="1")
parser.add_argument("-m", metavar='"metrics"', help='comma separated list (without a value: "sm_efficiency,achieved_occupancy,sm_efficiency_instance")', nargs='?', const="")
parser.add_argument("-k", metavar='"kernels"', help='| separated list (without arg then: "solve")', nargs='?', const="")
parser.add_argument("-cnargs", metavar='"required"', help="all args for coreneuron_exec (but not -mpi or --gpu)", required=True)
args = parser.parse_args()
import sys
import os
import subprocess
'''
mpirun -n 1 coreneuron_exec -mpi -d coredat -e 100 --cell_permute=2 --nwarp=10 --voltage=1000 --gpu
'''
cwd = os.getcwd()
profile = '--profile-from-start off' if args.p else ""
metrics = '"sm_efficiency,achieved_occupancy,sm_efficiency_instance"' if args.m == "" else '"%s"' % args.m
metrics = '--metrics %s' % metrics if args.m != None else ""
kernels = '"::solve:"' if args.k == "" else '"::%s:"' % args.k
kernels = '--kernels %s' % kernels if args.k != None else ""
if args.p or args.m != None or args.k != None:
profile = 'nvprof %s %s %s' % (profile, kernels, metrics)
builddir = '%s/%s' % (cwd, args.b)
corenrn = '%s/bin/coreneuron_exec' % builddir
outdatdir = '%s/%s' % (cwd, args.o)
cnargs = '-mpi %s --gpu' % args.cnargs
cmd = 'mkdir -p %s' % outdatdir
if subprocess.call(cmd , shell = True) != 0:
print "could not %s" % cmd
sys.exit(1)
pid = os.getpid()
stdoutfile = '%s/stdout%d' % (outdatdir, pid)
launch = 'mpirun -n 1 %s %s %s' % (profile, corenrn, cnargs)
launch_info = "cat %s/buildcmd ; echo '%s'" % (builddir, launch)
cmd = '( %s ; %s ; echo "" ) > %s 2>&1' % (launch_info, launch, stdoutfile)
print "\n", cmd, "\n"
subprocess.call(cmd, shell = True)
subprocess.call('grep "Solver Time" %s' % stdoutfile, shell = True);