diff --git a/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py b/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py index 34fe288f07..41d25903a4 100644 --- a/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py +++ b/projects/rocprofiler-compute/src/omniperf_analyze/omniperf_analyze.py @@ -38,6 +38,7 @@ import sys import copy +import random import sys import argparse import os.path @@ -170,7 +171,10 @@ def run_gui(args, runs): args.verbose, args, ) - app.run_server(debug=False, host="0.0.0.0", port=args.gui) + if(args.random_port): + app.run_server(debug=False, host="0.0.0.0", port=random.randint(1024, 49151)) + else: + app.run_server(debug=False, host="0.0.0.0", port=args.gui) else: print("Multiple runs not yet supported in GUI. Retry without --gui flag.") @@ -281,4 +285,7 @@ def analyze(args): if args.gui: run_gui(args, runs) else: + if(args.random_port): + print("ERROR: --gui flag required to enable --random-port") + sys.exit(1) run_cli(args, runs) diff --git a/projects/rocprofiler-compute/src/parser.py b/projects/rocprofiler-compute/src/parser.py index b1b4794bf2..f6557b63b5 100644 --- a/projects/rocprofiler-compute/src/parser.py +++ b/projects/rocprofiler-compute/src/parser.py @@ -487,3 +487,8 @@ def parse(my_parser): const=8050, help="\t\tActivate a GUI to interate with Omniperf metrics.\n\t\tOptionally, specify port to launch application (DEFAULT: 8050)", ) + analyze_group.add_argument( + "--random-port", + action="store_true", + help="\t\tRandomly generate a port to launch GUI application.\n\t\tRegistered Ports range inclusive (1024-49151)." + )