-
Notifications
You must be signed in to change notification settings - Fork 14
/
benchmark
executable file
·97 lines (83 loc) · 3.47 KB
/
benchmark
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
#! /usr/bin/env python3
import sys
import os
import copy
from options import OptionParser
from multirun import *
from slot import Slot
import FWCore.ParameterSet.Config as cms
if __name__ == "__main__":
if not 'CMSSW_BASE' in os.environ:
print('Error: the CMS environment is not set up, please run "cmsenv" or "eval `scram runtime -sh`".')
sys.exit(1)
parser = OptionParser()
opts = parser.parse(sys.argv[1:])
# common options for multirun
options = {
'verbose' : opts.verbose,
'plumbing' : opts.plumbing,
'warmup' : opts.warmup,
'events' : opts.events,
'resolution' : opts.event_resolution,
'skipevents' : opts.event_skip,
'repeats' : opts.repeats,
'wait' : opts.wait,
'jobs' : opts.jobs,
'threads' : opts.threads,
'streams' : opts.streams,
'gpus_per_job' : opts.gpus_per_job,
'allow_hyperthreading': opts.allow_hyperthreading,
'set_numa_affinity' : opts.numa_affinity,
'set_cpu_affinity' : opts.cpu_affinity,
'set_gpu_affinity' : opts.gpu_affinity,
'slots' : opts.slots,
'executable' : opts.executable,
'data' : open(opts.csv, 'wt', buffering=1, encoding='utf-8') if opts.csv else None,
'header' : opts.csvheader,
'logdir' : opts.logdir if opts.logdir else None,
'tmpdir' : opts.tmpdir,
'keep' : opts.keep,
'automerge' : opts.automerge,
'autodelete' : opts.autodelete,
'autodelete_delay' : opts.autodelete_delay,
}
# print a system overview
info()
# 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())
# autodetermine either the number of jobs ot the nuber of threads per job
if options['threads'] is None and options['jobs'] is None:
sys.stderr.write('%s: error: either the number of jobs ot the nuber of threads per job must be specified\n' % sys.argv[0])
elif options['threads'] is None:
options['threads'] = count // options['jobs']
elif options['jobs'] is None:
options['jobs'] = count // options['threads']
# the number of streams defaults to the number of threads per job
if options['streams'] is None:
options['streams'] = options['threads']
process = parseProcess(opts.config)
if opts.run_io_benchmark:
# prepare a trimmed down configuration for benchmarking only reading the input data
io_process = copy.deepcopy(process)
io_process.hltGetRaw = cms.EDAnalyzer("HLTGetRaw", RawDataCollection = cms.InputTag("rawDataCollector"))
io_process.path = cms.Path(io_process.hltGetRaw)
io_process.schedule = cms.Schedule(io_process.path)
if 'PrescaleService' in io_process.__dict__:
del io_process.PrescaleService
# benchmark reading the input data
print('Benchmarking only I/O')
io_options = dict(options, logdir = None, keep = [], data = None)
multiCmsRun(io_process, **io_options)
print()
# wait the required number of seconds between the I/O benchmark and the actual measurement
if opts.wait > 0:
time.sleep(opts.wait)
print('Benchmarking %s' % opts.config)
multiCmsRun(process, **options)
# close the CSV file
if options['data']:
options['data'].close()