-
Notifications
You must be signed in to change notification settings - Fork 8
/
run_tests.py
executable file
·75 lines (64 loc) · 2.62 KB
/
run_tests.py
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
#!/usr/bin/env python3
import argparse
import os
import subprocess
import sys
import hashlib
import time
parser = argparse.ArgumentParser('Run GMCORE tests.')
parser.add_argument('--slurm', help='Use SLURM job manager', action='store_true')
parser.add_argument('-q', '--queue', help='Job queue')
parser.add_argument('-n', '--np', help='Processes to use for running tests', type=int, default=2)
parser.add_argument('-p', '--ntasks-per-node', type=int, default=20)
parser.add_argument('-m', '--node-list')
parser.add_argument('-w', '--work-root', help='Where to run tests', required=True)
parser.add_argument('-c', '--cases', help='Which cases to run', nargs='+', default=[])
args = parser.parse_args()
gmcore_root = os.path.dirname(os.path.realpath(__file__))
if args.node_list:
args.node_list = os.path.abspath(args.node_list)
if not os.path.isdir(args.work_root):
os.makedirs(args.work_root)
os.chdir(args.work_root)
testbed_root = os.getcwd() + '/GMCORE-TESTBED/'
def run(cmd):
print(f'==> {cmd}')
res = subprocess.run(cmd, shell=True, check=True)
def mpiexec(exe, namelist, args):
if args.slurm:
if not args.queue:
print('[Error]: No job queue is provided!')
exit(1)
job_name = 'gmcore_' + hashlib.new('ripemd160', str(time.time()).encode()).hexdigest()[:8]
run(f'srun -p {args.queue} -n {args.np} --ntasks-per-node {args.ntasks_per_node} --mpi=pmi2 --exclusive -J {job_name} {gmcore_root}/build/{exe} {namelist}')
elif args.node_list:
run(f'mpiexec -rr -f {args.node_list} -np {args.np} {gmcore_root}/build/{exe} {namelist}')
else:
run(f'mpiexec -np {args.np} {gmcore_root}/build/{exe} {namelist}')
def run_case(exe, case):
if len(args.cases) == 0 or case in args.cases:
os.chdir(testbed_root + case)
mpiexec(exe, 'namelist', args)
if not os.path.isdir('GMCORE-TESTBED'):
run('git clone https://gitee.com/dongli85/GMCORE-TESTBED')
if len(args.cases) > 0:
for case in args.cases:
if 'swm' in case:
run_case('gmcore_swm_driver.exe', case)
elif 'adv' in case:
run_case('gmcore_adv_driver.exe', case)
else:
run_case('gmcore_driver.exe', case)
else:
run_case('gmcore_swm_driver.exe', 'swm_rh.180x90')
run_case('gmcore_swm_driver.exe', 'swm_rh.360x180')
run_case('gmcore_swm_driver.exe', 'swm_mz.180x90')
run_case('gmcore_swm_driver.exe', 'swm_mz.360x180')
run_case('gmcore_swm_driver.exe', 'swm_jz.180x90')
run_case('gmcore_swm_driver.exe', 'swm_jz.360x180')
run_case('gmcore_driver.exe', 'rh.180x90')
run_case('gmcore_driver.exe', 'rh.360x180')
run_case('gmcore_driver.exe', 'mz.180x90')
run_case('gmcore_driver.exe', 'mz.360x180')
run_case('gmcore_driver.exe', 'bw.180x90')
run_case('gmcore_driver.exe', 'bw.360x180')