Skip to content

Commit 72e4471

Browse files
committed
Detect bad PGO usage
1 parent c882162 commit 72e4471

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

truffle/mx.truffle/mx_polybench/command.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#
4141
import argparse
4242
import contextlib
43+
import os
4344
import shlex
4445
from argparse import ArgumentParser
4546
from enum import Enum
@@ -247,7 +248,9 @@ class VMFeature(Enum):
247248
def _get_vm_features(args) -> Set[VMFeature]:
248249
def require_native(feature_name):
249250
if not args.is_native:
250-
mx.abort(f"Feature {feature_name} is only supported on native runs, but native mode is not selected.")
251+
mx.abort(
252+
f"Feature {feature_name} is only supported on native runs, but native mode is not selected (enable native mode with --native)."
253+
)
251254

252255
result = set()
253256
if args.is_native:
@@ -264,21 +267,21 @@ def require_native(feature_name):
264267
def _run_benchmark_pattern(args):
265268
arguments_spec = PolybenchArgumentsSpecification.parse(args.benchmark_arguments)
266269
run_spec = PolybenchRunSpecification(args.benchmarks, _get_vm_features(args), arguments_spec)
267-
_validate_jdk(run_spec.is_native())
270+
_validate_jdk(run_spec)
268271
mx.logv(f"Performing polybench run: {run_spec}")
269272
_run_specification(
270273
run_spec, pattern_is_glob=args.pattern_is_glob, dry_run=args.dry_run, reuse_disk_images=args.reuse_disk_images
271274
)
272275

273276

274-
def _validate_jdk(is_native: bool) -> mx.JDKConfig:
277+
def _validate_jdk(run_spec: "PolybenchRunSpecification") -> mx.JDKConfig:
275278
jdk = mx.get_jdk()
279+
rerun_details = (
280+
'You can change the JDK using "mx --java-home $GRAALVM_HOME", where GRAALVM_HOME points to a downloaded GraalVM release '
281+
'(or a GraalVM built from source, e.g., with "mx -p /vm --env ce build").'
282+
)
276283
if not mx_sdk.GraalVMJDKConfig.is_graalvm(jdk.home):
277-
rerun_details = (
278-
'You can change the JDK using "mx --java-home $GRAALVM_HOME", where GRAALVM_HOME points to a downloaded GraalVM release '
279-
'(or a GraalVM built from source, e.g., with "mx -p /vm --env ce build").'
280-
)
281-
if is_native:
284+
if run_spec.is_native:
282285
mx.abort(
283286
f"Polybench was invoked with a non-Graal JDK ({jdk.home}), but a native image run was requested. "
284287
f"Re-run using a Graal JDK. " + rerun_details
@@ -288,10 +291,21 @@ def _validate_jdk(is_native: bool) -> mx.JDKConfig:
288291
f"Polybench is intended to run on a Graal JDK, but it was invoked with a non-Graal JDK ({jdk.home}). "
289292
f"If you encounter issues, consider re-running using a GraalVM release. " + rerun_details
290293
)
294+
295+
if VMFeature.PGO in run_spec.vm_features and not _check_vm_is_enterprise(jdk.home):
296+
mx.abort(
297+
"PGO was requested, but the Graal JDK specified does not appear to support PGO. Re-run using an Oracle GraalVM. "
298+
+ rerun_details
299+
)
300+
291301
mx.logv(f"Using GraalVM at {jdk.home}")
292302
return jdk
293303

294304

305+
def _check_vm_is_enterprise(jdk_home):
306+
return os.path.exists(os.path.join(jdk_home, "lib", "svm", "builder", "svm-enterprise.jar"))
307+
308+
295309
def _parse_mx_benchmark_pattern(pattern: str, pattern_is_glob: bool) -> str:
296310
if ":" in pattern:
297311
message = f'Invalid benchmark pattern "{pattern}".'

0 commit comments

Comments
 (0)