From a7329eb8ee620dd88b5842ed8b8fca45ae0ecc11 Mon Sep 17 00:00:00 2001 From: Giovanni LB Date: Sat, 18 Feb 2023 02:12:05 -0300 Subject: [PATCH] SWDEV-384602: Solved issues with multiple users. Change-Id: Ie40addcbfdfce6ce45ceec8e38fc83d3d72882eb [ROCm/rocprofiler commit: 4ec67854e58ad06ed14b98d3db95f30c92f66ccf] --- projects/rocprofiler/bin/rocprofv2 | 12 ++++------ projects/rocprofiler/plugin/att/att.cpp | 2 +- projects/rocprofiler/plugin/att/att.py | 23 ++++++++++--------- projects/rocprofiler/plugin/att/trace_view.py | 10 ++++---- projects/rocprofiler/plugin/att/ui/index.html | 11 ++++++--- 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/projects/rocprofiler/bin/rocprofv2 b/projects/rocprofiler/bin/rocprofv2 index d1fedd0ce4..f22fb61937 100755 --- a/projects/rocprofiler/bin/rocprofv2 +++ b/projects/rocprofiler/bin/rocprofv2 @@ -213,7 +213,7 @@ while [ 1 ] ; do ATT_PATH=$ROCPROFV2_DIR/../libexec/rocprofiler/att/att.py fi ATT_ARGV=$3 - shift + shift ATT_OPTIONS="Not done" while [ "$ATT_OPTIONS" = "Not done" ]; do @@ -221,7 +221,7 @@ while [ 1 ] ; do ATT_ARGV="$ATT_ARGV $3 \"$4\"" shift shift - elif [[ "$3" = "--genasm" || "$3" = "--target_cu" || "$3" = "-o" || "$3" == "-k" || "$3" == "--att_kernel" ]]; then + elif [[ "$3" = "--ports" || "$3" = "--genasm" || "$3" = "--target_cu" || "$3" = "-o" || "$3" == "-k" || "$3" == "--att_kernel" ]]; then ATT_ARGV="$ATT_ARGV $3 $4" shift shift @@ -229,11 +229,6 @@ while [ 1 ] ; do ATT_OPTIONS="Done" fi done - if [ $RUN_FROM_BUILD == 1 ]; then - ATT_PATH=$ROCPROFV2_DIR/build/plugin/att/att/att.py - else - ATT_PATH=$ROCPROFV2_DIR/../libexec/rocprofiler/att/att.py - fi fi shift shift @@ -289,6 +284,9 @@ fi if [ -n "$ATT_PATH" ]; then if [ -n "$ATT_ARGV" ]; then + if [ -n "$OUTPUT_PATH" ]; then + ATT_ARGV="$ATT_ARGV -o $OUTPUT_PATH" + fi eval "python3 $ATT_PATH $ATT_ARGV" elif [ ! -n "$PMC_LINES" ]; then echo "ATT File is required!" diff --git a/projects/rocprofiler/plugin/att/att.cpp b/projects/rocprofiler/plugin/att/att.cpp index 00227ca8d7..4165fbe9f0 100644 --- a/projects/rocprofiler/plugin/att/att.cpp +++ b/projects/rocprofiler/plugin/att/att.cpp @@ -102,7 +102,7 @@ class att_plugin_t { // iterate over each shader engine att trace for (int i = 0; i < se_num; i++) { - if (!att_tracer_record->shader_engine_data && + if (!att_tracer_record->shader_engine_data || !att_tracer_record->shader_engine_data[i].buffer_ptr) continue; printf("--------------collecting data for shader_engine %d---------------\n", i); diff --git a/projects/rocprofiler/plugin/att/att.py b/projects/rocprofiler/plugin/att/att.py index 7ded24e4d4..12ce4cfbfd 100755 --- a/projects/rocprofiler/plugin/att/att.py +++ b/projects/rocprofiler/plugin/att/att.py @@ -298,12 +298,12 @@ def draw_wave_metrics(selections, normalize): global EVENT_NAMES #event_names = ['Busy CUs', 'Occupancy', 'Eligible waves', 'Waves waiting'] - with open(PIC_SAVE_FOLDER+'counters.json', 'w') as f: + with open(os.path.join(PIC_SAVE_FOLDER,'counters.json'), 'w') as f: f.write(json.dumps({"counters": EVENT_NAMES})) plt.figure(figsize=(15,3)) - delta_time = int(0.5+np.min([get_delta_time(events) for events in EVENTS])) + delta_time = max(1,int(0.5+np.min([get_delta_time(events) for events in EVENTS]))) maxtime = np.max([np.max([e.time for e in events]) for events in EVENTS])+1 event_timeline = np.zeros((16, maxtime), dtype=np.int32) print('Delta:', delta_time) @@ -342,7 +342,7 @@ def draw_wave_metrics(selections, normalize): else: plt.ylabel('Value') plt.subplots_adjust(left=0.05, right=1, top=1, bottom=0.07) - plt.savefig(PIC_SAVE_FOLDER+'timeline.png', dpi=150) + plt.savefig(os.path.join(PIC_SAVE_FOLDER,'timeline.png'), dpi=150) #plt.show() @@ -371,7 +371,7 @@ def draw_wave_states(selections, normalize): timelines = [np.convolve(time, kernel)[kernsize//2:-kernsize//2][::trim] for time in timelines] - with open(PIC_SAVE_FOLDER+'counters.json', 'w') as f: + with open(os.path.join(PIC_SAVE_FOLDER,'counters.json'), 'w') as f: f.write(json.dumps({"counters": STATES})) [plt.plot(cycles, t, label='State '+s, linewidth=1.1, color=c) @@ -385,7 +385,7 @@ def draw_wave_states(selections, normalize): plt.ylim(-1) plt.xlim(-maxtime//200, maxtime+maxtime//200) plt.subplots_adjust(left=0.05, right=1, top=1, bottom=0.07) - plt.savefig(PIC_SAVE_FOLDER+'timeline.png', dpi=150) + plt.savefig(os.path.join(PIC_SAVE_FOLDER,'timeline.png'), dpi=150) def GeneratePIC(selections=[True for k in range(16)], normalize=True, bScounter=True): @@ -402,12 +402,10 @@ if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("assembly_code", help="Path of the assembly code") parser.add_argument("--trace_file", help="Filter for trace files", default=None, type=str) - parser.add_argument("-o", "--output_ui", help="Output Folder", default='/dev/shm/attplugin/') + parser.add_argument("-o", "--output_ui", help="Output Folder", default='.') parser.add_argument("-k", "--att_kernel", help="Kernel file", type=str, default=pathenv+'/*_kernel.txt') - parser.add_argument("-w", "--wave_id", help="wave id") parser.add_argument("-p", "--ports", help="Server and websocket ports, default: 8000,18000") parser.add_argument("--target_cu", help="Collected target CU id{0-15}", type=int, default=None) - parser.add_argument("-v", "--verbose", action="store_true") parser.add_argument("-g", "--genasm", help="Generate post-processed asm file at this path", type=str, default="") args = parser.parse_args() @@ -478,7 +476,7 @@ if __name__ == "__main__": TIMELINES = [np.zeros(int(1E4),dtype=np.int32) for k in range(5)] EVENTS = [] for name in filenames: - SIMD, perfevents = getWaves(name, args.target_cu, args.verbose) + SIMD, perfevents = getWaves(name, args.target_cu, False) EVENTS.append(perfevents) DBFILES.append( persist(args.output_ui, name, SIMD) ) for wave in SIMD: @@ -500,6 +498,11 @@ if __name__ == "__main__": TIMELINES[state[0]][time_acc:time_acc+state[1]] += 1 time_acc += state[1] + global PIC_SAVE_FOLDER + PIC_SAVE_FOLDER = os.path.abspath(os.path.join(args.output_ui, 'ui')) + #GeneratePIC() + #quit() + if args.genasm and len(args.genasm) > 0: flight_count = view_trace(args, 0, code, jumps, DBFILES, filenames, True, None) @@ -513,6 +516,4 @@ if __name__ == "__main__": for k in keys: file.write(assembly_code[k]+'\n') else: - global PIC_SAVE_FOLDER - PIC_SAVE_FOLDER = args.output_ui+"/ui/" view_trace(args, 0, code, jumps, DBFILES, filenames, False, GeneratePIC) diff --git a/projects/rocprofiler/plugin/att/trace_view.py b/projects/rocprofiler/plugin/att/trace_view.py index 584e49b472..c406908b6c 100755 --- a/projects/rocprofiler/plugin/att/trace_view.py +++ b/projects/rocprofiler/plugin/att/trace_view.py @@ -12,7 +12,7 @@ from struct import * from collections import defaultdict import json import time -import webbrowser +#import webbrowser import http.server import socketserver import socket @@ -308,9 +308,9 @@ def extract_data(df, output_ui, se_number, code, jumps): return flight_count, all_filenames -def open_browser(): - time.sleep(0.1) - webbrowser.open_new_tab('http://{0}:{1}'.format(IPAddr, PORT)) +#def open_browser(): +# time.sleep(0.1) +# webbrowser.open_new_tab('http://{0}:{1}'.format(IPAddr, PORT)) class NoCacheHTTPRequestHandler(http.server.SimpleHTTPRequestHandler): @@ -452,7 +452,7 @@ def view_trace(args, wait, code, jumps, dbnames, att_filenames, bReturnLoc, pic_ if wait == 0: try: PROCS = [Process(target=run_server), - Process(target=open_browser), + #Process(target=open_browser), Process(target=run_websocket)] if pic_thread is not None: pic_thread.join() diff --git a/projects/rocprofiler/plugin/att/ui/index.html b/projects/rocprofiler/plugin/att/ui/index.html index b1dbbc7703..1370ebe11d 100644 --- a/projects/rocprofiler/plugin/att/ui/index.html +++ b/projects/rocprofiler/plugin/att/ui/index.html @@ -58,7 +58,11 @@ ctx.fill(); } - function DrawCanvas(waitcnt) { + var canvas_waitcnt = 0 + function DrawCanvas() { + if (canvas_waitcnt == 0) return; + var waitcnt = canvas_waitcnt + const canvas = document.getElementById("arrows"); if (canvas.getContext) { const ctx = canvas.getContext("2d"); @@ -98,7 +102,6 @@ for(var s=smin; s<=smax; s++) { slots[s] += 1 max_slots = Math.max(max_slots, waitcnt[w][1][l][1]) - console.log(waitcnt[w][2]) } } } @@ -151,6 +154,8 @@ } } + setInterval(DrawCanvas, 200) + function WaveButtonHtml(index) { return '\n' } @@ -617,7 +622,7 @@ } }) - DrawCanvas(data.wave.waitcnt) + canvas_waitcnt = data.wave.waitcnt /*var all_nodes = d3.select("#code") .selectAll("li")