-
Notifications
You must be signed in to change notification settings - Fork 73
/
batch.py
46 lines (40 loc) · 1.75 KB
/
batch.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
import subprocess
import os
from os import listdir
from os.path import isfile, join
import argparse
parser = argparse.ArgumentParser(description='Batch proccess IPC sims.')
parser.add_argument(
"--offline", help="run IPC without the viewer", action='store_true')
args = parser.parse_args()
inputFolderPath = os.path.realpath('.') + '/input/'
# on Mac:
# progPath = os.path.realpath('.') + '/build/Release/IPC_bin'
# on Minchen's Mac:
# progPath = '/Users/mincli/Library/Developer/Xcode/DerivedData/IPC-cegibpdumtrmuqbjruacrqwltitb/Build/Products/Release/IPC'
# on Ubuntu:
progPath = os.path.realpath('.') + '/build/IPC_bin'
# progPath = os.path.realpath('.') + '/src/Projects/DistortionMin/DistortionMin'
# envSetStr = 'export LD_LIBRARY_PATH=/usr/local/lib\n'
# for Ubuntu or Mac when CHOLMOD is compiled with MKL LAPACK and BLAS
NTSetStr0 = 'export MKL_NUM_THREADS='
# for Ubuntu when CHOLMOD is compiled with libopenblas
NTSetStr1 = 'export OMP_NUM_THREADS='
# for Mac when CHOLMOD is compiled with default LAPACK and BLAS
NTSetStr2 = 'export VECLIB_MAXIMUM_THREADS='
for numOfThreads in ['1', '8', '12']:
inputFolderPath = os.path.realpath('.') + '/input/' + numOfThreads + '/'
if(not os.path.isdir(inputFolderPath)):
continue
onlyfiles = [
f for f in listdir(inputFolderPath) if isfile(join(inputFolderPath, f))
]
for inputModelNameI in onlyfiles:
runCommand = NTSetStr0 + numOfThreads + '\n'
runCommand += NTSetStr1 + numOfThreads + '\n'
runCommand += NTSetStr2 + numOfThreads + '\n'
runCommand += "{} {} {} t{}".format(
progPath, '100' if args.offline else '10',
inputFolderPath + inputModelNameI, numOfThreads)
if subprocess.call([runCommand], shell=True):
continue