Skip to content

Commit 33c7778

Browse files
committed
Adapt polybench to use --prebuilt-vm flag
1 parent 39bb0ab commit 33c7778

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

truffle/mx.truffle/mx_polybench/command.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,17 @@ class PolybenchRunSpecification(NamedTuple):
368368
def is_native(self) -> bool:
369369
return VMFeature.NATIVE in self.vm_features
370370

371-
def jvm_name(self) -> str:
372-
return "native-image-java-home" if self.is_native() else "java-home"
371+
def jvm_and_config(self) -> Tuple[str, str]:
372+
if self.is_native():
373+
# The VM config misses the 'ce'/'ee' suffix. The PolybenchBenchmarkSuite
374+
# patches this in the output data.
375+
return "native-image", self._native_vm_config()
376+
else:
377+
# The vanilla configuration does not inject any additional VM arguments.
378+
# The PolybenchBenchmarkSuite overwrites this config in the output data.
379+
return "server", "vanilla"
373380

374-
def jvm_config(self) -> str:
381+
def _native_vm_config(self) -> str:
375382
features = []
376383
if VMFeature.G1GC in self.vm_features:
377384
features.append("g1gc")
@@ -387,10 +394,11 @@ def _run_specification(
387394
reuse_disk_images: bool = False,
388395
):
389396
pattern = _parse_mx_benchmark_pattern(spec.pattern, pattern_is_glob)
397+
jvm_name, jvm_config = spec.jvm_and_config()
390398
mx_benchmark_args = (
391399
[f"polybench:{pattern}"]
392400
+ spec.arguments.mx_benchmark_args
393-
+ ["--", f"--jvm={spec.jvm_name()}", f"--jvm-config={spec.jvm_config()}"]
401+
+ ["--", f"--jvm={jvm_name}", f"--jvm-config={jvm_config}", "--prebuilt-vm"]
394402
+ spec.arguments.vm_args
395403
+ ["--"]
396404
+ spec.arguments.polybench_args

truffle/mx.truffle/mx_polybench/model.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,48 @@ def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
461461
return vm_args + [PolybenchBenchmarkSuite.POLYBENCH_MAIN] + polybench_args
462462

463463
def runAndReturnStdOut(self, benchmarks, bmSuiteArgs):
464-
"""Delegates to the super implementation then injects engine.config into every datapoint."""
465464
ret_code, out, dims = super().runAndReturnStdOut(benchmarks, bmSuiteArgs)
466-
dims["engine.config"] = self._get_mode(bmSuiteArgs)
465+
host_vm_config = self._infer_host_vm_config(bmSuiteArgs, dims)
466+
guest_vm, guest_vm_config = self._infer_guest_vm_info(benchmarks, bmSuiteArgs)
467+
dims.update(
468+
{
469+
"host-vm-config": host_vm_config,
470+
"guest-vm": guest_vm,
471+
"guest-vm-config": guest_vm_config,
472+
}
473+
)
467474
return ret_code, out, dims
468475

476+
def _infer_host_vm_config(self, bm_suite_args, dims):
477+
edition = dims.get("platform.graalvm-edition", "unknown").lower()
478+
if edition not in ["ce", "ee"] or not dims.get("platform.prebuilt-vm", False):
479+
raise ValueError(f"Polybench should only run with a prebuilt GraalVM. Dimensions found: {dims}")
480+
481+
if self.is_native_mode(bm_suite_args):
482+
# patch ce/ee suffix
483+
existing_config = dims["host-vm-config"]
484+
existing_edition = existing_config.split("-")[-1]
485+
if existing_edition in ["ce", "ee"]:
486+
assert (
487+
existing_edition == edition
488+
), f"Existing host-vm-config {existing_config} conflicts with GraalVM edition {edition}"
489+
return existing_config
490+
return dims["host-vm-config"] + "-" + edition
491+
else:
492+
# assume config used when building a GraalVM distribution
493+
return "graal-enterprise-libgraal-pgo" if edition == "ee" else "graal-core-libgraal"
494+
495+
def _infer_guest_vm_info(self, benchmarks, bm_suite_args) -> Tuple[str, str]:
496+
resolved_benchmark = self._resolve_current_benchmark(benchmarks)
497+
guest_vm = "-".join(sorted(resolved_benchmark.suite.languages))
498+
if "--engine.Compilation=false" in self.runArgs(
499+
bm_suite_args
500+
) or "-Dpolyglot.engine.Compilation=false" in self.vmArgs(bm_suite_args):
501+
guest_vm_config = "interpreter"
502+
else:
503+
guest_vm_config = "default"
504+
return guest_vm, guest_vm_config
505+
469506
def rules(self, output, benchmarks, bmSuiteArgs):
470507
metric_name = PolybenchBenchmarkSuite._get_metric_name(output)
471508
if metric_name is None:
@@ -586,14 +623,6 @@ def _get_metric_name(bench_output) -> Optional[str]:
586623
)
587624
return metric_name
588625

589-
def _get_mode(self, bmSuiteArgs):
590-
"""Determines the "mode" to report in benchmark data points."""
591-
if "--engine.Compilation=false" in self.runArgs(
592-
bmSuiteArgs
593-
) or "-Dpolyglot.engine.Compilation=false" in self.vmArgs(bmSuiteArgs):
594-
return "interpreter"
595-
return "standard"
596-
597626

598627
class ExcludeWarmupRule(mx_benchmark.StdOutRule):
599628
"""Rule that behaves as the StdOutRule, but skips input until a certain pattern."""

0 commit comments

Comments
 (0)