Skip to content

Commit

Permalink
Improve formatting when displaying rocprof command. (#476)
Browse files Browse the repository at this point in the history
* Improve formatting when displaying rocprof command.

Signed-off-by: xuchen-amd <[email protected]>

* Fix python formatting.

Signed-off-by: xuchen-amd <[email protected]>

* Strip unwanted characters (rocprofv1 specific) from rocprof commands.

Signed-off-by: xuchen-amd <[email protected]>

* Strip unwanted characters (rocprofv1 specific) from rocprof commands.

Signed-off-by: xuchen-amd <[email protected]>

* Save the unmodified arguments for rocprof for debug message display.

Signed-off-by: xuchen-amd <[email protected]>

---------

Signed-off-by: xuchen-amd <[email protected]>
  • Loading branch information
xuchen-amd authored Dec 18, 2024
1 parent b2ee53f commit 6be1a17
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/rocprof_compute_profile/profiler_rocprof_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import os

from rocprof_compute_profile.profiler_base import RocProfCompute_Base
from utils.utils import console_log, demarcate, replace_timestamps
from utils.utils import console_log, demarcate, replace_timestamps, store_app_cmd


class rocprof_v1_profiler(RocProfCompute_Base):
Expand All @@ -50,6 +50,16 @@ def get_profiler_options(self, fname):
# v1 does require quotes on app cmd
'"' + app_cmd + '"',
]
# store original args for debug message
store_app_cmd(
[
"--timestamp",
"on",
"-o",
self.get_args().path + "/" + fbase + ".csv",
app_cmd,
]
)
return args

# -----------------------
Expand Down
4 changes: 3 additions & 1 deletion src/rocprof_compute_profile/profiler_rocprof_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import shlex

from rocprof_compute_profile.profiler_base import RocProfCompute_Base
from utils.utils import console_log, demarcate, replace_timestamps
from utils.utils import console_log, demarcate, replace_timestamps, store_app_cmd


class rocprof_v2_profiler(RocProfCompute_Base):
Expand All @@ -47,6 +47,8 @@ def get_profiler_options(self, fname):
self.get_args().path + "/" + "out",
]
args.extend(app_cmd)
# store args for debug message
store_app_cmd(args)
return args

# -----------------------
Expand Down
11 changes: 10 additions & 1 deletion src/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import config

rocprof_cmd = ""
rocprof_args = ""


def demarcate(function):
Expand Down Expand Up @@ -186,8 +187,16 @@ def detect_rocprof():
return rocprof_cmd # TODO: Do we still need to return this? It's not being used in the function call


def store_app_cmd(args):
global rocprof_args
rocprof_args = args


def capture_subprocess_output(subprocess_args, new_env=None, profileMode=False):
console_debug("subprocess", subprocess_args)
global rocprof_args
# Format command for debug messages, formatting for rocprofv1 and rocprofv2
command = " ".join(rocprof_args)
console_debug("subprocess", "Running: " + command)
# Start subprocess
# bufsize = 1 means output is line buffered
# universal_newlines = True is required for line buffering
Expand Down

0 comments on commit 6be1a17

Please sign in to comment.