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

Show CFGs on Nightly #608

Merged
merged 13 commits into from
May 24, 2024
Merged

Show CFGs on Nightly #608

merged 13 commits into from
May 24, 2024

Conversation

ajpal
Copy link
Collaborator

@ajpal ajpal commented May 23, 2024

image

image
image

@ajpal ajpal requested a review from oflatt May 23, 2024 22:11
Copy link
Member

@oflatt oflatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code requires lots of mutating the file system, so I'm getting confused about all the folders. If we can minimize the number of places we specify paths and minimize moving files around that would be great.

Besides that, making clear wrappers for mutating the state of the html page would be good

infra/nightly.sh Outdated
@@ -62,6 +62,9 @@ fi
# Generate latex after running the profiler (depends on profile.json)
./infra/generate_line_counts.py "$NIGHTLY_DIR"

# Generate CFGs for LLVM after running the profiler
./infra/generate_cfgs.py "$NIGHTLY_DIR/data/llvm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better for the profile.py file to call generate_cfgs directly- less bash communication is better

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of disagree? I think the separation is good- profile.py is in charge of running all the benchmarks and stuff, generate_cfgs is in charge of reading that data in and writing pngs out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping that having the code together would mean that there's a single place where we talk about the path to the .ll files
But it's okay if you think this is better

infra/profile.py Outdated
@@ -103,8 +103,9 @@ def should_have_llvm_ir(runMethod):
def dump_llvm_ir(runMethod, benchmark, output_directory):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of dump_llvm_ir? It seems to move .ll files from one folder to another. Shouldn't we just put it in that folder in the first place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


async function showCFGs(benchmark, runMode) {
let pngs = (
await fetchText(`./data/llvm/${benchmark}/${runMode}/png_names.txt`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to just fetch all pngs instead of using png_names.txt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline- this is the least bad option :)

function copyToClipboard(eltId) {
navigator.clipboard.writeText(document.getElementById(eltId).innerText);
function toggleAllPngs(elt) {
const btns = Array.from(document.getElementsByTagName("button"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems kinda scary if we add more buttons to the page later- perhaps just grab all stuff with a drop-down class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to getting elements by class name

if (elt.innerText == "Expand All") {
elt.innerText = "Collapse All";
btns.forEach((btn) => {
btn.innerText = btn.innerText.replace("▶ Show", "▼ Hide");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code for "what happens when you click the drop down" is duplicated between the onclick and this code. That seems not great

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a clean way to de-dupe them because this one is "set all to open" (or closed), while the other is "toggle" so they're not exactly the same logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see-
I think this could be solved by one method that sets it to open or closed. This code would set it to open. The other code would set it to the opposite of the current state

@ajpal ajpal requested a review from oflatt May 24, 2024 21:28
Copy link
Member

@oflatt oflatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Minor comments, not blocking

path = f"{data_dir}/{bench}"
runmodes = os.listdir(path)
for mode in runmodes:
os.chdir(f"{path}/{mode}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't catch this, but I think it's bad practice to change the working directory
Can we build the relative path everywhere instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then all the dot and png files would get created in the top-level dir, which is not what we want


# Delete the -init.ll file (We don't need it for nightly,
# so just reduce the amount of clutter we copy to the nightly machine)
os.system(f"rm {bench}-{mode}-init.ll")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be deleted when it is created instead of here?

infra/profile.py Outdated
@@ -129,17 +123,19 @@ def aggregate(compile_times, bench_times, output_directory):
print("Usage: profile.py <bril_directory> <output_directory>")
exit(1)

profile_path, output_path = os.sys.argv[1:]
# Create tmp directory for intermediate files
os.mkdir(TMP_DIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this script is killed and the tmp dir is still there, does this fail? Do we want to delete it in that case?

@ajpal ajpal merged commit 81cdeef into main May 24, 2024
4 checks passed
@ajpal ajpal deleted the ajpal-cfg branch May 24, 2024 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants