Fixed target satisfaction and updated tests accordingly
This commit is contained in:
parent
aa28e4e81f
commit
2b4dd8b9af
@ -209,37 +209,6 @@ def concretize_version(self, spec):
|
|||||||
|
|
||||||
return True # Things changed
|
return True # Things changed
|
||||||
|
|
||||||
def class_from_platform_name(self, platform_name):
|
|
||||||
file_path = join_path(spack.platform_path, platform_name)
|
|
||||||
platform_mod = imp.load_source('spack.platforms', file_path + '.py')
|
|
||||||
cls = getattr(platform_mod, mod_to_class(platform_name))
|
|
||||||
|
|
||||||
return cls
|
|
||||||
|
|
||||||
def spec_add_target_from_string(self, spec, target):
|
|
||||||
"""If only a target is provided, spack will assume the default architecture.
|
|
||||||
A platform-target pair can be input delimited by a '-'. If either portion of
|
|
||||||
a platform-target pair is empty, spack will supply a default, in the case of
|
|
||||||
a blank target the default will be dependent on the platform.
|
|
||||||
E.g. x86_64 -> 64 bit x86
|
|
||||||
bgq- -> default bgq target (back end/powerpc)
|
|
||||||
cray-hawswell -> haswell target on cray platform
|
|
||||||
"""
|
|
||||||
if '-' in target:
|
|
||||||
platform, target = target.split('-')
|
|
||||||
else:
|
|
||||||
platform = ''
|
|
||||||
|
|
||||||
if platform != '':
|
|
||||||
cls = self.class_from_platform_name(platform)
|
|
||||||
platform = cls()
|
|
||||||
else:
|
|
||||||
platform = spack.architecture.sys_type()
|
|
||||||
if target != '':
|
|
||||||
spec.target = platform.target(target)
|
|
||||||
else:
|
|
||||||
spec.target = platform.target('default')
|
|
||||||
|
|
||||||
def concretize_target(self, spec):
|
def concretize_target(self, spec):
|
||||||
"""If the spec already has an target and it is a an target type,
|
"""If the spec already has an target and it is a an target type,
|
||||||
return. Otherwise, if it has a target that is a string type, generate a
|
return. Otherwise, if it has a target that is a string type, generate a
|
||||||
@ -251,14 +220,14 @@ def concretize_target(self, spec):
|
|||||||
if isinstance(spec.target,spack.architecture.Target):
|
if isinstance(spec.target,spack.architecture.Target):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.spec_add_target_from_string(spec, spec.target)
|
spec.add_target_from_string(spec, spec.target)
|
||||||
return True #changed
|
return True #changed
|
||||||
|
|
||||||
if spec.root.target:
|
if spec.root.target:
|
||||||
if isinstance(spec.root.target,spack.architecture.Target):
|
if isinstance(spec.root.target,spack.architecture.Target):
|
||||||
spec.target = spec.root.target
|
spec.target = spec.root.target
|
||||||
else:
|
else:
|
||||||
self.spec_add_target_from_string(spec, spec.root.target)
|
spec.add_target_from_string(spec, spec.root.target)
|
||||||
else:
|
else:
|
||||||
platform = spack.architecture.sys_type()
|
platform = spack.architecture.sys_type()
|
||||||
spec.target = platform.target('default')
|
spec.target = platform.target('default')
|
||||||
|
@ -1228,6 +1228,36 @@ def _autospec(self, spec_like):
|
|||||||
return parse_anonymous_spec(spec_like, self.name)
|
return parse_anonymous_spec(spec_like, self.name)
|
||||||
|
|
||||||
|
|
||||||
|
def add_target_from_string(self, target):
|
||||||
|
"""If only a target is provided, spack will assume the default architecture.
|
||||||
|
A platform-target pair can be input delimited by a '-'. If either portion of
|
||||||
|
a platform-target pair is empty, spack will supply a default, in the case of
|
||||||
|
a blank target the default will be dependent on the platform.
|
||||||
|
E.g. x86_64 -> 64 bit x86
|
||||||
|
bgq- -> default bgq target (back end/powerpc)
|
||||||
|
cray-hawswell -> haswell target on cray platform
|
||||||
|
"""
|
||||||
|
if target is None:
|
||||||
|
return
|
||||||
|
if '-' in target:
|
||||||
|
platform, target = target.split('-')
|
||||||
|
else:
|
||||||
|
platform = ''
|
||||||
|
|
||||||
|
if platform != '':
|
||||||
|
# Find the class for the platform name given
|
||||||
|
file_path = join_path(spack.platform_path, platform_name)
|
||||||
|
platform_mod = imp.load_source('spack.platforms', file_path + '.py')
|
||||||
|
cls = getattr(platform_mod, mod_to_class(platform_name))
|
||||||
|
platform = cls()
|
||||||
|
else:
|
||||||
|
platform = spack.architecture.sys_type()
|
||||||
|
if target != '':
|
||||||
|
self.target = platform.target(target)
|
||||||
|
else:
|
||||||
|
self.target = platform.target('default')
|
||||||
|
|
||||||
|
|
||||||
def satisfies(self, other, deps=True, strict=False):
|
def satisfies(self, other, deps=True, strict=False):
|
||||||
"""Determine if this spec satisfies all constraints of another.
|
"""Determine if this spec satisfies all constraints of another.
|
||||||
|
|
||||||
@ -1275,6 +1305,11 @@ def satisfies(self, other, deps=True, strict=False):
|
|||||||
|
|
||||||
# Target satisfaction is currently just class equality.
|
# Target satisfaction is currently just class equality.
|
||||||
# If not strict, None means unconstrained.
|
# If not strict, None means unconstrained.
|
||||||
|
if not isinstance(self.target, spack.architecture.Target):
|
||||||
|
self.add_target_from_string(self.target)
|
||||||
|
if not isinstance(other.target, spack.architecture.Target):
|
||||||
|
other.add_target_from_string(other.target)
|
||||||
|
|
||||||
if self.target and other.target:
|
if self.target and other.target:
|
||||||
if self.target != other.target:
|
if self.target != other.target:
|
||||||
return False
|
return False
|
||||||
|
@ -92,22 +92,16 @@ def test_default_works(self):
|
|||||||
|
|
||||||
|
|
||||||
def test_target_match(self):
|
def test_target_match(self):
|
||||||
pkg = spack.db.get('multimethod=x86_64')
|
platform = spack.architecture.sys_type()
|
||||||
self.assertEqual(pkg.different_by_target(), 'x86_64')
|
targets = platform.targets.values()
|
||||||
|
for target in targets[:-1]:
|
||||||
|
print target
|
||||||
|
pkg = spack.db.get('multimethod='+target.name)
|
||||||
|
self.assertEqual(pkg.different_by_target(), target.name)
|
||||||
|
|
||||||
pkg = spack.db.get('multimethod=ppc64')
|
pkg = spack.db.get('multimethod='+targets[-1].name)
|
||||||
self.assertEqual(pkg.different_by_target(), 'ppc64')
|
|
||||||
|
|
||||||
pkg = spack.db.get('multimethod=ppc32')
|
|
||||||
self.assertEqual(pkg.different_by_target(), 'ppc32')
|
|
||||||
|
|
||||||
pkg = spack.db.get('multimethod=arm64')
|
|
||||||
self.assertEqual(pkg.different_by_target(), 'arm64')
|
|
||||||
|
|
||||||
pkg = spack.db.get('multimethod=macos')
|
|
||||||
self.assertRaises(NoSuchMethodError, pkg.different_by_target)
|
self.assertRaises(NoSuchMethodError, pkg.different_by_target)
|
||||||
|
|
||||||
|
|
||||||
def test_dependency_match(self):
|
def test_dependency_match(self):
|
||||||
pkg = spack.db.get('multimethod^zmpi')
|
pkg = spack.db.get('multimethod^zmpi')
|
||||||
self.assertEqual(pkg.different_by_dep(), 'zmpi')
|
self.assertEqual(pkg.different_by_dep(), 'zmpi')
|
||||||
|
@ -241,9 +241,13 @@ def test_unsatisfiable_compiler_version(self):
|
|||||||
|
|
||||||
|
|
||||||
def test_unsatisfiable_target(self):
|
def test_unsatisfiable_target(self):
|
||||||
set_pkg_dep('mpileaks', 'mpich=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
spec = Spec('mpileaks ^mpich=sles_10_ppc64 ^callpath ^dyninst ^libelf ^libdwarf')
|
if len(platform.targets) > 1:
|
||||||
self.assertRaises(spack.spec.UnsatisfiableTargetSpecError, spec.normalize)
|
first = platform.targets.values()[0].name
|
||||||
|
second = platform.targets.values()[1].name
|
||||||
|
set_pkg_dep('mpileaks', 'mpich='+first)
|
||||||
|
spec = Spec('mpileaks ^mpich='+ second +' ^callpath ^dyninst ^libelf ^libdwarf')
|
||||||
|
self.assertRaises(spack.spec.UnsatisfiableTargetSpecError, spec.normalize)
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_dep(self):
|
def test_invalid_dep(self):
|
||||||
|
@ -111,12 +111,13 @@ def test_satisfies_compiler_version(self):
|
|||||||
|
|
||||||
|
|
||||||
def test_satisfies_target(self):
|
def test_satisfies_target(self):
|
||||||
self.check_satisfies('foo=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib')
|
platform = spack.architecture.sys_type()
|
||||||
self.check_satisfies('foo=bgqos_0', '=bgqos_0')
|
targets = platform.targets.values()
|
||||||
|
for target in targets:
|
||||||
self.check_unsatisfiable('foo=bgqos_0', '=chaos_5_x86_64_ib')
|
self.check_satisfies('foo='+target.name, '='+target.name)
|
||||||
self.check_unsatisfiable('foo=chaos_5_x86_64_ib', '=bgqos_0')
|
|
||||||
|
|
||||||
|
for i in range(1,len(targets)):
|
||||||
|
self.check_unsatisfiable('foo='+targets[i-1].name, '='+targets[i].name)
|
||||||
|
|
||||||
def test_satisfies_dependencies(self):
|
def test_satisfies_dependencies(self):
|
||||||
self.check_satisfies('mpileaks^mpich', '^mpich')
|
self.check_satisfies('mpileaks^mpich', '^mpich')
|
||||||
@ -267,13 +268,15 @@ def test_constrain_variants(self):
|
|||||||
|
|
||||||
|
|
||||||
def test_constrain_target(self):
|
def test_constrain_target(self):
|
||||||
self.check_constrain('libelf=bgqos_0', 'libelf=bgqos_0', 'libelf=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0')
|
target = platform.target('default').name
|
||||||
|
self.check_constrain('libelf='+target, 'libelf='+target, 'libelf='+target)
|
||||||
|
self.check_constrain('libelf='+target, 'libelf', 'libelf='+target)
|
||||||
|
|
||||||
|
|
||||||
def test_constrain_compiler(self):
|
def test_constrain_compiler(self):
|
||||||
self.check_constrain('libelf=bgqos_0', 'libelf=bgqos_0', 'libelf=bgqos_0')
|
self.check_constrain('libelf%intel', 'libelf%intel', 'libelf%intel')
|
||||||
self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0')
|
self.check_constrain('libelf%intel', 'libelf', 'libelf%intel')
|
||||||
|
|
||||||
|
|
||||||
def test_invalid_constraint(self):
|
def test_invalid_constraint(self):
|
||||||
@ -283,7 +286,10 @@ def test_invalid_constraint(self):
|
|||||||
self.check_invalid_constraint('libelf+debug', 'libelf~debug')
|
self.check_invalid_constraint('libelf+debug', 'libelf~debug')
|
||||||
self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo')
|
self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo')
|
||||||
|
|
||||||
self.check_invalid_constraint('libelf=bgqos_0', 'libelf=x86_54')
|
platform = spack.architecture.sys_type()
|
||||||
|
targets = platform.targets.values()
|
||||||
|
if len(targets) > 1:
|
||||||
|
self.check_invalid_constraint('libelf='+targets[0].name, 'libelf='+targets[1].name)
|
||||||
|
|
||||||
|
|
||||||
def test_constrain_changed(self):
|
def test_constrain_changed(self):
|
||||||
@ -293,7 +299,8 @@ def test_constrain_changed(self):
|
|||||||
self.check_constrain_changed('libelf%gcc', '%gcc@4.5')
|
self.check_constrain_changed('libelf%gcc', '%gcc@4.5')
|
||||||
self.check_constrain_changed('libelf', '+debug')
|
self.check_constrain_changed('libelf', '+debug')
|
||||||
self.check_constrain_changed('libelf', '~debug')
|
self.check_constrain_changed('libelf', '~debug')
|
||||||
self.check_constrain_changed('libelf', '=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
|
self.check_constrain_changed('libelf', '='+platform.target('default').name)
|
||||||
|
|
||||||
|
|
||||||
def test_constrain_not_changed(self):
|
def test_constrain_not_changed(self):
|
||||||
@ -304,7 +311,9 @@ def test_constrain_not_changed(self):
|
|||||||
self.check_constrain_not_changed('libelf%gcc@4.5', '%gcc@4.5')
|
self.check_constrain_not_changed('libelf%gcc@4.5', '%gcc@4.5')
|
||||||
self.check_constrain_not_changed('libelf+debug', '+debug')
|
self.check_constrain_not_changed('libelf+debug', '+debug')
|
||||||
self.check_constrain_not_changed('libelf~debug', '~debug')
|
self.check_constrain_not_changed('libelf~debug', '~debug')
|
||||||
self.check_constrain_not_changed('libelf=bgqos_0', '=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
|
default = platform.target('default').name
|
||||||
|
self.check_constrain_not_changed('libelf='+default, '='+default)
|
||||||
self.check_constrain_not_changed('libelf^foo', 'libelf^foo')
|
self.check_constrain_not_changed('libelf^foo', 'libelf^foo')
|
||||||
self.check_constrain_not_changed('libelf^foo^bar', 'libelf^foo^bar')
|
self.check_constrain_not_changed('libelf^foo^bar', 'libelf^foo^bar')
|
||||||
|
|
||||||
@ -316,7 +325,9 @@ def test_constrain_dependency_changed(self):
|
|||||||
self.check_constrain_changed('libelf^foo%gcc', 'libelf^foo%gcc@4.5')
|
self.check_constrain_changed('libelf^foo%gcc', 'libelf^foo%gcc@4.5')
|
||||||
self.check_constrain_changed('libelf^foo', 'libelf^foo+debug')
|
self.check_constrain_changed('libelf^foo', 'libelf^foo+debug')
|
||||||
self.check_constrain_changed('libelf^foo', 'libelf^foo~debug')
|
self.check_constrain_changed('libelf^foo', 'libelf^foo~debug')
|
||||||
self.check_constrain_changed('libelf^foo', 'libelf^foo=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
|
default = platform.target('default').name
|
||||||
|
self.check_constrain_changed('libelf^foo', 'libelf^foo='+default)
|
||||||
|
|
||||||
|
|
||||||
def test_constrain_dependency_not_changed(self):
|
def test_constrain_dependency_not_changed(self):
|
||||||
@ -326,5 +337,7 @@ def test_constrain_dependency_not_changed(self):
|
|||||||
self.check_constrain_not_changed('libelf^foo%gcc@4.5', 'libelf^foo%gcc@4.5')
|
self.check_constrain_not_changed('libelf^foo%gcc@4.5', 'libelf^foo%gcc@4.5')
|
||||||
self.check_constrain_not_changed('libelf^foo+debug', 'libelf^foo+debug')
|
self.check_constrain_not_changed('libelf^foo+debug', 'libelf^foo+debug')
|
||||||
self.check_constrain_not_changed('libelf^foo~debug', 'libelf^foo~debug')
|
self.check_constrain_not_changed('libelf^foo~debug', 'libelf^foo~debug')
|
||||||
self.check_constrain_not_changed('libelf^foo=bgqos_0', 'libelf^foo=bgqos_0')
|
platform = spack.architecture.sys_type()
|
||||||
|
default = platform.target('default').name
|
||||||
|
self.check_constrain_not_changed('libelf^foo='+default, 'libelf^foo='+default)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from spack import *
|
from spack import *
|
||||||
|
import spack.architecture
|
||||||
|
|
||||||
class Multimethod(Package):
|
class Multimethod(Package):
|
||||||
"""This package is designed for use with Spack's multimethod test.
|
"""This package is designed for use with Spack's multimethod test.
|
||||||
@ -103,21 +103,12 @@ def has_a_default(self):
|
|||||||
#
|
#
|
||||||
# Make sure we can switch methods on different target
|
# Make sure we can switch methods on different target
|
||||||
#
|
#
|
||||||
@when('=x86_64')
|
platform = spack.architecture.sys_type()
|
||||||
def different_by_target(self):
|
targets = platform.targets.values()
|
||||||
return 'x86_64'
|
for target in targets[:-1]:
|
||||||
|
@when('='+target.name)
|
||||||
@when('=ppc64')
|
def different_by_target(self):
|
||||||
def different_by_target(self):
|
return self.spec.target.name
|
||||||
return 'ppc64'
|
|
||||||
|
|
||||||
@when('=ppc32')
|
|
||||||
def different_by_target(self):
|
|
||||||
return 'ppc32'
|
|
||||||
|
|
||||||
@when('=arm64')
|
|
||||||
def different_by_target(self):
|
|
||||||
return 'arm64'
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user