Skip to content

Commit

Permalink
[GR-58270] Resolve VMs with dynamically generated vm configs.
Browse files Browse the repository at this point in the history
PullRequest: mx/1837
  • Loading branch information
farquet committed Nov 4, 2024
2 parents f51e183 + 3578cb2 commit 76b13a9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
16 changes: 8 additions & 8 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+19-2105", "platformspecific": true, "extrabundles": ["static-libs"]},
"galahad-jdk": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+21-2436", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk17": {"name": "jpg-jdk", "version": "17.0.7", "build_id": "jdk-17.0.7+8", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-17": {"name": "labsjdk", "version": "ce-17.0.7+4-jvmci-23.1-b02", "platformspecific": true },
Expand Down Expand Up @@ -45,13 +45,13 @@

"oraclejdk23": {"name": "jpg-jdk", "version": "23", "build_id": "jdk-23+37", "platformspecific": true, "extrabundles": ["static-libs"]},

"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+19", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+19-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+19-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+21", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+21-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+21-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18215,7 +18215,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("7.33.2") # [GR-59265] Mx Unittest Can't Find test Classes With @Theory Annotation Only
version = VersionSpec("7.34.0") # [GR-58270] Allow syntactic sugar to configure benchmark VM configs

_mx_start_datetime = datetime.utcnow()

Expand Down
28 changes: 27 additions & 1 deletion src/mx/_impl/mx_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ def get_vm_from_suite_args(self, bmSuiteArgs, hosted=False, quiet=False, host_vm
return vm_object

def add_vm(self, vm, suite=None, priority=0):
if not vm.canonical_configuration:
mx.abort(f"{vm.__class__.__name__}({vm.name()}, {vm.config_name()}) got configured with a non-canonical vm config, which is not allowed!")
key = (vm.name(), vm.config_name())
if key in self._vms:
mx.abort(f"{self.vm_type_name} and config '{key}' already exist.")
Expand All @@ -428,7 +430,15 @@ def add_vm(self, vm, suite=None, priority=0):
self._vms_priority[key] = priority

def get_vm(self, vm_name, vm_config):
key = (vm_name, vm_config)
resolved_name = None
for (candidate_vm_name, candidate_vm_config), candidate_vm in self._vms.items():
canonical_name = candidate_vm.canonical_config_name(vm_config)
if vm_name == candidate_vm_name and canonical_name == candidate_vm_config:
resolved_name = candidate_vm_config
if vm_config != canonical_name:
mx.log(f"Canonicalized the '{vm_config}' vm config to: {resolved_name}")
break
key = (vm_name, resolved_name or vm_config)
if key not in self._vms:
mx.abort(f"{self.vm_type_name} and config '{key}' do not exist.\n{self.get_available_vm_configs_help()}")
return self._vms[key]
Expand Down Expand Up @@ -1921,6 +1931,22 @@ def config_name(self):
"""Returns the config name for a VM (e.g. graal-core or graal-enterprise)."""
raise NotImplementedError()

@staticmethod
def canonical_config_name(config_name):
"""
Some VMs may allow different names to be aliases for the exact same configuration.
This method will return the canonical version of the configuration in this case.
It just returns the provided config otherwise.
"""
return config_name

@property
def canonical_configuration(self):
"""
:return: returns True if a VM got configured using a canonical form (i.e. without syntactic sugar).
"""
return getattr(self, '_canonical_configuration', True)

def extract_vm_info(self, args=None):
"""Extract vm information."""
pass
Expand Down

0 comments on commit 76b13a9

Please sign in to comment.