Skip to content

Commit

Permalink
Merge pull request #612 from egraphs-good/ajpal-loop-benchmarks
Browse files Browse the repository at this point in the history
Filter benchmarks by looped
  • Loading branch information
ajpal committed May 28, 2024
2 parents f7b1b09 + 70f1d1b commit b8d3596
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
27 changes: 18 additions & 9 deletions infra/nightly-resources/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ async function load_llvm() {
const benchmark = params.get("benchmark");
const runMode = params.get("runmode");

document.title = `${benchmark} | ${runMode}`;
document.getElementById("llvm-header").innerText =
`Benchmark: ${benchmark} | Run Mode: ${runMode}`;

if (!benchmark || !runMode) {
console.error("missing query params, this probably shouldn't happen");
return;
Expand Down Expand Up @@ -59,16 +63,21 @@ function selectAllModes(enabled) {
refreshView();
}

function selectAllBenchmarks(enabled) {
function selectAllBenchmarks(enabled, category) {
const checkboxContainer = document.getElementById("benchmarkCheckboxes");
Array.from(checkboxContainer.getElementsByTagName("input")).forEach(
(checkbox) => {
checkbox.checked = enabled;
enabled
? GLOBAL_DATA.enabledBenchmarks.add(checkbox.id)
: GLOBAL_DATA.enabledBenchmarks.delete(checkbox.id);
},
);
let checkboxes = Array.from(checkboxContainer.getElementsByTagName("input"));
if (category === "looped") {
const loopedBenchmarks = new Set(
GLOBAL_DATA.currentRun.filter((x) => x.looped).map((x) => x.benchmark),
);
checkboxes = checkboxes.filter((x) => loopedBenchmarks.has(x.id));
}
checkboxes.forEach((checkbox) => {
checkbox.checked = enabled;
enabled
? GLOBAL_DATA.enabledBenchmarks.add(checkbox.id)
: GLOBAL_DATA.enabledBenchmarks.delete(checkbox.id);
});
refreshView();
}

Expand Down
7 changes: 5 additions & 2 deletions infra/nightly-resources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ <h2>Profile</h2>
<div class="filters">
<div>
<p>Benchmarks</p>
<button onclick="selectAllBenchmarks(true)">Select All</button>
<button onclick="selectAllBenchmarks(false)">Select None</button>
<button onclick="selectAllBenchmarks(true, 'all')">Select All</button>
<button onclick="selectAllBenchmarks(false, 'all')">Deselect All</button>
<br />
<button onclick="selectAllBenchmarks(true, 'looped')">Select All Looped</button>
<button onclick="selectAllBenchmarks(false, 'looped')">Deselect All Looped</button>
</div>
<div id="benchmarkCheckboxes"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion infra/nightly-resources/llvm.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<title>LLVM</title>

<body onload="load_llvm()">
<h2>LLVM</h2>
<h2 id="llvm-header">LLVM</h2>
<button class="collapsible" onclick="toggleAllPngs(this)">Expand All</button>
<div id="llvm-cfg"></div>
<button type="button" class="collapsible" onclick="toggle(this, '\u25B6 Show LLVM', '\u25BC Hide LLVM')">\u25BC Hide LLVM</button>
Expand Down
15 changes: 12 additions & 3 deletions infra/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,21 @@ def should_have_llvm_ir(runMethod):
]

# aggregate all profile info into a single json array.
def aggregate(compile_times, bench_times):
def aggregate(compile_times, bench_times, looped):
res = []

for path in sorted(compile_times.keys()):
name = path.split("/")[-2]
runMethod = path.split("/")[-1]
result = {"runMethod": runMethod, "benchmark": name, "hyperfine": bench_times[path], "compileTime": compile_times[path]}
result = {"runMethod": runMethod, "benchmark": name, "hyperfine": bench_times[path], "compileTime": compile_times[path], "looped": looped[name]}

res.append(result)
return res

def is_looped(bril_file):
with open(bril_file) as f:
txt = f.read()
return "orig_main" in txt

if __name__ == '__main__':
# expect two arguments
Expand All @@ -138,6 +142,11 @@ def aggregate(compile_times, bench_times):
else:
profiles = [bril_dir]

looped = {}
for profile in profiles:
name = profile.split("/")[-1][:-len(".bril")]
looped[name] = is_looped(profile)

to_run = []
index = 0
total = len(profiles) * len(treatments)
Expand Down Expand Up @@ -181,7 +190,7 @@ def aggregate(compile_times, bench_times):
(path, _bench_data) = res
bench_data[path] = _bench_data

nightly_data = aggregate(compile_times, bench_data)
nightly_data = aggregate(compile_times, bench_data, looped)
with open(f"{DATA_DIR}/profile.json", "w") as profile:
json.dump(nightly_data, profile, indent=2)

Expand Down

0 comments on commit b8d3596

Please sign in to comment.