/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
HeterogeneousCore/CUDAServices/scripts/cudaPreallocate.py
37 строк
1 KB
Shahzad Malik Muzaffar
[MISC2] py2/3 compatibility:drop use of __future__
22 ноя 2024, 20:18
22 ноя 2024, 20:18
2c224d4
Код
Авторство
О чём код?
#!/usr/bin/env python3 import re import sys import argparse def main(opts): device = [] host = [] device_re = re.compile("Device.*allocated new device block.*\((?P<bytes>\d+) bytes") host_re = re.compile("Host.*allocated new host block.*\((?P<bytes>\d+) bytes") f = open(opts.file) for line in f: m = device_re.search(line) if m: device.append(m.group("bytes")) continue m = host_re.search(line) if m: host.append(m.group("bytes")) f.close() print("process.CUDAService.allocator.devicePreallocate = cms.untracked.vuint32(%s)" % ",".join(device)) print("process.CUDAService.allocator.hostPreallocate = cms.untracked.vuint32(%s)" % ",".join(host)) if __name__ == "__main__": parser = argparse.ArgumentParser(description="""Extract CUDAService preallocation parameters from a log file. To use, run the job once with "process.CUDAService.allocator.debug = True" and direct the output to a file. Then run this script by passing the file as an argument, and copy the output of this script back to the configuration file.""") parser.add_argument("file", type=str, help="Log file to parse") opts = parser.parse_args() main(opts)