Skip to content

Commit ec1f2ab

Browse files
committed
Migrate espresso to unchained polybench
1 parent f1be56b commit ec1f2ab

File tree

8 files changed

+112
-2
lines changed

8 files changed

+112
-2
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

espresso/mx.espresso/mx_espresso.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import mx_subst
3737
import mx_util
3838
import mx_gate
39-
import mx_espresso_benchmarks # pylint: disable=unused-import
39+
import mx_espresso_benchmarks
4040
import mx_sdk_vm
4141
import mx_sdk_vm_impl
4242
from mx_gate import Task, add_gate_runner
@@ -99,7 +99,7 @@ def _espresso_standalone_command(args, with_sulong=False, allow_jacoco=True, jdk
9999
)
100100

101101
def javavm_deps():
102-
result = [espresso_resources_suite() + ':ESPRESSO_RUNTIME_RESOURCES']
102+
result = [espresso_runtime_resources_distribution()]
103103
if mx.suite('truffle-enterprise', fatalIfMissing=False):
104104
result.append('truffle-enterprise:TRUFFLE_ENTERPRISE')
105105
if mx.suite('regex', fatalIfMissing=False):
@@ -210,6 +210,8 @@ def _run_verify_imports(s):
210210
# Find invalid files
211211
invalid_files = []
212212
for project in s.projects:
213+
if getattr(project, "skipVerifyImports", False):
214+
continue
213215
output_root = project.get_output_root()
214216
for src_dir in project.source_dirs():
215217
if src_dir.startswith(output_root):
@@ -579,6 +581,8 @@ def mx_register_dynamic_suite_constituents(register_project, register_distributi
579581
community_dist_name=f'GRAALVM_ESPRESSO_COMMUNITY_JAVA{java_home_dep.major_version}{dist_suffix}',
580582
enterprise_dist_name=f'GRAALVM_ESPRESSO_JAVA{java_home_dep.major_version}{dist_suffix}'))
581583

584+
mx_espresso_benchmarks.mx_register_dynamic_suite_constituents(register_project, register_distribution)
585+
582586

583587
def espresso_resources_suite(java_home_dep=None):
584588
# Espresso resources are in the CE/EE suite depending on espresso java home type
@@ -590,6 +594,10 @@ def espresso_resources_suite(java_home_dep=None):
590594
return 'espresso'
591595

592596

597+
def espresso_runtime_resources_distribution(java_home_dep=None):
598+
return espresso_resources_suite(java_home_dep=java_home_dep) + ':ESPRESSO_RUNTIME_RESOURCES'
599+
600+
593601
def register_espresso_runtime_resources(register_project, register_distribution, suite):
594602
if espresso_resources_suite() != suite.name:
595603
return

espresso/mx.espresso/mx_espresso_benchmarks.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,108 @@
2020
# or visit www.oracle.com if you need additional information or have any
2121
# questions.
2222
#
23+
import os
2324
import re
2425
from abc import ABCMeta, abstractmethod
2526

2627
import mx
2728
import mx_benchmark
2829
import mx_espresso
30+
import mx_jardistribution
31+
import mx_polybench
2932

3033
from mx_benchmark import GuestVm, JavaVm, OutputCapturingJavaVm
3134
from mx_sdk_benchmark import _daCapoScalaConfig
3235

3336
_suite = mx.suite('espresso')
3437

3538

