Skip to content

Commit 643972b

Browse files
committed
Avoid environment variables in polybench by letting suites specify additional polybench args
1 parent d45cb82 commit 643972b

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

truffle/mx.truffle/mx_polybench/model.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ class PolybenchBenchmarkSuiteEntry(NamedTuple):
151151
runner: Optional[PolybenchBenchmarkSuiteRunner]
152152
tags: Set[str]
153153
suppress_validation_warnings: bool
154+
additional_polybench_args: List[str]
154155

155156
def validate(self) -> Optional[str]:
156157
"""Ensures this suite can run. Returns an error string otherwise."""
@@ -436,7 +437,11 @@ def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
436437
java_distributions = _get_java_distributions(resolved_benchmark)
437438
vm_args = mx.get_runtime_jvm_args(names=java_distributions) + self.vmArgs(bmSuiteArgs)
438439
mx_truffle.enable_truffle_native_access(vm_args)
439-
polybench_args = ["--path=" + resolved_benchmark.absolute_path] + self.runArgs(bmSuiteArgs)
440+
polybench_args = (
441+
["--path=" + resolved_benchmark.absolute_path]
442+
+ self.runArgs(bmSuiteArgs)
443+
+ resolved_benchmark.suite.additional_polybench_args
444+
)
440445
return vm_args + [PolybenchBenchmarkSuite.POLYBENCH_MAIN] + polybench_args
441446

442447
def runAndReturnStdOut(self, benchmarks, bmSuiteArgs):
@@ -707,6 +712,7 @@ def register_polybench_benchmark_suite(
707712
runner: Optional[PolybenchBenchmarkSuiteRunner] = None,
708713
tags: Optional[Set[str]] = None,
709714
suppress_validation_warnings: bool = False,
715+
additional_polybench_args: Optional[List[str]] = None,
710716
):
711717
"""
712718
Registers a suite of polybench benchmarks. A polybench suite declares a distribution of benchmark files and the
@@ -730,6 +736,8 @@ def register_polybench_benchmark_suite(
730736
input format as the "mx polybench" command).
731737
:param tags: The set of tags supported by the runner.
732738
:param suppress_validation_warnings: Whether to suppress warning messages when the suite specification does not validate.
739+
:param additional_polybench_args: An optional list of arguments to always pass to the benchmark launcher (e.g., to
740+
specify a load path for benchmark sources).
733741
"""
734742
check_late_registration(f"Polybench benchmark suite {name}")
735743
if isinstance(benchmark_file_filter, str):
@@ -750,6 +758,7 @@ def register_polybench_benchmark_suite(
750758
runner=runner,
751759
tags=tags if tags is not None else set(),
752760
suppress_validation_warnings=suppress_validation_warnings,
761+
additional_polybench_args=additional_polybench_args or [],
753762
)
754763
if name in _polybench_benchmark_suite_registry:
755764
mx.abort(

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,24 +260,12 @@ protected void validateArguments(Map<String, String> polyglotOptions) {
260260
@Override
261261
protected void launch(Context.Builder contextBuilder) {
262262
if (config.isSingleEngine()) {
263-
setEnv(contextBuilder);
264263
runHarness(contextBuilder, config.evalSourceOnlyDefault, 0);
265264
} else {
266265
multiEngineLaunch(contextBuilder);
267266
}
268267
}
269268

270-
private void setEnv(Context.Builder contextBuilder) {
271-
if ("python".equals(getLanguageId(config.path))) {
272-
String pythonpath = System.getenv("POLYBENCH_PYTHONPATH");
273-
if (pythonpath != null) {
274-
contextBuilder.option("python.PythonPath", pythonpath);
275-
} else {
276-
log("WARNING: running Python benchmark but Python path was not set. Consider setting the POLYBENCH_PYTHONPATH environment variable.");
277-
}
278-
}
279-
}
280-
281269
private void multiEngineLaunch(Context.Builder contextBuilder) {
282270
if (config.multiEngine.sharedEngine) {
283271
contextBuilder.engine(Engine.newBuilder().allowExperimentalOptions(true).options(config.multiEngine.engineOptions).build());

0 commit comments

Comments
 (0)