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