Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jump-buttons to get fro Stmt directly to Assembly #7793

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/StmtToViz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,9 @@ class HTMLCodePrinter : public IRVisitor {
cost_model = std::move(cm);
}

void print(const Module &m) {
void print(const Module &m, AssemblyInfo asm_info) {
assembly_info = std::move(asm_info);

// Generate a unique ID for this module
int id = gen_unique_id();

Expand Down Expand Up @@ -708,6 +710,7 @@ class HTMLCodePrinter : public IRVisitor {

// Holds cost information for visualized program
IRCostModel cost_model;
AssemblyInfo assembly_info;

/* Private print functions to handle various IR types */
void print(const Buffer<> &buf) {
Expand Down Expand Up @@ -928,6 +931,16 @@ class HTMLCodePrinter : public IRVisitor {
<< "</button>";
}

// Prints a button to sync text with visualization
void print_assembly_button(const void *op) {
int asm_lno = assembly_info.get_asm_lno((uint64_t)op);
if (asm_lno != -1) {
stream << "<button class='icon-btn text-info sync-btn' onclick='scrollToAsm(\"" << asm_lno << "\")'>"
<< " <i class='bi bi-arrow-right-square' title='Jump to Assembly'></i>"
<< "</button>";
}
}

// CUDA kernels are embedded into modules as PTX assembly. This
// routine pretty - prints that assembly format.
void print_cuda_gpu_source_kernels(const std::string &str) {
Expand Down Expand Up @@ -1521,6 +1534,7 @@ class HTMLCodePrinter : public IRVisitor {

// Add a button to jump to this producer/consumer in the viz
print_visualization_button("prodcons-viz-" + std::to_string(id));
print_assembly_button(op);

// Open code block to hold function body
print_html_element("span", "matched", "{");
Expand Down Expand Up @@ -1583,6 +1597,7 @@ class HTMLCodePrinter : public IRVisitor {

// Add a button to jump to this loop in the viz
print_visualization_button("loop-viz-" + std::to_string(id));
print_assembly_button(op);

// Open code block to hold function body
print_html_element("span", "matched", "{");
Expand Down Expand Up @@ -2885,7 +2900,7 @@ class IRVisualizer {
// Generate tab 1/3: Lowered IR code with syntax highlighting in HTML
void generate_ir_tab(const Module &m) {
stream << "<div id='ir-code-tab'>\n";
html_code_printer.print(m);
html_code_printer.print(m, asm_info);
stream << "</div>\n";
}

Expand Down