diff --git a/projects/rocprofiler/bin/rpl_run.sh b/projects/rocprofiler/bin/rpl_run.sh index 0556265ef7..86383d1494 100755 --- a/projects/rocprofiler/bin/rpl_run.sh +++ b/projects/rocprofiler/bin/rpl_run.sh @@ -46,6 +46,7 @@ fi # runtime API trace ROCTX_TRACE=0 +KFD_TRACE=0 HSA_TRACE=0 SYS_TRACE=0 HIP_TRACE=0 @@ -164,6 +165,7 @@ usage() { echo "" echo " --stats - generating kernel execution stats, file .stats.csv" echo " --roctx-trace - to enable rocTX trace" + echo " --kfd-trace - to trace KFD, generates API execution stats and JSON file chrome-tracing compatible" echo " --hsa-trace - to trace HSA, generates API execution stats and JSON file chrome-tracing compatible" echo " --sys-trace - to trace HIP/HSA APIs and GPU activity, generates stats and JSON trace chrome-tracing compatible" echo " --hip-trace - to trace HIP, generates API execution stats and JSON file chrome-tracing compatible" @@ -233,6 +235,10 @@ run() { if [ "$ROCTX_TRACE" = 1 ] ; then API_TRACE=${API_TRACE}":roctx" fi + if [ "$KFD_TRACE" = 1 ] ; then + API_TRACE=${API_TRACE}":kfd" + export LD_PRELOAD="libkfdwrapper64.so libhsakmt.so.1" + fi if [ "$HIP_TRACE" = 1 ] ; then API_TRACE=${API_TRACE}":hip" fi @@ -256,6 +262,8 @@ run() { CMD_LINE="$APP_CMD $redirection_cmd" eval "$CMD_LINE" + + unset LD_PRELOAD } merge_output() { @@ -364,6 +372,11 @@ while [ 1 ] ; do elif [ "$1" = "--roctx-trace" ] ; then ARG_VAL=0 ROCTX_TRACE=1 + elif [ "$1" = "--kfd-trace" ] ; then + ARG_VAL=0 + export ROCP_TIMESTAMP_ON=1 + GEN_STATS=1 + KFD_TRACE=1 elif [ "$1" = "--hsa-trace" ] ; then ARG_VAL=0 export ROCP_TIMESTAMP_ON=1 diff --git a/projects/rocprofiler/bin/tblextr.py b/projects/rocprofiler/bin/tblextr.py index 26374938c1..490cdb8b2b 100755 --- a/projects/rocprofiler/bin/tblextr.py +++ b/projects/rocprofiler/bin/tblextr.py @@ -36,8 +36,11 @@ EXT_PID = 0 COPY_PID = 1 HIP_PID = 2 HSA_PID = 3 -OPS_PID = 4 -GPU_BASE_PID = 5 +KFD_PID = 4 +OPS_PID = 5 +GPU_BASE_PID = 6 +NONE_PID = -1 + max_gpu_id = -1 START_US = 0 @@ -315,11 +318,12 @@ def fill_api_db(table_name, db, indir, api_name, api_pid, dep_pid, dep_list, dep db.insert_entry(table_handle, [from_ns, from_ns, api_pid, tid, 'hsa_dispatch', '', record_id]) record_id += 1 - if not dep_pid in dep_dict: dep_dict[dep_pid] = {} - dep_dict[dep_pid]['pid'] = api_pid - dep_dict[dep_pid]['tid'] = dep_tid_list - dep_dict[dep_pid]['from'] = dep_from_us_list - if expl_id: dep_dict[dep_pid]['id'] = dep_id_list + if dep_pid != NONE_PID: + if not dep_pid in dep_dict: dep_dict[dep_pid] = {} + dep_dict[dep_pid]['pid'] = api_pid + dep_dict[dep_pid]['tid'] = dep_tid_list + dep_dict[dep_pid]['from'] = dep_from_us_list + if expl_id: dep_dict[dep_pid]['id'] = dep_id_list if copy_csv != '': file_name = os.environ['PWD'] + '/results_mcopy.csv' @@ -447,6 +451,8 @@ else: ext_trace_found = fill_ext_db('rocTX', db, indir, 'roctx', EXT_PID) + kfd_trace_found = fill_api_db('KFD', db, indir, 'kfd', KFD_PID, NONE_PID, [], {}, 0) + hsa_activity_found = fill_copy_db('COPY', db, indir) hsa_trace_found = fill_api_db('HSA', db, indir, 'hsa', HSA_PID, COPY_PID, kern_dep_list, {}, 0) @@ -455,7 +461,7 @@ else: fill_kernel_db('A', db) - any_trace_found = ext_trace_found | hsa_trace_found | hip_trace_found + any_trace_found = ext_trace_found | kfd_trace_found | hsa_trace_found | hip_trace_found if any_trace_found: db.open_json(jsonfile) @@ -467,6 +473,10 @@ else: if hsa_trace_found: db.label_json(HSA_PID, "CPU HSA API", jsonfile) + + if kfd_trace_found: + db.label_json(KFD_PID, "CPU KFD API", jsonfile) + if hsa_activity_found: db.label_json(COPY_PID, "COPY", jsonfile) @@ -502,6 +512,12 @@ else: dform.post_process_data(db, 'OPS') dform.gen_ops_json_trace(db, 'OPS', GPU_BASE_PID, START_US, jsonfile) + if kfd_trace_found: + statfile = re.sub(r'stats', r'kfd_stats', statfile) + dform.post_process_data(db, 'KFD') + dform.gen_table_bins(db, 'KFD', statfile, 'Name', 'DurationNs') + dform.gen_api_json_trace(db, 'KFD', START_US, jsonfile) + if any_trace_found: for (to_pid, dep_str) in dep_dict.items(): if 'bsp' in dep_str: