Fixed Outpt Path and recv_0 for ATT
Change-Id: I94248e217d5af14152be82cbe6095de90a489387
[ROCm/rocprofiler commit: 602ac83ce7]
Esse commit está contido em:
@@ -55,14 +55,14 @@ class att_plugin_t {
|
||||
bool is_valid_{true};
|
||||
|
||||
inline bool att_file_exists(const std::string& name) {
|
||||
struct stat buffer;
|
||||
struct stat buffer;
|
||||
return stat(name.c_str(), &buffer) == 0;
|
||||
}
|
||||
|
||||
bool IsValid() const { return is_valid_; }
|
||||
|
||||
void FlushATTRecord(const rocprofiler_record_att_tracer_t* att_tracer_record,
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
|
||||
std::lock_guard<std::mutex> lock(writing_lock);
|
||||
|
||||
if (!att_tracer_record) {
|
||||
@@ -72,26 +72,32 @@ class att_plugin_t {
|
||||
|
||||
size_t name_length;
|
||||
CHECK_ROCMTOOLS(rocprofiler_query_kernel_info_size(ROCPROFILER_KERNEL_NAME,
|
||||
att_tracer_record->kernel_id, &name_length));
|
||||
att_tracer_record->kernel_id, &name_length));
|
||||
const char* kernel_name_c = static_cast<const char*>(malloc(name_length * sizeof(char)));
|
||||
CHECK_ROCMTOOLS(rocprofiler_query_kernel_info(ROCPROFILER_KERNEL_NAME,
|
||||
att_tracer_record->kernel_id, &kernel_name_c));
|
||||
att_tracer_record->kernel_id, &kernel_name_c));
|
||||
|
||||
std::string name_demangled = rocmtools::truncate_name(rocmtools::cxx_demangle(kernel_name_c));
|
||||
|
||||
// Get the number of shader engine traces
|
||||
int se_num = att_tracer_record->shader_engine_data_count;
|
||||
|
||||
std::string outpath;
|
||||
if (getenv("OUTPUT_PATH") == nullptr) {
|
||||
outpath = "";
|
||||
} else {
|
||||
outpath = std::string(getenv("OUTPUT_PATH")) + "/";
|
||||
}
|
||||
// Find if this filename already exists. If so, increment vname.
|
||||
int file_iteration = -1;
|
||||
bool bIncrementVersion = true;
|
||||
while(bIncrementVersion) {
|
||||
while (bIncrementVersion) {
|
||||
file_iteration += 1;
|
||||
std::string fss = name_demangled+"_v"+std::to_string(file_iteration);
|
||||
bIncrementVersion = att_file_exists(fss + "_kernel.txt");
|
||||
std::string fss = name_demangled + "_v" + std::to_string(file_iteration);
|
||||
bIncrementVersion = att_file_exists(outpath + fss + "_kernel.txt");
|
||||
}
|
||||
|
||||
std::string fname = name_demangled+"_v"+std::to_string(file_iteration)+"_kernel.txt";
|
||||
std::string fname =
|
||||
outpath + name_demangled + "_v" + std::to_string(file_iteration) + "_kernel.txt";
|
||||
std::ofstream(fname.c_str()) << name_demangled << ": " << kernel_name_c << '\n';
|
||||
|
||||
// iterate over each shader engine att trace
|
||||
@@ -106,7 +112,7 @@ class att_plugin_t {
|
||||
|
||||
// dump data in binary format
|
||||
std::ostringstream oss;
|
||||
oss << name_demangled << "_v" << file_iteration << "_se" << i << ".att";
|
||||
oss << outpath + name_demangled << "_v" << file_iteration << "_se" << i << ".att";
|
||||
std::ofstream out(oss.str().c_str(), std::ios::binary);
|
||||
if (out.is_open()) {
|
||||
out.write((char*)data_buffer_ptr, size);
|
||||
@@ -118,8 +124,8 @@ class att_plugin_t {
|
||||
}
|
||||
|
||||
int WriteBufferRecords(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end, rocprofiler_session_id_t session_id,
|
||||
rocprofiler_buffer_id_t buffer_id) {
|
||||
const rocprofiler_record_header_t* end,
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
|
||||
while (begin < end) {
|
||||
if (!begin) return 0;
|
||||
switch (begin->kind) {
|
||||
@@ -131,8 +137,9 @@ class att_plugin_t {
|
||||
break;
|
||||
|
||||
case ROCPROFILER_ATT_TRACER_RECORD: {
|
||||
rocprofiler_record_att_tracer_t* att_record = const_cast<rocprofiler_record_att_tracer_t*>(
|
||||
reinterpret_cast<const rocprofiler_record_att_tracer_t*>(begin));
|
||||
rocprofiler_record_att_tracer_t* att_record =
|
||||
const_cast<rocprofiler_record_att_tracer_t*>(
|
||||
reinterpret_cast<const rocprofiler_record_att_tracer_t*>(begin));
|
||||
FlushATTRecord(att_record, session_id, buffer_id);
|
||||
break;
|
||||
}
|
||||
@@ -151,7 +158,7 @@ att_plugin_t* att_plugin = nullptr;
|
||||
} // namespace
|
||||
|
||||
ROCPROFILER_EXPORT int rocprofiler_plugin_initialize(uint32_t rocprofiler_major_version,
|
||||
uint32_t rocprofiler_minor_version) {
|
||||
uint32_t rocprofiler_minor_version) {
|
||||
if (rocprofiler_major_version != ROCPROFILER_VERSION_MAJOR ||
|
||||
rocprofiler_minor_version < ROCPROFILER_VERSION_MINOR)
|
||||
return -1;
|
||||
@@ -173,16 +180,15 @@ ROCPROFILER_EXPORT void rocprofiler_plugin_finalize() {
|
||||
att_plugin = nullptr;
|
||||
}
|
||||
|
||||
ROCPROFILER_EXPORT int rocprofiler_plugin_write_buffer_records(const rocprofiler_record_header_t* begin,
|
||||
const rocprofiler_record_header_t* end,
|
||||
rocprofiler_session_id_t session_id,
|
||||
rocprofiler_buffer_id_t buffer_id) {
|
||||
ROCPROFILER_EXPORT int rocprofiler_plugin_write_buffer_records(
|
||||
const rocprofiler_record_header_t* begin, const rocprofiler_record_header_t* end,
|
||||
rocprofiler_session_id_t session_id, rocprofiler_buffer_id_t buffer_id) {
|
||||
if (!att_plugin || !att_plugin->IsValid()) return -1;
|
||||
return att_plugin->WriteBufferRecords(begin, end, session_id, buffer_id);
|
||||
}
|
||||
|
||||
ROCPROFILER_EXPORT int rocprofiler_plugin_write_record(rocprofiler_record_tracer_t record,
|
||||
rocprofiler_session_id_t session_id) {
|
||||
rocprofiler_session_id_t session_id) {
|
||||
if (!att_plugin || !att_plugin->IsValid()) return -1;
|
||||
if (record.header.id.handle == 0) return 0;
|
||||
return 0;
|
||||
|
||||
@@ -124,6 +124,7 @@ def parse_binary(filename, kernel=None):
|
||||
print('Parsing kernel:', kernel[0].split(': ')[0])
|
||||
kernel = kernel[0].split(': ')[1].split('.kd')[0]
|
||||
kernel = str(kernel).encode('utf-8')
|
||||
filename = os.path.abspath(str(filename))
|
||||
info = SO.wrapped_parse_binary(str(filename).encode('utf-8'), kernel)
|
||||
|
||||
code = []
|
||||
@@ -149,6 +150,7 @@ def parse_binary(filename, kernel=None):
|
||||
|
||||
|
||||
def getWaves(filename, target_cu, verbose):
|
||||
filename = os.path.abspath(str(filename))
|
||||
info = SO.AnalyseBinary(filename.encode('utf-8'), target_cu, verbose)
|
||||
|
||||
waves = [info.wavedata[k] for k in range(info.num_waves)]
|
||||
@@ -282,21 +284,12 @@ def Copy_Files(output_ui):
|
||||
|
||||
|
||||
def get_delta_time(events):
|
||||
for begin in range(len(events)):
|
||||
tg_cu = events[begin].cu
|
||||
for e in range(begin+1,len(events)):
|
||||
if events[e].cu == tg_cu:
|
||||
return events[e].time-events[begin].time
|
||||
return 1
|
||||
|
||||
|
||||
def num_cus(EVENTS):
|
||||
cus = 0
|
||||
for events in EVENTS:
|
||||
for e in events:
|
||||
cus = max(cus, e.cu)
|
||||
return cus+1
|
||||
|
||||
try:
|
||||
CUS = [[e.time for e in events if e.cu==k and e.bank==0] for k in range(16)]
|
||||
CUS = [np.asarray(c).astype(np.int64) for c in CUS if len(c) > 2]
|
||||
return np.min([np.min(abs(c[1:]-c[:-1])) for c in CUS])
|
||||
except:
|
||||
return 1
|
||||
|
||||
def draw_wave_metrics(selections, normalize):
|
||||
global PIC_SAVE_FOLDER
|
||||
@@ -309,18 +302,18 @@ def draw_wave_metrics(selections, normalize):
|
||||
|
||||
plt.figure(figsize=(15,3))
|
||||
|
||||
delta_time = int(0.5+np.mean([get_delta_time(events) for events in EVENTS]))
|
||||
delta_time = 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)
|
||||
print('Max_cycles:', maxtime)
|
||||
|
||||
kernsize = 2*(delta_time//8)+1
|
||||
kernsize = 2*(delta_time//14)+1
|
||||
trim = max(maxtime//5000,1)
|
||||
cycles = 4*np.arange(maxtime)[::trim]
|
||||
|
||||
kernel = np.asarray([np.exp(-abs(k/kernsize)**2) for k in range(-kernsize*3,kernsize*3+1)])
|
||||
kernel /= np.sum(kernel)*len(EVENTS)*delta_time#*5.12 # SEslots/100%
|
||||
kernel /= np.sum(kernel)*len(EVENTS)*delta_time
|
||||
|
||||
for events in EVENTS:
|
||||
for e in range(len(events)-1):
|
||||
@@ -336,7 +329,6 @@ def draw_wave_metrics(selections, normalize):
|
||||
|
||||
if normalize:
|
||||
event_timeline = [100*e/max(e.max(), 1E-5) for e in event_timeline]
|
||||
#event_timeline[0] = np.clip(event_timeline[0]*8.5, 0, 100) #CC rate
|
||||
|
||||
colors = ['blue', 'green', 'gray', 'red', 'orange', 'cyan', 'black', 'darkviolet',
|
||||
'yellow', 'darkred', 'pink', 'lime', 'gold', 'tan', 'aqua', 'olive']
|
||||
@@ -369,7 +361,7 @@ def draw_wave_states(selections, normalize):
|
||||
if normalize:
|
||||
timelines = np.array(timelines) / np.maximum(np.sum(timelines,0)*1E-2,1E-7)
|
||||
|
||||
kernsize = maxtime//120+3
|
||||
kernsize = maxtime//150+1
|
||||
trim = max(maxtime//5000,1)
|
||||
cycles = np.arange(timelines[0].size)[::trim]
|
||||
|
||||
@@ -395,19 +387,22 @@ def draw_wave_states(selections, normalize):
|
||||
plt.savefig(PIC_SAVE_FOLDER+'timeline.png', dpi=150)
|
||||
|
||||
|
||||
def GeneratePIC(selections=[True for k in range(4)], normalize=True):
|
||||
if len(EVENTS) > 0 and np.sum([len(e) for e in EVENTS]) > 32:
|
||||
def GeneratePIC(selections=[True for k in range(16)], normalize=True, bScounter=True):
|
||||
if bScounter and len(EVENTS) > 0 and np.sum([len(e) for e in EVENTS]) > 32:
|
||||
draw_wave_metrics(selections, normalize)
|
||||
else:
|
||||
draw_wave_states(selections, normalize)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pathenv = os.getenv('OUTPUT_PATH')
|
||||
if pathenv is None:
|
||||
pathenv = "."
|
||||
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("-k", "--att_kernel", help="Kernel file", type=str, default='*_kernel.txt')
|
||||
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)
|
||||
@@ -422,7 +417,6 @@ if __name__ == "__main__":
|
||||
|
||||
EVENT_NAMES = []
|
||||
clean = lambda x: x.split('=')[1].split(' ')[0].split('\n')[0]
|
||||
|
||||
for line in lines:
|
||||
if 'PERFCOUNTER_ID=' in line:
|
||||
EVENT_NAMES += ['id: '+clean(line)]
|
||||
|
||||
@@ -161,7 +161,7 @@ def stitch(insts, code, jumps):
|
||||
|
||||
N = max(N, 1)
|
||||
if len(result) != N:
|
||||
print('Warning - Stitching rate: {'+str(len(result) * 100 / N)+'% matched')
|
||||
print('Warning - Stitching rate: '+str(len(result) * 100 / N)+'% matched')
|
||||
|
||||
return result, loopCount, mem_unroll, flight_count
|
||||
|
||||
@@ -327,8 +327,8 @@ class NoCacheHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
global PICTURE_CALLBACK
|
||||
if 'timeline.png?' in self.path:
|
||||
selections = [int(s)!=0 for s in self.path.split('timeline.png?')[1]]
|
||||
print('Sel:', selections)
|
||||
PICTURE_CALLBACK(selections[1:], selections[0])
|
||||
#PICTURE_CALLBACK(selections[2:], selections[1], selections[0])
|
||||
http.server.SimpleHTTPRequestHandler.do_GET(self)
|
||||
|
||||
class RocTCPServer(socketserver.TCPServer):
|
||||
|
||||
@@ -262,7 +262,11 @@ if [ -n "$PMC_LINES" ]; then
|
||||
for i in ${!PMC_LINES[@]}; do
|
||||
export ROCPROFILER_COUNTERS="${PMC_LINES[$i]}"
|
||||
if [ -n "$OUTPUT_PATH" ]; then
|
||||
FINAL_PATH="$OUTPUT_PATH_INTERNAL/pmc_$COUNTER"
|
||||
if [ ! -n "$ATT_ARGV" ]; then
|
||||
FINAL_PATH="$OUTPUT_PATH_INTERNAL/pmc_$COUNTER"
|
||||
else
|
||||
FINAL_PATH="$OUTPUT_PATH"
|
||||
fi
|
||||
echo -e "\nThe output path for the following counters: $FINAL_PATH"
|
||||
mkdir -p $FINAL_PATH
|
||||
echo $ROCPROFILER_COUNTERS > $FINAL_PATH/pmc.txt
|
||||
|
||||
@@ -256,7 +256,7 @@ att_parsed_input_t GetATTParams() {
|
||||
|
||||
if (param_name == "PERFCOUNTERS_COL_PERIOD") {
|
||||
default_params["TOKEN_MASK"] |= 0x4000;
|
||||
param_value = ((param_value & 0x1F) << 8) | 0x007F;
|
||||
param_value = ((param_value & 0x1F) << 8) | 0xFFFF00FF;
|
||||
parameters.push_back(std::make_pair(ROCPROFILER_ATT_PERF_CTRL, param_value));
|
||||
continue;
|
||||
} else if (param_name == "SIMD_MASK") {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário