Cleaned up naming conventions for architecture, split into platform and target
This commit is contained in:
parent
b4a0004f44
commit
6ccd9d6fa4
@ -37,7 +37,7 @@
|
||||
lib_path = join_path(prefix, "lib", "spack")
|
||||
build_env_path = join_path(lib_path, "env")
|
||||
module_path = join_path(lib_path, "spack")
|
||||
arch_path = join_path(module_path, 'architectures')
|
||||
platform_path = join_path(module_path, 'platforms')
|
||||
compilers_path = join_path(module_path, "compilers")
|
||||
test_path = join_path(module_path, "test")
|
||||
hooks_path = join_path(module_path, "hooks")
|
||||
|
@ -34,9 +34,9 @@ class ABI(object):
|
||||
"""This class provides methods to test ABI compatibility between specs.
|
||||
The current implementation is rather rough and could be improved."""
|
||||
|
||||
def architecture_compatible(self, parent, child):
|
||||
"""Returns true iff the parent and child specs have ABI compatible architectures."""
|
||||
return not parent.architecture or not child.architecture or parent.architecture == child.architecture
|
||||
def target_compatible(self, parent, child):
|
||||
"""Returns true iff the parent and child specs have ABI compatible targets."""
|
||||
return not parent.target or not child.target or parent.target == child.target
|
||||
|
||||
|
||||
@memoized
|
||||
@ -123,6 +123,6 @@ def compiler_compatible(self, parent, child, **kwargs):
|
||||
def compatible(self, parent, child, **kwargs):
|
||||
"""Returns true iff a parent and child spec are ABI compatible"""
|
||||
loosematch = kwargs.get('loose', False)
|
||||
return self.architecture_compatible(parent, child) and \
|
||||
return self.target_compatible(parent, child) and \
|
||||
self.compiler_compatible(parent, child, loose=loosematch)
|
||||
|
||||
|
@ -51,8 +51,8 @@ def __init__(self):
|
||||
class Target(object):
|
||||
""" Target is the processor of the host machine. The host machine may have different front-end
|
||||
and back-end targets, especially if it is a Cray machine. The target will have a name and
|
||||
also the module_name (e.g craype-compiler). Targets will also recognize which architecture
|
||||
they came from using the set_architecture method. Targets will have compiler finding strategies
|
||||
also the module_name (e.g craype-compiler). Targets will also recognize which platform
|
||||
they came from using the set_platform method. Targets will have compiler finding strategies
|
||||
"""
|
||||
|
||||
def __init__(self, name, compiler_strategy, module_name=None):
|
||||
@ -60,17 +60,17 @@ def __init__(self, name, compiler_strategy, module_name=None):
|
||||
self.compiler_strategy = compiler_strategy
|
||||
self.module_name = module_name # craype-ivybridge
|
||||
|
||||
# Sets only the architecture name to avoid recursiveness
|
||||
def set_architecture(self, architecture):
|
||||
self.architecture_name = architecture.name
|
||||
# Sets only the platform name to avoid recursiveness
|
||||
def set_platform(self, platform):
|
||||
self.platform_name = platform.name
|
||||
|
||||
def to_dict(self):
|
||||
d = {}
|
||||
d['name'] = self.name
|
||||
d['compiler_strategy'] = self.compiler_strategy
|
||||
d['module_name'] = self.module_name
|
||||
if self.architecture_name:
|
||||
d['architecture'] = self.architecture_name
|
||||
if self.platform_name:
|
||||
d['platform'] = self.platform_name
|
||||
return d
|
||||
|
||||
@staticmethod
|
||||
@ -81,8 +81,8 @@ def from_dict(d):
|
||||
target.name = d['name']
|
||||
target.compiler_strategy = d['compiler_strategy']
|
||||
target.module_name = d['module_name']
|
||||
if 'architecture' in d:
|
||||
target.architecture_name = d['architecture']
|
||||
if 'platform' in d:
|
||||
target.platform_name = d['platform']
|
||||
return target
|
||||
|
||||
|
||||
@ -96,13 +96,13 @@ def __str__(self):
|
||||
return self.name
|
||||
|
||||
@key_ordering
|
||||
class Architecture(object):
|
||||
""" Abstract class that each type of Architecture will subclass.
|
||||
class Platform(object):
|
||||
""" Abstract class that each type of Platform will subclass.
|
||||
Will return a instance of it once it
|
||||
is returned
|
||||
"""
|
||||
|
||||
priority = None # Subclass needs to set this number. This controls order in which arch is detected.
|
||||
priority = None # Subclass needs to set this number. This controls order in which platform is detected.
|
||||
front_end = None
|
||||
back_end = None
|
||||
default = None # The default back end target. On cray ivybridge
|
||||
@ -112,12 +112,12 @@ def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
def add_target(self, name, target):
|
||||
"""Used by the architecture specific subclass to list available targets. Raises an error
|
||||
if the architecture specifies a name that is reserved by spack as an alias.
|
||||
"""Used by the platform specific subclass to list available targets. Raises an error
|
||||
if the platform specifies a name that is reserved by spack as an alias.
|
||||
"""
|
||||
if name in ['front_end', 'fe', 'back_end', 'be', 'default']:
|
||||
raise ValueError("%s is a spack reserved alias and cannot be the name of a target" % name)
|
||||
target.set_architecture(self)
|
||||
target.set_platform(self)
|
||||
self.targets[name] = target
|
||||
|
||||
def target(self, name):
|
||||
@ -137,7 +137,7 @@ def target(self, name):
|
||||
@classmethod
|
||||
def detect(self):
|
||||
""" Subclass is responsible for implementing this method.
|
||||
Returns True if the architecture detects if it is the current architecture
|
||||
Returns True if the Platform class detects that it is the current platform
|
||||
and False if it's not.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
@ -182,18 +182,18 @@ def get_sys_type_from_uname():
|
||||
Front-end config
|
||||
"""
|
||||
try:
|
||||
arch_proc = subprocess.Popen(['uname', '-i'], stdout = subprocess.PIPE)
|
||||
arch, _ = arch_proc.communicate()
|
||||
return arch.strip()
|
||||
platform_proc = subprocess.Popen(['uname', '-i'], stdout = subprocess.PIPE)
|
||||
platform, _ = platform_proc.communicate()
|
||||
return platform.strip()
|
||||
except:
|
||||
return None
|
||||
|
||||
@memoized
|
||||
def all_architectures():
|
||||
def all_platforms():
|
||||
modules = []
|
||||
for name in list_modules(spack.arch_path):
|
||||
mod_name = 'spack.architectures' + name
|
||||
path = join_path(spack.arch_path, name) + ".py"
|
||||
for name in list_modules(spack.platform_path):
|
||||
mod_name = 'spack.platformss' + name
|
||||
path = join_path(spack.platform_path, name) + ".py"
|
||||
mod = imp.load_source(mod_name, path)
|
||||
class_name = mod_to_class(name)
|
||||
if not hasattr(mod, class_name):
|
||||
@ -208,16 +208,16 @@ def all_architectures():
|
||||
|
||||
@memoized
|
||||
def sys_type():
|
||||
""" Gather a list of all available subclasses of architectures.
|
||||
""" Gather a list of all available subclasses of platforms.
|
||||
Sorts the list according to their priority looking. Priority is
|
||||
an arbitrarily set number. Detects arch either using uname or
|
||||
an arbitrarily set number. Detects platform either using uname or
|
||||
a file path (/opt/cray...)
|
||||
"""
|
||||
# Try to create an architecture object using the config file FIRST
|
||||
architecture_list = all_architectures()
|
||||
architecture_list.sort(key = lambda a: a.priority)
|
||||
# Try to create a Platform object using the config file FIRST
|
||||
platform_list = all_platforms()
|
||||
platform_list.sort(key = lambda a: a.priority)
|
||||
|
||||
for arch in architecture_list:
|
||||
if arch.detect():
|
||||
return arch()
|
||||
for platform in platform_list:
|
||||
if platform.detect():
|
||||
return platform()
|
||||
|
||||
|
@ -226,8 +226,8 @@ def set_build_environment_variables(pkg):
|
||||
pkg_config_dirs.append(pcdir)
|
||||
path_put_first("PKG_CONFIG_PATH", pkg_config_dirs)
|
||||
|
||||
if pkg.spec.architecture.module_name:
|
||||
load_module(pkg.spec.architecture.module_name)
|
||||
if pkg.spec.target.module_name:
|
||||
load_module(pkg.spec.target.module_name)
|
||||
|
||||
def set_module_variables_for_package(pkg):
|
||||
"""Populate the module scope of install() with some useful functions.
|
||||
|
@ -72,19 +72,19 @@ def display_specs(specs, **kwargs):
|
||||
hashes = True
|
||||
hlen = None
|
||||
|
||||
# Make a dict with specs keyed by architecture and compiler.
|
||||
index = index_by(specs, ('architecture', 'compiler'))
|
||||
# Make a dict with specs keyed by target and compiler.
|
||||
index = index_by(specs, ('target', 'compiler'))
|
||||
|
||||
# Traverse the index and print out each package
|
||||
for i, (architecture, compiler) in enumerate(sorted(index)):
|
||||
for i, (target, compiler) in enumerate(sorted(index)):
|
||||
if i > 0: print
|
||||
|
||||
header = "%s{%s} / %s{%s}" % (
|
||||
spack.spec.architecture_color, architecture,
|
||||
spack.spec.target_color, target,
|
||||
spack.spec.compiler_color, compiler)
|
||||
tty.hline(colorize(header), char='-')
|
||||
|
||||
specs = index[(architecture,compiler)]
|
||||
specs = index[(target,compiler)]
|
||||
specs.sort()
|
||||
|
||||
abbreviated = [s.format('$_$@$+', color=True) for s in specs]
|
||||
|
@ -208,30 +208,30 @@ def concretize_version(self, spec):
|
||||
return True # Things changed
|
||||
|
||||
|
||||
def concretize_architecture(self, spec):
|
||||
"""If the spec already has an architecture and it is a an architecture type,
|
||||
return. Otherwise, if it has an architecture that is a string type, generate an
|
||||
architecture based on that type. If it has no architecture and the root of the
|
||||
DAG has an architecture, then use that. Otherwise, take the system's default
|
||||
architecture.
|
||||
def concretize_target(self, spec):
|
||||
"""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
|
||||
target based on that type. If it has no target and the root of the
|
||||
DAG has an target, then use that. Otherwise, take the system's default
|
||||
target.
|
||||
"""
|
||||
if spec.architecture is not None:
|
||||
if isinstance(spec.architecture,spack.architecture.Target):
|
||||
if spec.target is not None:
|
||||
if isinstance(spec.target,spack.architecture.Target):
|
||||
return False
|
||||
else:
|
||||
arch = spack.architecture.sys_type()
|
||||
spec.architecture = arch.target(spec.architecture)
|
||||
platform = spack.architecture.sys_type()
|
||||
spec.target = platform.target(spec.target)
|
||||
return True #changed
|
||||
|
||||
if spec.root.architecture:
|
||||
if isinstance(spec.root.architecture,spack.architecture.Target):
|
||||
spec.architecture = spec.root.architecture
|
||||
if spec.root.target:
|
||||
if isinstance(spec.root.target,spack.architecture.Target):
|
||||
spec.target = spec.root.target
|
||||
else:
|
||||
arch = spack.architecture.sys_type()
|
||||
spec.architecture = arch.target(spec.root.architecture)
|
||||
platform = spack.architecture.sys_type()
|
||||
spec.target = platform.target(spec.root.target)
|
||||
else:
|
||||
arch = spack.architecture.sys_type()
|
||||
spec.architecture = arch.target('default')
|
||||
platform = spack.architecture.sys_type()
|
||||
spec.target = platform.target('default')
|
||||
|
||||
return True #changed
|
||||
|
||||
@ -260,8 +260,8 @@ def concretize_compiler(self, spec):
|
||||
build with the compiler that will be used by libraries that
|
||||
link to this one, to maximize compatibility.
|
||||
"""
|
||||
# Pass on concretizing the compiler if the architecture is not yet determined
|
||||
if not spec.architecture:
|
||||
# Pass on concretizing the compiler if the target is not yet determined
|
||||
if not spec.target:
|
||||
#Although this usually means changed, this means awaiting other changes
|
||||
return True
|
||||
|
||||
@ -305,7 +305,7 @@ def _proper_compiler_style(cspec, target):
|
||||
|
||||
# copy concrete version into other_compiler
|
||||
index = len(matches)-1
|
||||
while not _proper_compiler_style(matches[index], spec.architecture):
|
||||
while not _proper_compiler_style(matches[index], spec.target):
|
||||
index -= 1
|
||||
if index == 0:
|
||||
raise NoValidVersionError(spec)
|
||||
|
@ -129,7 +129,7 @@ def __init__(self, n, f, m):
|
||||
config_scopes = [('site', os.path.join(spack.etc_path, 'spack')),
|
||||
('user', os.path.expanduser('~/.spack'))]
|
||||
|
||||
_compiler_by_arch = {}
|
||||
_compiler_by_platform = {}
|
||||
_read_config_file_result = {}
|
||||
def _read_config_file(filename):
|
||||
"""Read a given YAML configuration file"""
|
||||
@ -156,7 +156,7 @@ def clear_config_caches():
|
||||
s.files_read_from = []
|
||||
s.result_dict = {}
|
||||
spack.config._read_config_file_result = {}
|
||||
spack.config._compiler_by_arch = {}
|
||||
spack.config._compiler_by_platform = {}
|
||||
spack.compilers._cached_default_compiler = None
|
||||
|
||||
|
||||
@ -213,27 +213,27 @@ def get_config(category_name):
|
||||
return category.result_dict
|
||||
|
||||
|
||||
def get_compilers_config(arch=None):
|
||||
def get_compilers_config(platform=None):
|
||||
"""Get the compiler configuration from config files for the given
|
||||
architecture. Strips off the architecture component of the
|
||||
platform. Strips off the platform component of the
|
||||
configuration"""
|
||||
global _compiler_by_arch
|
||||
if not arch:
|
||||
arch = str(spack.architecture.sys_type())
|
||||
if arch in _compiler_by_arch:
|
||||
return _compiler_by_arch[arch]
|
||||
global _compiler_by_platform
|
||||
if not platform:
|
||||
platform = str(spack.architecture.sys_type())
|
||||
if platform in _compiler_by_platform:
|
||||
return _compiler_by_platform[platform]
|
||||
|
||||
cc_config = get_config('compilers')
|
||||
if arch in cc_config and 'all' in cc_config:
|
||||
arch_compiler = dict(cc_config[arch])
|
||||
_compiler_by_arch[arch] = _merge_dict(arch_compiler, cc_config['all'])
|
||||
elif arch in cc_config:
|
||||
_compiler_by_arch[arch] = cc_config[arch]
|
||||
if platform in cc_config and 'all' in cc_config:
|
||||
platform_compiler = dict(cc_config[platform])
|
||||
_compiler_by_platform[platform] = _merge_dict(platform_compiler, cc_config['all'])
|
||||
elif platform in cc_config:
|
||||
_compiler_by_platform[platform] = cc_config[platform]
|
||||
elif 'all' in cc_config:
|
||||
_compiler_by_arch[arch] = cc_config['all']
|
||||
_compiler_by_platform[platform] = cc_config['all']
|
||||
else:
|
||||
_compiler_by_arch[arch] = {}
|
||||
return _compiler_by_arch[arch]
|
||||
_compiler_by_platform[platform] = {}
|
||||
return _compiler_by_platform[platform]
|
||||
|
||||
|
||||
def get_mirror_config():
|
||||
@ -371,11 +371,11 @@ def add_to_mirror_config(addition_dict, scope=None):
|
||||
add_to_config('mirrors', addition_dict, scope)
|
||||
|
||||
|
||||
def add_to_compiler_config(addition_dict, scope=None, arch=None):
|
||||
def add_to_compiler_config(addition_dict, scope=None, platform=None):
|
||||
"""Add compilers to the configuration files"""
|
||||
if not arch:
|
||||
arch = spack.architecture.sys_type()
|
||||
add_to_config('compilers', { str(arch) : addition_dict }, scope)
|
||||
if not platform:
|
||||
platform = spack.architecture.sys_type()
|
||||
add_to_config('compilers', { str(platform) : addition_dict }, scope)
|
||||
clear_config_caches()
|
||||
|
||||
|
||||
|
@ -156,7 +156,7 @@ def remove_install_directory(self, spec):
|
||||
class YamlDirectoryLayout(DirectoryLayout):
|
||||
"""Lays out installation directories like this::
|
||||
<install root>/
|
||||
<architecture>/
|
||||
<target>/
|
||||
<compiler>-<compiler version>/
|
||||
<name>-<version>-<variants>-<hash>
|
||||
|
||||
@ -201,7 +201,7 @@ def relative_path_for_spec(self, spec):
|
||||
spec.dag_hash(self.hash_len))
|
||||
|
||||
path = join_path(
|
||||
spec.architecture,
|
||||
spec.target,
|
||||
"%s-%s" % (spec.compiler.name, spec.compiler.version),
|
||||
dir_name)
|
||||
|
||||
|
@ -193,7 +193,7 @@ class Dotkit(EnvModule):
|
||||
|
||||
@property
|
||||
def file_name(self):
|
||||
return join_path(Dotkit.path, self.spec.architecture,
|
||||
return join_path(Dotkit.path, self.spec.target,
|
||||
self.spec.format('$_$@$%@$+$#.dk'))
|
||||
|
||||
@property
|
||||
@ -230,7 +230,7 @@ class TclModule(EnvModule):
|
||||
|
||||
@property
|
||||
def file_name(self):
|
||||
return join_path(TclModule.path, self.spec.architecture, self.use_name)
|
||||
return join_path(TclModule.path, self.spec.target, self.use_name)
|
||||
|
||||
|
||||
@property
|
||||
|
@ -592,7 +592,7 @@ def compiler(self):
|
||||
"""Get the spack.compiler.Compiler object used to build this package."""
|
||||
if not self.spec.concrete:
|
||||
raise ValueError("Can only get a compiler for a concrete package.")
|
||||
return spack.compilers.compiler_for_spec(self.spec.compiler, self.spec.architecture)
|
||||
return spack.compilers.compiler_for_spec(self.spec.compiler, self.spec.target)
|
||||
|
||||
|
||||
def url_version(self, version):
|
||||
|
@ -1,8 +1,8 @@
|
||||
import os
|
||||
|
||||
from spack.architecture import Architecture, Target
|
||||
from spack.architecture import Platform, Target
|
||||
|
||||
class Bgq(Architecture):
|
||||
class Bgq(Platform):
|
||||
priority = 30
|
||||
front_end = 'power7'
|
||||
back_end = 'powerpc'
|
@ -1,8 +1,8 @@
|
||||
import os
|
||||
|
||||
from spack.architecture import Architecture, Target
|
||||
from spack.architecture import Platform, Target
|
||||
|
||||
class Cray(Architecture):
|
||||
class Cray(Platform):
|
||||
priority = 20
|
||||
front_end = 'sandybridge'
|
||||
back_end = 'ivybridge'
|
@ -1,7 +1,7 @@
|
||||
import subprocess
|
||||
from spack.architecture import Architecture, Target
|
||||
from spack.architecture import Platform, Target
|
||||
|
||||
class Darwin(Architecture):
|
||||
class Darwin(Platform):
|
||||
priority = 89
|
||||
front_end = 'x86_64'
|
||||
back_end = 'x86_64'
|
||||
@ -13,6 +13,6 @@ def __init__(self):
|
||||
|
||||
@classmethod
|
||||
def detect(self):
|
||||
arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
|
||||
arch, _ = arch.communicate()
|
||||
return 'darwin' in arch.strip().lower()
|
||||
platform = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
|
||||
platform, _ = platform.communicate()
|
||||
return 'darwin' in platform.strip().lower()
|
@ -1,7 +1,7 @@
|
||||
import subprocess
|
||||
from spack.architecture import Architecture, Target
|
||||
from spack.architecture import Platform, Target
|
||||
|
||||
class Linux(Architecture):
|
||||
class Linux(Platform):
|
||||
priority = 90
|
||||
front_end = 'x86_64'
|
||||
back_end = 'x86_64'
|
||||
@ -13,6 +13,6 @@ def __init__(self):
|
||||
|
||||
@classmethod
|
||||
def detect(self):
|
||||
arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
|
||||
arch, _ = arch.communicate()
|
||||
return 'linux' in arch.strip().lower()
|
||||
platform = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
|
||||
platform, _ = platform.communicate()
|
||||
return 'linux' in platform.strip().lower()
|
@ -163,11 +163,11 @@ def variant_compare(self, pkgname, a, b):
|
||||
return self._component_compare(pkgname, 'variant', a, b, False, None)
|
||||
|
||||
|
||||
def architecture_compare(self, pkgname, a, b):
|
||||
"""Return less-than-0, 0, or greater than 0 if architecture a of pkgname is
|
||||
respecively less-than, equal-to, or greater-than architecture b of pkgname.
|
||||
One architecture is less-than another if it is preferred over the other."""
|
||||
return self._component_compare(pkgname, 'architecture', a, b, False, None)
|
||||
def target_compare(self, pkgname, a, b):
|
||||
"""Return less-than-0, 0, or greater than 0 if target a of pkgname is
|
||||
respecively less-than, equal-to, or greater-than target b of pkgname.
|
||||
One target is less-than another if it is preferred over the other."""
|
||||
return self._component_compare(pkgname, 'target', a, b, False, None)
|
||||
|
||||
|
||||
def compiler_compare(self, pkgname, a, b):
|
||||
|
@ -63,7 +63,7 @@
|
||||
if it comes immediately after the compiler name. Otherwise it will be
|
||||
associated with the current package spec.
|
||||
|
||||
6. The architecture to build with. This is needed on machines where
|
||||
6. The target to build with. This is needed on machines where
|
||||
cross-compilation is required
|
||||
|
||||
Here is the EBNF grammar for a spec::
|
||||
@ -72,9 +72,9 @@
|
||||
dep_list = { ^ spec }
|
||||
spec = id [ options ]
|
||||
options = { @version-list | +variant | -variant | ~variant |
|
||||
%compiler | =architecture }
|
||||
%compiler | =target }
|
||||
variant = id
|
||||
architecture = id
|
||||
target = id
|
||||
compiler = id [ version-list ]
|
||||
version-list = version [ { , version } ]
|
||||
version = id | id: | :id | id:id
|
||||
@ -119,7 +119,7 @@
|
||||
# Convenient names for color formats so that other things can use them
|
||||
compiler_color = '@g'
|
||||
version_color = '@c'
|
||||
architecture_color = '@m'
|
||||
target_color = '@m'
|
||||
enabled_variant_color = '@B'
|
||||
disabled_variant_color = '@r'
|
||||
dependency_color = '@.'
|
||||
@ -130,7 +130,7 @@
|
||||
See spack.color for descriptions of the color codes. """
|
||||
color_formats = {'%' : compiler_color,
|
||||
'@' : version_color,
|
||||
'=' : architecture_color,
|
||||
'=' : target_color,
|
||||
'+' : enabled_variant_color,
|
||||
'~' : disabled_variant_color,
|
||||
'^' : dependency_color,
|
||||
@ -407,7 +407,7 @@ def __init__(self, spec_like, *dep_like, **kwargs):
|
||||
self.name = other.name
|
||||
self.dependents = other.dependents
|
||||
self.versions = other.versions
|
||||
self.architecture = other.architecture
|
||||
self.target = other.target
|
||||
self.compiler = other.compiler
|
||||
self.dependencies = other.dependencies
|
||||
self.variants = other.variants
|
||||
@ -452,11 +452,11 @@ def _set_compiler(self, compiler):
|
||||
self.compiler = compiler
|
||||
|
||||
|
||||
def _set_architecture(self, architecture):
|
||||
"""Called by the parser to set the architecture."""
|
||||
if self.architecture: raise DuplicateArchitectureError(
|
||||
"Spec for '%s' cannot have two architectures." % self.name)
|
||||
self.architecture = architecture
|
||||
def _set_target(self, target):
|
||||
"""Called by the parser to set the target."""
|
||||
if self.target: raise DuplicateTargetError(
|
||||
"Spec for '%s' cannot have two targets." % self.name)
|
||||
self.target = target
|
||||
|
||||
|
||||
def _add_dependency(self, spec):
|
||||
@ -512,7 +512,7 @@ def is_virtual(name):
|
||||
@property
|
||||
def concrete(self):
|
||||
"""A spec is concrete if it can describe only ONE build of a package.
|
||||
If any of the name, version, architecture, compiler,
|
||||
If any of the name, version, target, compiler,
|
||||
variants, or depdenencies are ambiguous,then it is not concrete.
|
||||
"""
|
||||
if self._concrete:
|
||||
@ -521,7 +521,7 @@ def concrete(self):
|
||||
self._concrete = bool(not self.virtual
|
||||
and self.versions.concrete
|
||||
and self.variants.concrete
|
||||
and self.architecture
|
||||
and self.target
|
||||
and self.compiler and self.compiler.concrete
|
||||
and self.dependencies.concrete)
|
||||
return self._concrete
|
||||
@ -656,10 +656,10 @@ def to_node_dict(self):
|
||||
'dependencies' : dict((d, self.dependencies[d].dag_hash())
|
||||
for d in sorted(self.dependencies))
|
||||
}
|
||||
if self.architecture:
|
||||
d['arch'] = self.architecture.to_dict()
|
||||
if self.target:
|
||||
d['target'] = self.target.to_dict()
|
||||
else:
|
||||
d['arch'] = None
|
||||
d['target'] = None
|
||||
if self.compiler:
|
||||
d.update(self.compiler.to_dict())
|
||||
else:
|
||||
@ -685,7 +685,7 @@ def from_node_dict(node):
|
||||
|
||||
spec = Spec(name)
|
||||
spec.versions = VersionList.from_dict(node)
|
||||
spec.architecture = spack.architecture.Target.from_dict(node['arch'])
|
||||
spec.target = spack.architecture.Target.from_dict(node['target'])
|
||||
|
||||
if node['compiler'] is None:
|
||||
spec.compiler = None
|
||||
@ -757,7 +757,7 @@ def _concretize_helper(self, presets=None, visited=None):
|
||||
# to presets below, their constraints will all be merged, but we'll
|
||||
# still need to select a concrete package later.
|
||||
changed |= any(
|
||||
(spack.concretizer.concretize_architecture(self),
|
||||
(spack.concretizer.concretize_target(self),
|
||||
spack.concretizer.concretize_compiler(self),
|
||||
spack.concretizer.concretize_version(self),
|
||||
spack.concretizer.concretize_variants(self)))
|
||||
@ -1145,10 +1145,10 @@ def constrain(self, other, deps=True):
|
||||
raise UnsatisfiableVariantSpecError(self.variants[v],
|
||||
other.variants[v])
|
||||
|
||||
if self.architecture is not None and other.architecture is not None:
|
||||
if self.architecture != other.architecture:
|
||||
raise UnsatisfiableArchitectureSpecError(self.architecture,
|
||||
other.architecture)
|
||||
if self.target is not None and other.target is not None:
|
||||
if self.target != other.target:
|
||||
raise UnsatisfiableTargetSpecError(self.target,
|
||||
other.target)
|
||||
|
||||
changed = False
|
||||
if self.compiler is not None and other.compiler is not None:
|
||||
@ -1160,9 +1160,9 @@ def constrain(self, other, deps=True):
|
||||
changed |= self.versions.intersect(other.versions)
|
||||
changed |= self.variants.constrain(other.variants)
|
||||
|
||||
old = self.architecture
|
||||
self.architecture = self.architecture or other.architecture
|
||||
changed |= (self.architecture != old)
|
||||
old = self.target
|
||||
self.target = self.target or other.target
|
||||
changed |= (self.target != old)
|
||||
|
||||
if deps:
|
||||
changed |= self._constrain_dependencies(other)
|
||||
@ -1273,12 +1273,12 @@ def satisfies(self, other, deps=True, strict=False):
|
||||
if not self.variants.satisfies(other.variants, strict=strict):
|
||||
return False
|
||||
|
||||
# Architecture satisfaction is currently just string equality.
|
||||
# Target satisfaction is currently just class equality.
|
||||
# If not strict, None means unconstrained.
|
||||
if self.architecture and other.architecture:
|
||||
if self.architecture != other.architecture:
|
||||
if self.target and other.target:
|
||||
if self.target != other.target:
|
||||
return False
|
||||
elif strict and (other.architecture and not self.architecture):
|
||||
elif strict and (other.target and not self.target):
|
||||
return False
|
||||
|
||||
# If we need to descend into dependencies, do it, otherwise we're done.
|
||||
@ -1352,7 +1352,7 @@ def _dup(self, other, **kwargs):
|
||||
changed = True
|
||||
if hasattr(self, 'name'):
|
||||
changed = (self.name != other.name and self.versions != other.versions and \
|
||||
self.architecture != other.architecture and self.compiler != other.compiler and \
|
||||
self.target != other.target and self.compiler != other.compiler and \
|
||||
self.variants != other.variants and self._normal != other._normal and \
|
||||
self.concrete != other.concrete and self.external != other.external and \
|
||||
self.external_module != other.external_module)
|
||||
@ -1360,7 +1360,7 @@ def _dup(self, other, **kwargs):
|
||||
# Local node attributes get copied first.
|
||||
self.name = other.name
|
||||
self.versions = other.versions.copy()
|
||||
self.architecture = other.architecture
|
||||
self.target = other.target
|
||||
self.compiler = other.compiler.copy() if other.compiler else None
|
||||
if kwargs.get('cleardeps', True):
|
||||
self.dependents = DependencyMap()
|
||||
@ -1490,7 +1490,7 @@ def ne_dag(self, other):
|
||||
def _cmp_node(self):
|
||||
"""Comparison key for just *this node* and not its deps."""
|
||||
return (self.name, self.versions, self.variants,
|
||||
self.architecture, self.compiler)
|
||||
self.target, self.compiler)
|
||||
|
||||
|
||||
def eq_node(self, other):
|
||||
@ -1524,7 +1524,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
|
||||
$% Compiler with '%' prefix
|
||||
$%@ Compiler with '%' prefix & compiler version with '@' prefix
|
||||
$+ Options
|
||||
$= Architecture with '=' prefix
|
||||
$= Target with '=' prefix
|
||||
$# 7-char prefix of DAG hash with '-' prefix
|
||||
$$ $
|
||||
|
||||
@ -1536,7 +1536,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
|
||||
${COMPILERNAME} Compiler name
|
||||
${COMPILERVER} Compiler version
|
||||
${OPTIONS} Options
|
||||
${ARCHITECTURE} Architecture
|
||||
${TARGET} Target
|
||||
${SHA1} Dependencies 8-char sha1 prefix
|
||||
|
||||
${SPACK_ROOT} The spack root directory
|
||||
@ -1549,7 +1549,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
|
||||
Anything else is copied verbatim into the output stream.
|
||||
|
||||
*Example:* ``$_$@$+`` translates to the name, version, and options
|
||||
of the package, but no dependencies, arch, or compiler.
|
||||
of the package, but no dependencies, target, or compiler.
|
||||
|
||||
TODO: allow, e.g., $6# to customize short hash length
|
||||
TODO: allow, e.g., $## for full hash.
|
||||
@ -1593,8 +1593,8 @@ def write(s, c):
|
||||
if self.variants:
|
||||
write(fmt % str(self.variants), c)
|
||||
elif c == '=':
|
||||
if self.architecture:
|
||||
write(fmt % (c + str(self.architecture)), c)
|
||||
if self.target:
|
||||
write(fmt % (c + str(self.target)), c)
|
||||
elif c == '#':
|
||||
out.write('-' + fmt % (self.dag_hash(7)))
|
||||
elif c == '$':
|
||||
@ -1641,9 +1641,9 @@ def write(s, c):
|
||||
elif named_str == 'OPTIONS':
|
||||
if self.variants:
|
||||
write(fmt % str(self.variants), '+')
|
||||
elif named_str == 'ARCHITECTURE':
|
||||
if self.architecture:
|
||||
write(fmt % str(self.architecture), '=')
|
||||
elif named_str == 'TARGET':
|
||||
if self.target:
|
||||
write(fmt % str(self.target), '=')
|
||||
elif named_str == 'SHA1':
|
||||
if self.dependencies:
|
||||
out.write(fmt % str(self.dep_hash(8)))
|
||||
@ -1691,10 +1691,10 @@ def __cmp__(self, other):
|
||||
return spack.pkgsort.variant_compare(pkgname,
|
||||
self.variants, other.variants)
|
||||
|
||||
#Architecture
|
||||
if self.architecture != other.architecture:
|
||||
return spack.pkgsort.architecture_compare(pkgname,
|
||||
self.architecture, other.architecture)
|
||||
#Target
|
||||
if self.target != other.target:
|
||||
return spack.pkgsort.target_compare(pkgname,
|
||||
self.target, other.target)
|
||||
|
||||
#Dependency is not configurable
|
||||
if self.dep_hash() != other.dep_hash():
|
||||
@ -1811,7 +1811,7 @@ def spec(self):
|
||||
spec.name = self.token.value
|
||||
spec.versions = VersionList()
|
||||
spec.variants = VariantMap(spec)
|
||||
spec.architecture = None
|
||||
spec.target = None
|
||||
spec.compiler = None
|
||||
spec.external = None
|
||||
spec.external_module = None
|
||||
@ -1842,7 +1842,7 @@ def spec(self):
|
||||
spec._set_compiler(self.compiler())
|
||||
|
||||
elif self.accept(EQ):
|
||||
spec._set_architecture(self.architecture())
|
||||
spec._set_target(self.target())
|
||||
|
||||
else:
|
||||
break
|
||||
@ -1860,7 +1860,7 @@ def variant(self):
|
||||
return self.token.value
|
||||
|
||||
|
||||
def architecture(self):
|
||||
def target(self):
|
||||
self.expect(ID)
|
||||
return self.token.value
|
||||
|
||||
@ -2000,10 +2000,10 @@ def __init__(self, pkg, variant):
|
||||
"Package %s has no variant %s!" % (pkg, variant))
|
||||
|
||||
|
||||
class DuplicateArchitectureError(SpecError):
|
||||
"""Raised when the same architecture occurs in a spec twice."""
|
||||
class DuplicateTargetError(SpecError):
|
||||
"""Raised when the same target occurs in a spec twice."""
|
||||
def __init__(self, message):
|
||||
super(DuplicateArchitectureError, self).__init__(message)
|
||||
super(DuplicateTargetError, self).__init__(message)
|
||||
|
||||
|
||||
class InconsistentSpecError(SpecError):
|
||||
@ -2082,11 +2082,11 @@ def __init__(self, provided, required):
|
||||
provided, required, "variant")
|
||||
|
||||
|
||||
class UnsatisfiableArchitectureSpecError(UnsatisfiableSpecError):
|
||||
"""Raised when a spec architecture conflicts with package constraints."""
|
||||
class UnsatisfiableTargetSpecError(UnsatisfiableSpecError):
|
||||
"""Raised when a spec target conflicts with package constraints."""
|
||||
def __init__(self, provided, required):
|
||||
super(UnsatisfiableArchitectureSpecError, self).__init__(
|
||||
provided, required, "architecture")
|
||||
super(UnsatisfiableTargetSpecError, self).__init__(
|
||||
provided, required, "target")
|
||||
|
||||
|
||||
class UnsatisfiableProviderSpecError(UnsatisfiableSpecError):
|
||||
|
@ -6,13 +6,14 @@
|
||||
import platform
|
||||
import spack
|
||||
from spack.architecture import *
|
||||
from spack.architectures.cray import Cray
|
||||
from spack.architectures.linux import Linux
|
||||
from spack.architectures.bgq import Bgq
|
||||
from spack.platforms.cray import Cray
|
||||
from spack.platforms.linux import Linux
|
||||
from spack.platforms.bgq import Bgq
|
||||
from spack.platforms.darwin import Darwin
|
||||
|
||||
class ArchitectureTest(unittest.TestCase):
|
||||
|
||||
def test_Architecture_class_and_compiler_strategies(self):
|
||||
def test_platform_class_and_compiler_strategies(self):
|
||||
a = Cray()
|
||||
t = a.target('default')
|
||||
self.assertEquals(t.compiler_strategy, 'MODULES')
|
||||
@ -21,15 +22,15 @@ def test_Architecture_class_and_compiler_strategies(self):
|
||||
self.assertEquals(s.compiler_strategy, 'PATH')
|
||||
|
||||
def test_sys_type(self):
|
||||
output_arch_class = sys_type()
|
||||
output_platform_class = sys_type()
|
||||
my_arch_class = None
|
||||
if os.path.exists('/opt/cray/craype'):
|
||||
my_arch_class = Cray()
|
||||
my_platform_class = Cray()
|
||||
elif os.path.exists('/bgsys'):
|
||||
my_arch_class = Bgq()
|
||||
my_platform_class = Bgq()
|
||||
elif 'Linux' in platform.system():
|
||||
my_arch_class = Linux()
|
||||
# elif 'Darwin' in platform.system():
|
||||
# my_arch_class = Darwin()
|
||||
my_platform_class = Linux()
|
||||
elif 'Darwin' in platform.system():
|
||||
my_platform_class = Darwin()
|
||||
|
||||
self.assertEqual(str(output_arch_class), str(my_arch_class))
|
||||
self.assertEqual(str(output_platform_class), str(my_platform_class))
|
||||
|
@ -46,8 +46,8 @@ def check_spec(self, abstract, concrete):
|
||||
if abstract.compiler and abstract.compiler.concrete:
|
||||
self.assertEqual(abstract.compiler, concrete.compiler)
|
||||
|
||||
if abstract.architecture and abstract.architecture.concrete:
|
||||
self.assertEqual(abstract.architecture, concrete.architecture)
|
||||
if abstract.target and abstract.target.concrete:
|
||||
self.assertEqual(abstract.target, concrete.target)
|
||||
|
||||
|
||||
def check_concretize(self, abstract_spec):
|
||||
|
@ -91,21 +91,21 @@ def test_default_works(self):
|
||||
self.assertEqual(pkg.has_a_default(), 'default')
|
||||
|
||||
|
||||
def test_architecture_match(self):
|
||||
def test_target_match(self):
|
||||
pkg = spack.db.get('multimethod=x86_64')
|
||||
self.assertEqual(pkg.different_by_architecture(), 'x86_64')
|
||||
self.assertEqual(pkg.different_by_target(), 'x86_64')
|
||||
|
||||
pkg = spack.db.get('multimethod=ppc64')
|
||||
self.assertEqual(pkg.different_by_architecture(), 'ppc64')
|
||||
self.assertEqual(pkg.different_by_target(), 'ppc64')
|
||||
|
||||
pkg = spack.db.get('multimethod=ppc32')
|
||||
self.assertEqual(pkg.different_by_architecture(), 'ppc32')
|
||||
self.assertEqual(pkg.different_by_target(), 'ppc32')
|
||||
|
||||
pkg = spack.db.get('multimethod=arm64')
|
||||
self.assertEqual(pkg.different_by_architecture(), 'arm64')
|
||||
self.assertEqual(pkg.different_by_target(), 'arm64')
|
||||
|
||||
pkg = spack.db.get('multimethod=macos')
|
||||
self.assertRaises(NoSuchMethodError, pkg.different_by_architecture)
|
||||
self.assertRaises(NoSuchMethodError, pkg.different_by_target)
|
||||
|
||||
|
||||
def test_dependency_match(self):
|
||||
|
@ -240,10 +240,10 @@ def test_unsatisfiable_compiler_version(self):
|
||||
self.assertRaises(spack.spec.UnsatisfiableCompilerSpecError, spec.normalize)
|
||||
|
||||
|
||||
def test_unsatisfiable_architecture(self):
|
||||
def test_unsatisfiable_target(self):
|
||||
set_pkg_dep('mpileaks', 'mpich=bgqos_0')
|
||||
spec = Spec('mpileaks ^mpich=sles_10_ppc64 ^callpath ^dyninst ^libelf ^libdwarf')
|
||||
self.assertRaises(spack.spec.UnsatisfiableArchitectureSpecError, spec.normalize)
|
||||
self.assertRaises(spack.spec.UnsatisfiableTargetSpecError, spec.normalize)
|
||||
|
||||
|
||||
def test_invalid_dep(self):
|
||||
|
@ -110,7 +110,7 @@ def test_satisfies_compiler_version(self):
|
||||
self.check_unsatisfiable('foo %gcc@4.7', '%gcc@4.7.3')
|
||||
|
||||
|
||||
def test_satisfies_architecture(self):
|
||||
def test_satisfies_target(self):
|
||||
self.check_satisfies('foo=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib')
|
||||
self.check_satisfies('foo=bgqos_0', '=bgqos_0')
|
||||
|
||||
@ -266,7 +266,7 @@ def test_constrain_variants(self):
|
||||
self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf+debug~foo')
|
||||
|
||||
|
||||
def test_constrain_arch(self):
|
||||
def test_constrain_target(self):
|
||||
self.check_constrain('libelf=bgqos_0', 'libelf=bgqos_0', 'libelf=bgqos_0')
|
||||
self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0')
|
||||
|
||||
|
@ -101,22 +101,22 @@ def has_a_default(self):
|
||||
|
||||
|
||||
#
|
||||
# Make sure we can switch methods on different architectures
|
||||
# Make sure we can switch methods on different target
|
||||
#
|
||||
@when('=x86_64')
|
||||
def different_by_architecture(self):
|
||||
def different_by_target(self):
|
||||
return 'x86_64'
|
||||
|
||||
@when('=ppc64')
|
||||
def different_by_architecture(self):
|
||||
def different_by_target(self):
|
||||
return 'ppc64'
|
||||
|
||||
@when('=ppc32')
|
||||
def different_by_architecture(self):
|
||||
def different_by_target(self):
|
||||
return 'ppc32'
|
||||
|
||||
@when('=arm64')
|
||||
def different_by_architecture(self):
|
||||
def different_by_target(self):
|
||||
return 'arm64'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user