CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cudaPreallocate.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 import re
5 import sys
6 import argparse
7 
8 def main(opts):
9  device = []
10  host = []
11 
12  device_re = re.compile("Device.*allocated new device block.*\((?P<bytes>\d+) bytes")
13  host_re = re.compile("Host.*allocated new host block.*\((?P<bytes>\d+) bytes")
14 
15  f = open(opts.file)
16  for line in f:
17  m = device_re.search(line)
18  if m:
19  device.append(m.group("bytes"))
20  continue
21  m = host_re.search(line)
22  if m:
23  host.append(m.group("bytes"))
24  f.close()
25 
26  print("process.CUDAService.allocator.devicePreallocate = cms.untracked.vuint32(%s)" % ",".join(device))
27  print("process.CUDAService.allocator.hostPreallocate = cms.untracked.vuint32(%s)" % ",".join(host))
28 
29 if __name__ == "__main__":
30  parser = argparse.ArgumentParser(description="""Extract CUDAService preallocation parameters from a log file.
31 
32 To use, run the job once with "process.CUDAService.allocator.debug =
33 True" and direct the output to a file. Then run this script by passing
34 the file as an argument, and copy the output of this script back to
35 the configuration file.""")
36  parser.add_argument("file", type=str, help="Log file to parse")
37  opts = parser.parse_args()
38  main(opts)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
Definition: main.py:1