Integrated support for using rocscope with omniperf for top10 (--i-feel-lucky)

Signed-off-by: coleramos425 <colramos@amd.com>
This commit is contained in:
Keith Lowery
2022-12-07 20:19:22 +00:00
committed by coleramos425
parent 4c6a64f4e5
commit eadd35e5c6
22 changed files with 5487 additions and 66 deletions
+53 -62
View File
@@ -80,6 +80,8 @@ def get_soc():
target = "mi100"
elif mspec.GPU == "gfx90a":
target = "mi200"
elif mspec.GPU == "gfx900":
target = "vega10"
else:
print("\nInvalid SoC")
sys.exit(0)
@@ -328,6 +330,9 @@ def omniperf_profile(args):
workload_dir = args.path + "/" + args.name + "/" + args.target
perfmon_dir = str(OMNIPERF_HOME) + "/perfmon_pub"
# Perfmon filtering
perfmon_filter(workload_dir, perfmon_dir, args)
if not args.lucky == None and args.lucky == True:
print("You're feeling lucky - only profiling top N kernels")
#look for whether workload_dir exists - create if not
@@ -337,6 +342,51 @@ def omniperf_profile(args):
print("Unable to create workload directory: ", workload_dir)
print(e)
sys.exit(1)
result = subprocess.run(["which", "rocscope"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
if result.returncode == 0:
rs_cmd = [result.stdout.decode('ascii').strip(),
"top10",
"-p", args.path,
"-n", args.name,
"--", args.remaining]
print(rs_cmd)
result = subprocess.run(rs_cmd) #, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0:
print(result.stderr.decode('ascii'))
else:
print("rocscope must be in the PATH")
sys.exit(1)
else:
for fname in glob.glob(workload_dir + "/perfmon/*.txt"):
# Kernel filtering (in-place replacement)
if not args.kernel == None:
subprocess.run(
[
"sed",
"-i",
"-r",
"s%^(kernel:).*%" + "kernel: " + ",".join(args.kernel) + "%g",
fname,
]
)
# Dispatch filtering (inplace replacement)
if not args.dispatch == None:
subprocess.run(
[
"sed",
"-i",
"-r",
"s%^(range:).*%" + "range: " + " ".join(args.dispatch) + "%g",
fname,
]
)
run_prof(fname, workload_dir, perfmon_dir, args.remaining, args.verbose)
# run again with timestamps
subprocess.run(
[
rocprof_cmd,
@@ -349,69 +399,9 @@ def omniperf_profile(args):
'"' + args.remaining + '"',
]
)
df_stamps = pd.read_csv(workload_dir + "/timestamps.csv")
df_elapsed = df_stamps['EndNs'] - df_stamps['BeginNs']
df_stamps['Duration'] = df_elapsed
if args.dispatch == None:
args.dispatch = list(map(lambda x: str(x) + ':' + str(x), df_stamps.sort_values(by=['Duration'], ascending=False)['Index'].iloc[0:5].tolist()))
else:
ids = df_stamps.sort_values(by=['Duration'], ascending=False)['Index'].iloc[0:5].tolist()
dispatch = {}
for d in ids:
dispatch[d] = d
for d in args.dispatch:
dispatch[d] = d
args.dispatch = list(map(lambda x: str(x) + ':' + str(x),dispatch.values()))
# Perfmon filtering
perfmon_filter(workload_dir, perfmon_dir, args)
# Workload profiling
for fname in glob.glob(workload_dir + "/perfmon/*.txt"):
# Kernel filtering (in-place replacement)
if not args.kernel == None:
subprocess.run(
[
"sed",
"-i",
"-r",
"s%^(kernel:).*%" + "kernel: " + ",".join(args.kernel) + "%g",
fname,
]
)
# Dispatch filtering (inplace replacement)
if not args.dispatch == None:
subprocess.run(
[
"sed",
"-i",
"-r",
"s%^(range:).*%" + "range: " + " ".join(args.dispatch) + "%g",
fname,
]
)
run_prof(fname, workload_dir, perfmon_dir, args.remaining, args.verbose)
# run again with timestamps
subprocess.run(
[
rocprof_cmd,
# "-i", fname,
# "-m", perfmon_dir + "/" + "metrics.xml",
"--timestamp",
"on",
"-o",
workload_dir + "/" + "timestamps.csv",
'"' + args.remaining + '"',
]
)
# Update pmc_perf.csv timestamps
replace_timestamps(workload_dir)
# Update pmc_perf.csv timestamps
replace_timestamps(workload_dir)
# Generate sysinfo
gen_sysinfo(args.name, workload_dir, args.ipblocks, args.no_roof)
@@ -466,6 +456,7 @@ def main():
# PROFILE MODE
##############
if args.mode == "profile":
print("Resolving rocprof")
resolve_rocprof()
if ".." in str(args.path):
throw_parse_error(