Skip to content

Commit 799587c

Browse files
committed
[GR-70210] Outlier filtering of polybench wasm benchmarks.
PullRequest: graal/22296
2 parents 712ca0e + e887b48 commit 799587c

File tree

13 files changed

+26863
-28078
lines changed

13 files changed

+26863
-28078
lines changed

truffle/mx.truffle/mx_polybench/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ def _infer_guest_vm_info(self, benchmarks, bm_suite_args) -> Tuple[str, str]:
501501
guest_vm = "graal-js"
502502
elif "python" in resolved_benchmark.suite.languages:
503503
guest_vm = "graalpython"
504+
elif "wasm" in resolved_benchmark.suite.languages:
505+
guest_vm = "wasm"
504506
else:
505507
guest_vm = "none"
506508
if "--engine.Compilation=false" in self.runArgs(

truffle/src/org.graalvm.polybench/src/org/graalvm/polybench/Config.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void parseBenchSpecificDefaults(Value benchmark) throws InvalidObjectExce
104104
private void parseBenchSpecificSummary(Value benchmark) throws InvalidObjectException {
105105
if (!benchmark.hasMember("summary")) {
106106
// No 'summary' member provided in the benchmark
107+
summary = parseFallbackBenchSpecificSummary(benchmark);
107108
return;
108109
}
109110
Value summaryMember = benchmark.getMember("summary");
@@ -131,6 +132,18 @@ private void parseBenchSpecificSummary(Value benchmark) throws InvalidObjectExce
131132
}
132133
}
133134

135+
private static Summary parseFallbackBenchSpecificSummary(Value benchmark) {
136+
if (benchmark.hasMember(OutlierRemovalAverageSummary.class.getSimpleName())) {
137+
double lowerThreshold = benchmark.getMember(OutlierRemovalAverageSummary.class.getSimpleName() + "LowerThreshold").execute().asDouble();
138+
double upperThreshold = benchmark.getMember(OutlierRemovalAverageSummary.class.getSimpleName() + "UpperThreshold").execute().asDouble();
139+
return new OutlierRemovalAverageSummary(lowerThreshold, upperThreshold);
140+
} else if (benchmark.hasMember(AverageSummary.class.getSimpleName())) {
141+
return new AverageSummary();
142+
}
143+
// defaulting to averaging if the aggregation strategy is not specified
144+
return new AverageSummary();
145+
}
146+
134147
@Override
135148
public String toString() {
136149
String config = "metric: " + metric.name() + " (" + metric.unit() + ")" + "\n" +

truffle/src/org.graalvm.polybench/src/org/graalvm/polybench/PolyBenchLauncher.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ private EvalResult evalSource(Context context) {
394394
} finally {
395395
config.metric.afterLoad(config);
396396
}
397+
if (language.equals("wasm")) {
398+
result = result.newInstance();
399+
}
397400
return new EvalResult(language, source.getName(), source.hasBytes(), source.getLength(), result);
398401
}
399402
}
@@ -475,6 +478,9 @@ private void runHarness(Context.Builder contextBuilder, boolean evalSourceOnly,
475478
log("::: Bench specific options :::");
476479
if (evalResult.value instanceof Value) {
477480
Value value = (Value) evalResult.value;
481+
if (evalResult.languageId.equals("wasm")) {
482+
value = value.getMember("exports");
483+
}
478484
config.parseBenchSpecificDefaults(value);
479485
config.metric.parseBenchSpecificOptions(value);
480486
}
@@ -556,7 +562,7 @@ private Workload lookup(Context context, String languageId, Object evalSource, S
556562
// language-specific lookup
557563
switch (languageId) {
558564
case "wasm":
559-
result = evalSourceValue.newInstance().getMember("exports").getMember(memberName);
565+
result = evalSourceValue.getMember("exports").getMember(memberName);
560566
break;
561567
case "java":
562568
// Espresso doesn't provide methods as executable values.
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
## Benchmark generation
22

3-
The `wat` files in this folder were generated from the provided C sources (which are included for reproducibility). To re-generate the `wat` files, one has to use the `clang` compiler contained in the `wasi-sdk` and `wasm2wat` from WABT. Follow the instructions in [the WASM README.](../../README.md)
4-
5-
And then proceed by running the following commands:
3+
The `wat` files in this folder were generated from the provided C sources (which are included for reproducibility). To re-generate the `wat` files, you can use the provided `regenerate_wat.sh` script. First, ensure that `WASI_SDK` and `WABT_DIR` are set in your environment, then run:
64
```
7-
$WASI_SDK/bin/clang -Wl,--export="run" -O3 -o richards.wasm richards.c
8-
$WABT_DIR/wasm2wat -o richards.wat richards.wasm
5+
./regenerate_wat.sh
96
```
7+
This script uses `clang` from `WASI_SDK` and `wasm2wat` from `WABT_DIR` to regenerate all `.wat` files from the C sources.
108

11-
In the case of `sieve`, an additional linker flag must be passed to clang, since the default stack size (64kb) is too small.
12-
```
13-
$WASI_SDK/bin/clang -Wl,-export="run" -Wl,-z,stack-size=4194304 -O3 -o sieve.wasm sieve.c
14-
$WABT_DIR/wasm2wat -o sieve.wat sieve.wasm
15-
```
9+
Follow the instructions in [the WASM README.](../../README.md)

wasm/benchmarks/interpreter/deltablue.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,17 @@ void ProjectionTest(int n)
10991099
List_Destroy(dests);
11001100
}
11011101

1102+
void OutlierRemovalAverageSummary() {
1103+
}
1104+
1105+
double OutlierRemovalAverageSummaryLowerThreshold() {
1106+
return 0.0;
1107+
}
1108+
1109+
double OutlierRemovalAverageSummaryUpperThreshold() {
1110+
return 0.5;
1111+
}
1112+
11021113
int run()
11031114
{
11041115
int n = 1000;

0 commit comments

Comments
 (0)