SWDEV-423947: Added ATT header option
Change-Id: I6e9ad213b578d752c865c9f9af4ee0b79d447e1b
This commit is contained in:
committed by
Giovanni Baraldi
parent
fdd4af4023
commit
e0962d9d63
+16
-10
@@ -45,30 +45,33 @@
|
||||
#include "rocprofiler_plugin.h"
|
||||
#include "../utils.h"
|
||||
#include "code_printing.hpp"
|
||||
|
||||
#include "../../src/core/session/att/att.h"
|
||||
|
||||
#define ATT_FILENAME_MAXBYTES 90
|
||||
#define TEST_INVALID_KERNEL size_t(-1)
|
||||
|
||||
namespace {
|
||||
|
||||
class att_plugin_t {
|
||||
public:
|
||||
att_plugin_t() {
|
||||
att_plugin_t(void* data) {
|
||||
std::vector<const char*> mpivars = {"MPI_RANK", "OMPI_COMM_WORLD_RANK", "MV2_COMM_WORLD_RANK"};
|
||||
|
||||
for (const char* envvar : mpivars)
|
||||
if (const char* env = getenv(envvar)) {
|
||||
MPI_RANK = atoi(env);
|
||||
MPI_ENABLE = true;
|
||||
break;
|
||||
}
|
||||
if (const char* env = getenv(envvar)) {
|
||||
MPI_RANK = atoi(env);
|
||||
MPI_ENABLE = true;
|
||||
break;
|
||||
}
|
||||
|
||||
header.raw = reinterpret_cast<uint64_t>(data);
|
||||
header.reserved = 0x11;
|
||||
}
|
||||
|
||||
bool MPI_ENABLE = false;
|
||||
int MPI_RANK = 0;
|
||||
std::mutex writing_lock;
|
||||
bool is_valid_{true};
|
||||
rocprofiler::att_header_packet_t header{.raw = 0};
|
||||
|
||||
inline bool att_file_exists(const std::string& name) {
|
||||
struct stat buffer;
|
||||
@@ -130,12 +133,14 @@ class att_plugin_t {
|
||||
<< '\n';
|
||||
|
||||
// iterate over each shader engine att trace
|
||||
header.navi = !att_tracer_record->intercept_list.userdata;
|
||||
int se_num = att_tracer_record->shader_engine_data_count;
|
||||
for (int i = 0; i < se_num; i++) {
|
||||
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);
|
||||
header.SEID = i;
|
||||
rocprofiler_record_se_att_data_t* se_att_trace = &att_tracer_record->shader_engine_data[i];
|
||||
char* data_buffer_ptr = reinterpret_cast<char*>(se_att_trace->buffer_ptr);
|
||||
|
||||
@@ -145,6 +150,8 @@ class att_plugin_t {
|
||||
std::cerr << "ATT Failed to open file: " << outfilepath << "_se" << i << ".att\n";
|
||||
return ROCPROFILER_STATUS_ERROR;
|
||||
}
|
||||
if (header.enable)
|
||||
out.write((const char*)&header, sizeof(header.raw));
|
||||
out.write(data_buffer_ptr, se_att_trace->buffer_size);
|
||||
}
|
||||
|
||||
@@ -153,7 +160,6 @@ class att_plugin_t {
|
||||
std::cerr << "Could not open ISA file: " << outfilepath << "_isa.s" << std::endl;
|
||||
return ROCPROFILER_STATUS_ERROR;
|
||||
}
|
||||
uint64_t kernel_begin_addr = att_tracer_record->intercept_list.userdata;
|
||||
isafile << "<Kernel> " << kernel_name_mangled << '\n';
|
||||
|
||||
for (size_t i = 0; i < att_tracer_record->intercept_list.count; i++) {
|
||||
@@ -231,7 +237,7 @@ ROCPROFILER_EXPORT int rocprofiler_plugin_initialize(uint32_t rocprofiler_major_
|
||||
|
||||
if (att_plugin != nullptr) return ROCPROFILER_STATUS_ERROR;
|
||||
|
||||
att_plugin = new att_plugin_t();
|
||||
att_plugin = new att_plugin_t(data);
|
||||
if (att_plugin->IsValid()) return ROCPROFILER_STATUS_SUCCESS;
|
||||
|
||||
// The plugin failed to initialied, destroy it and return an error.
|
||||
|
||||
+19
-19
@@ -172,7 +172,7 @@ path_to_parser = os.path.abspath(rocprofv2_att_lib)
|
||||
SO = CDLL(path_to_parser)
|
||||
|
||||
SO.AnalyseBinary.restype = ReturnInfo
|
||||
SO.AnalyseBinary.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.c_bool]
|
||||
SO.AnalyseBinary.argtypes = [ctypes.c_char_p]
|
||||
SO.wrapped_parse_binary.argtypes = [ctypes.c_char_p, ctypes.c_char_p]
|
||||
SO.wrapped_parse_binary.restype = ReturnAssemblyInfo
|
||||
SO.FreeBinary.argtypes = [ctypes.c_uint64]
|
||||
@@ -217,9 +217,9 @@ def parse_binary(filename, kernel=None):
|
||||
return code, jumps, kernel_addr
|
||||
|
||||
|
||||
def getWaves_binary(name, target_cu):
|
||||
def getWaves_binary(name):
|
||||
filename = os.path.abspath(str(name))
|
||||
info = SO.AnalyseBinary(filename.encode("utf-8"), target_cu, False)
|
||||
info = SO.AnalyseBinary(filename.encode("utf-8"))
|
||||
|
||||
isValid = info.flags & 0x1
|
||||
if isValid == 0:
|
||||
@@ -267,7 +267,10 @@ def persist(trace_file, SIMD, traces):
|
||||
smem_ins, smem_stalls, br_ins, br_taken_ins, br_stalls = [], [], [], [], []
|
||||
|
||||
for wave in SIMD:
|
||||
if wave.instructions is None or traces[wave.traceid].instructions is None:
|
||||
try:
|
||||
if wave.instructions is None or traces[wave.traceid].instructions is None:
|
||||
continue
|
||||
except:
|
||||
continue
|
||||
simds.append(wave.simd)
|
||||
waves.append(wave.wave_id)
|
||||
@@ -456,21 +459,18 @@ if __name__ == "__main__":
|
||||
print("Skipping analysis.")
|
||||
quit()
|
||||
|
||||
with open(os.getenv("COUNTERS_PATH"), "r") as f:
|
||||
lines = [l.split("//")[0] for l in f.readlines()]
|
||||
if os.getenv("COUNTERS_PATH"):
|
||||
with open(os.getenv("COUNTERS_PATH"), "r") as f:
|
||||
lines = [l.split("//")[0] for l in f.readlines()]
|
||||
|
||||
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)]
|
||||
elif "att: TARGET_CU" in line:
|
||||
args.target_cu = int(clean(line))
|
||||
for line in lines:
|
||||
if "PERFCOUNTER=" in line:
|
||||
EVENT_NAMES += [clean(line).split("SQ_")[1].lower()]
|
||||
if args.target_cu is None:
|
||||
args.target_cu = 1
|
||||
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)]
|
||||
for line in lines:
|
||||
if "PERFCOUNTER=" in line:
|
||||
EVENT_NAMES += [clean(line).split("SQ_")[1].lower()]
|
||||
|
||||
att_kernel_list = glob.glob(args.att_kernel)
|
||||
|
||||
@@ -520,7 +520,7 @@ if __name__ == "__main__":
|
||||
gc.collect()
|
||||
|
||||
for name in filenames:
|
||||
traces, waves, perfevents, occupancy, gfxv, addrs = getWaves_binary(name, args.target_cu)
|
||||
traces, waves, perfevents, occupancy, gfxv, addrs = getWaves_binary(name)
|
||||
if gfxv is None:
|
||||
continue
|
||||
|
||||
|
||||
@@ -258,7 +258,6 @@ def stitch(insts, raw_code, jumps, gfxv, bIsAuto):
|
||||
while i < N:
|
||||
if insts[i].type == PCINFO:
|
||||
i += 1
|
||||
N -= 1
|
||||
continue
|
||||
|
||||
#print(line, i, WaveInstCategory[insts[i].type], insts[i].num_waves, insts[i].cycles)
|
||||
@@ -297,7 +296,6 @@ def stitch(insts, raw_code, jumps, gfxv, bIsAuto):
|
||||
pcskip.append(i)
|
||||
matched = next >= 0
|
||||
i += 1
|
||||
N -= 1
|
||||
elif as_line[1] == SWAPPC:
|
||||
next = watchlist.swappc(as_line[0], line, i)
|
||||
matched = inst.type in [SALU, JUMP]
|
||||
@@ -305,7 +303,6 @@ def stitch(insts, raw_code, jumps, gfxv, bIsAuto):
|
||||
pcskip.append(i)
|
||||
matched = next >= 0
|
||||
i += 1
|
||||
N -= 1
|
||||
elif inst.type == as_line[1]:
|
||||
if line in jumps:
|
||||
loopCount[jumps[line] - 1] += 1
|
||||
|
||||
Reference in New Issue
Block a user