bugfix for target adjustments on target ranges (#20537)

(cherry picked from commit 61c1b71d38)
This commit is contained in:
Greg Becker 2021-01-05 12:27:13 -08:00 committed by Massimiliano Culpo
parent f30fc6cd33
commit 095ace9028
3 changed files with 20 additions and 15 deletions

View file

@ -578,10 +578,14 @@ def adjust_target(self, spec):
True if spec was modified, False otherwise
"""
# To minimize the impact on performance this function will attempt
# to adjust the target only at the very first call. It will just
# return False on subsequent calls. The way this is achieved is by
# initializing a generator and making this function return the next
# answer.
# to adjust the target only at the very first call once necessary
# information is set. It will just return False on subsequent calls.
# The way this is achieved is by initializing a generator and making
# this function return the next answer.
if not (spec.architecture and spec.architecture.concrete):
# Not ready, but keep going because we have work to do later
return True
def _make_only_one_call(spec):
yield self._adjust_target(spec)
while True:
@ -619,9 +623,10 @@ def _adjust_target(self, spec):
if PackagePrefs.has_preferred_targets(spec.name):
default_target = self.target_from_package_preferences(spec)
if current_target != default_target or \
(self.abstract_spec.architecture is not None and
self.abstract_spec.architecture.target is not None):
if current_target != default_target or (
self.abstract_spec and
self.abstract_spec.architecture and
self.abstract_spec.architecture.concrete):
return False
try:

View file

@ -688,13 +688,14 @@ def test_noversion_pkg(self, spec):
with pytest.raises(spack.error.SpackError):
Spec(spec).concretized()
# Include targets to prevent regression on 20537
@pytest.mark.parametrize('spec, best_achievable', [
('mpileaks%gcc@4.4.7', 'core2'),
('mpileaks%gcc@4.8', 'haswell'),
('mpileaks%gcc@5.3.0', 'broadwell'),
('mpileaks%apple-clang@5.1.0', 'x86_64')
('mpileaks%gcc@4.4.7 target=x86_64:', 'core2'),
('mpileaks%gcc@4.8 target=x86_64:', 'haswell'),
('mpileaks%gcc@5.3.0 target=x86_64:', 'broadwell'),
('mpileaks%apple-clang@5.1.0 target=x86_64:', 'x86_64')
])
@pytest.mark.regression('13361')
@pytest.mark.regression('13361', '20537')
def test_adjusting_default_target_based_on_compiler(
self, spec, best_achievable, current_host, mock_targets
):

View file

@ -434,9 +434,8 @@ def load_json():
with open(mock_uarch_json) as f:
return json.load(f)
targets_json = archspec.cpu.schema.LazyDictionary(load_json)
targets = archspec.cpu.microarchitecture.LazyDictionary(
archspec.cpu.microarchitecture._known_microarchitectures)
targets_json = load_json()
targets = archspec.cpu.microarchitecture._known_microarchitectures()
yield targets_json, targets