39+
def mx_register_dynamic_suite_constituents(register_project, register_distribution):
40+
benchmark_dist = _suite.dependency("ESPRESSO_POLYBENCH_BENCHMARKS")
41+
polybench_benchmarks = os.path.join(_suite.dir, 'benchmarks', 'interpreter')
42+
for f in os.listdir(polybench_benchmarks):
43+
if os.path.isdir(os.path.join(polybench_benchmarks, f)) and not f.startswith("."):
44+
main_class = os.path.basename(f)
45+
simple_name = main_class.split(".")[-1]
46+
47+
project_name = 'benchmarks.interpreter.espresso.' + simple_name.lower()
48+
register_project(mx.JavaProject(
49+
suite=_suite,
50+
subDir=None,
51+
srcDirs=[os.path.join(_suite.dir, 'benchmarks', 'interpreter', main_class)],
52+
deps=[],
53+
name=project_name,
54+
d=os.path.join(_suite.dir, 'benchmarks', 'interpreter', main_class),
55+
javaCompliance='11+',
56+
workingSets=None,
57+
testProject=True,
58+
eclipseformat=False,
59+
skipVerifyImports=True,
60+
# javac and JDT both produce warnings on these sources. suppress javac warnings and avoid JDT.
61+
forceJavac=True,
62+
checkstyleProj=project_name,
63+
**{
64+
"javac.lint.overrides": "none",
65+
}
66+
))
67+
68+
dist_name = 'ESPRESSO_POLYBENCH_BENCHMARK_' + simple_name.upper()
69+
jar_dist = mx_jardistribution.JARDistribution(
70+
suite=_suite,
71+
subDir=None,
72+
srcDirs=[''],
73+
sourcesPath=None,
74+
deps=[project_name],
75+
mainClass=main_class,
76+
name=dist_name,
77+
path='',
78+
platformDependent=False,
79+
distDependencies=[],
80+
javaCompliance='11+',
81+
excludedLibs=[],
82+
workingSets=None,
83+
theLicense=None,
84+
testDistribution=True,
85+
maven=False,
86+
)
87+
register_distribution(jar_dist)
88+
89+
benchmark_dist.layout[f'./interpreter/{simple_name}.jar'] = [
90+
f'dependency:{dist_name}/*.jar']
91+
benchmark_dist.buildDependencies.append(dist_name)
92+
93+
espresso_runtime_resources_distribution = mx_espresso.espresso_runtime_resources_distribution()
94+
mx_polybench.register_polybench_language(mx_suite=_suite, language="espresso",
95+
distributions=["ESPRESSO", "ESPRESSO_LIBS_RESOURCES",
96+
espresso_runtime_resources_distribution, "truffle:TRUFFLE_NFI_LIBFFI"])
97+
98+
def espresso_polybench_runner(polybench_run: mx_polybench.PolybenchRunFunction, tags) -> None:
99+
if "gate" in tags:
100+
polybench_run(["--jvm", "interpreter/*.jar", "--experimental-options", "--engine.Compilation=false", "-w", "1", "-i", "1"])
101+
polybench_run(["--native", "interpreter/*.jar", "--experimental-options", "--engine.Compilation=false", "-w", "1", "-i", "1"])
102+
if "benchmark" in tags:
103+
polybench_run(["--jvm", "interpreter/*.jar", "--experimental-options", "--engine.Compilation=false"])
104+
polybench_run(["--native", "interpreter/*.jar", "--experimental-options", "--engine.Compilation=false"])
105+
polybench_run(["--jvm", "interpreter/*.jar"])
106+
polybench_run(["--native", "interpreter/*.jar"])
107+
polybench_run(["--jvm", "interpreter/*.jar", "--metric=metaspace-memory"])
108+
polybench_run(["--jvm", "interpreter/*.jar", "--metric=application-memory"])
109+
polybench_run(["--jvm", "interpreter/*.jar", "--metric=allocated-bytes", "-w", "40", "-i", "10", "--experimental-options", "--engine.Compilation=false"])
110+
polybench_run(["--native", "interpreter/*.jar", "--metric=allocated-bytes", "-w", "40", "-i", "10", "--experimental-options", "--engine.Compilation=false"])
111+
polybench_run(["--jvm", "interpreter/*.jar", "--metric=allocated-bytes", "-w", "40", "-i", "10"])
112+
polybench_run(["--native", "interpreter/*.jar", "--metric=allocated-bytes", "-w", "40", "-i", "10"])
113+
if "instructions" in tags:
114+
assert mx_polybench.is_enterprise()
115+
fork_count_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "polybench-fork-counts.json")
116+
polybench_run(["--native", "interpreter/*.jar", "--metric=instructions", "--experimental-options", "--engine.Compilation=false",
117+
"--mx-benchmark-args", "--fork-count-file", fork_count_file])
118+
119+
mx_polybench.register_polybench_benchmark_suite(mx_suite=_suite, name="espresso", languages=["espresso"],
120+
benchmark_distribution=benchmark_dist.name,
121+
benchmark_file_filter=".*jar", runner=espresso_polybench_runner,
122+
tags={"gate", "benchmark", "instructions"})
123+
124+
36125
class EspressoStandaloneVm(OutputCapturingJavaVm, metaclass=ABCMeta):
37126
def __init__(self, config_name, options):
38127
super().__init__()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"polybench:interpreter/DeltaBlue.jar": 5,
3+
"polybench:interpreter/Fibonacci.jar": 5,
4+
"polybench:interpreter/Richards.jar": 5,
5+
"polybench:interpreter/Sieve.jar": 5
6+
}

espresso/mx.espresso/suite.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,5 +919,12 @@
919919
"dynamicDistDependencies": "jvm_standalone_deps",
920920
"maven": False,
921921
},
922+
923+
"ESPRESSO_POLYBENCH_BENCHMARKS": {
924+
"description": "Distribution for Espresso polybench benchmarks",
925+
"layout": {
926+
# Layout is dynamically populated in mx_register_dynamic_suite_constituents
927+
},
928+
},
922929
}
923930
}

0 commit comments

Comments
 (0)