Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:44

0001 #!/usr/bin/env python3
0002 
0003 from __future__ import print_function
0004 import re
0005 import sys
0006 import argparse
0007 
0008 def main(opts):
0009     device = []
0010     host = []
0011 
0012     device_re = re.compile("Device.*allocated new device block.*\((?P<bytes>\d+) bytes")
0013     host_re = re.compile("Host.*allocated new host block.*\((?P<bytes>\d+) bytes")
0014 
0015     f = open(opts.file)
0016     for line in f:
0017         m = device_re.search(line)
0018         if m:
0019             device.append(m.group("bytes"))
0020             continue
0021         m = host_re.search(line)
0022         if m:
0023             host.append(m.group("bytes"))
0024     f.close()
0025 
0026     print("process.CUDAService.allocator.devicePreallocate = cms.untracked.vuint32(%s)" % ",".join(device))
0027     print("process.CUDAService.allocator.hostPreallocate = cms.untracked.vuint32(%s)" % ",".join(host))
0028 
0029 if __name__ == "__main__":
0030     parser = argparse.ArgumentParser(description="""Extract CUDAService preallocation parameters from a log file.
0031 
0032 To use, run the job once with "process.CUDAService.allocator.debug =
0033 True" and direct the output to a file. Then run this script by passing
0034 the file as an argument, and copy the output of this script back to
0035 the configuration file.""")
0036     parser.add_argument("file", type=str, help="Log file to parse")
0037     opts = parser.parse_args()
0038     main(opts)