Skip to content

Commit 5e505f5

Browse files
committed
Add support for wasm polybench benchmark configuration
1 parent c413cdb commit 5e505f5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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

Lines changed: 12 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,17 @@ private void parseBenchSpecificSummary(Value benchmark) throws InvalidObjectExce
131132
}
132133
}
133134

135+
private 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+
return null;
144+
}
145+
134146
@Override
135147
public String toString() {
136148
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.

0 commit comments

Comments
 (0)