forked from cms-patatrack/patatrack-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan
executable file
·82 lines (65 loc) · 2.77 KB
/
scan
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
#! /usr/bin/env python
import sys
import os
from multirun import *
if __name__ == "__main__":
if not 'CMSSW_BASE' in os.environ:
# FIXME print a meaningful error message
sys.exit(1)
# TODO parse arguments and options from the command line
if len(sys.argv) > 1:
config = sys.argv[1]
process = parseProcess(config)
else:
# FIXME print a meaningful error message
sys.exit(1)
# options passed to multiCmsRun
options = {
'verbose' : False,
'plumbing' : False,
'warmup' : True,
'events' : 10100,
'repeats' : 3,
'jobs' : 2, # if None, set the number of jobs to fill all available CPUs
'threads' : None, # if None, overridden by the scan
'streams' : None, # if None, overridden by the scan
'gpus_per_job' : 1,
'allow_hyperthreading': True, # this determines the number and afifnity of the CPUs used by each job
'set_cpu_affinity' : True,
'set_gpu_affinity' : True,
'logdir' : None, # relative or absolute path, or None to disable storing the logs
'keep' : [] # list of files produced by the jobs to be kept (requires logdir)
}
# options specific to scan
steps = [ 6, 8, 10, 12 ] # list, or None to make a linear scan from min_step to max_step
min_step = 1 # minimum is 1
max_step = None # None to guess based on the number of available cores (or threads) and concurrent jobs
##############################################################################
# print a system overview
info()
# save scan results to 'scan.csv'
options['data'] = open('scan.csv', 'w', 1)
options['header'] = True
# check the available cpus
cpus = get_cpu_info()
if options['allow_hyperthreading']:
count = sum(len(cpu.hardware_threads) for cpu in cpus.values())
else:
count = sum(len(cpu.physical_processors) for cpu in cpus.values())
# use the explicit list of steps, or a linear scan
if max_step is None:
max_step = count // options['jobs']
if not steps:
steps = range(min_step, max_step + 1)
# make a copy of the options to be updated during the scan
step_opt = dict(options)
for step in steps:
# update the options for each step
step_opt['threads'] = options['threads'] if options['threads'] is not None else step
step_opt['streams'] = options['streams'] if options['streams'] is not None else step
step_opt['jobs'] = options['jobs'] if options['jobs'] is not None else (count + step - 1) // step
# run
multiCmsRun(process, **step_opt)
# warm up only once
step_opt['warmup'] = False
step_opt['header'] = False