forked from FindHao/drgpu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·54 lines (46 loc) · 2.15 KB
/
main.py
File metadata and controls
executable file
·54 lines (46 loc) · 2.15 KB
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
#!/usr/bin/env python3
"""
Main entry point file to parse arguments and launch DrGPU.
"""
import argparse
import logging
from pathlib import Path
from drgpu.drgpu_launch import launch, load_report, load_config
logger = logging.getLogger(__name__)
def main():
"""
Main function to parse the arguments and launch the program.
"""
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--report-path', metavar='PATH',
help='path to the CSV main report generated by Nsight Compute (NCU).',
required=True, action='store')
parser.add_argument('-o', '--output', metavar='FILE_NAME',
help='name of the output decision tree file.', required=False,
action='store')
parser.add_argument('-s', '--source', metavar='CSV_FILE_PATH',
help='path to the CSV source mapping exported from NCU.',
required=False, action='store')
parser.add_argument('-c', '--memoryconfig', metavar='PATH',
help='absolute path to the memory config or a file name in mem_config',
required=False, action='store')
parser.add_argument('-id', '--id', metavar='ID',
help='ID of the kernel you want to analyze.', required=False,
dest='kernel_id', action='store')
parser.add_argument('-l', '--log-level', metavar='LEVEL',
help='log level (DEBUG, INFO, WARNING, ERROR, CRITICAL).', required=False,
action='store')
args = parser.parse_args()
if args.log_level:
logging.basicConfig(level=args.log_level)
else:
logging.basicConfig(level=logging.INFO)
report = load_report(Path(args.report_path),
Path(args.source) if args.source else None,
int(args.kernel_id) if args.kernel_id else None)
config = load_config(args.memoryconfig)
tree = launch(report, config, output=args.output)
logging.debug("\nSuggestions generated:")
logging.debug(tree.get_tree_suggestions_str(), end="")
if __name__ == "__main__":
main()