Cleaned up naming conventions for architecture, split into platform and target

This commit is contained in:
Gregory Becker 2016-01-07 11:49:01 -08:00
parent b4a0004f44
commit 6ccd9d6fa4
23 changed files with 191 additions and 190 deletions

View File

@ -37,7 +37,7 @@
lib_path = join_path(prefix, "lib", "spack") lib_path = join_path(prefix, "lib", "spack")
build_env_path = join_path(lib_path, "env") build_env_path = join_path(lib_path, "env")
module_path = join_path(lib_path, "spack") 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") compilers_path = join_path(module_path, "compilers")
test_path = join_path(module_path, "test") test_path = join_path(module_path, "test")
hooks_path = join_path(module_path, "hooks") hooks_path = join_path(module_path, "hooks")

View File

@ -34,9 +34,9 @@ class ABI(object):
"""This class provides methods to test ABI compatibility between specs. """This class provides methods to test ABI compatibility between specs.
The current implementation is rather rough and could be improved.""" The current implementation is rather rough and could be improved."""
def architecture_compatible(self, parent, child): def target_compatible(self, parent, child):
"""Returns true iff the parent and child specs have ABI compatible architectures.""" """Returns true iff the parent and child specs have ABI compatible targets."""
return not parent.architecture or not child.architecture or parent.architecture == child.architecture return not parent.target or not child.target or parent.target == child.target
@memoized @memoized
@ -123,6 +123,6 @@ def compiler_compatible(self, parent, child, **kwargs):
def compatible(self, parent, child, **kwargs): def compatible(self, parent, child, **kwargs):
"""Returns true iff a parent and child spec are ABI compatible""" """Returns true iff a parent and child spec are ABI compatible"""
loosematch = kwargs.get('loose', False) 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) self.compiler_compatible(parent, child, loose=loosematch)

View File

@ -51,8 +51,8 @@ def __init__(self):
class Target(object): class Target(object):
""" Target is the processor of the host machine. The host machine may have different front-end """ 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 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 also the module_name (e.g craype-compiler). Targets will also recognize which platform
they came from using the set_architecture method. Targets will have compiler finding strategies they came from using the set_platform method. Targets will have compiler finding strategies
""" """
def __init__(self, name, compiler_strategy, module_name=None): 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.compiler_strategy = compiler_strategy
self.module_name = module_name # craype-ivybridge self.module_name = module_name # craype-ivybridge
# Sets only the architecture name to avoid recursiveness # Sets only the platform name to avoid recursiveness
def set_architecture(self, architecture): def set_platform(self, platform):
self.architecture_name = architecture.name self.platform_name = platform.name
def to_dict(self): def to_dict(self):
d = {} d = {}
d['name'] = self.name d['name'] = self.name
d['compiler_strategy'] = self.compiler_strategy d['compiler_strategy'] = self.compiler_strategy
d['module_name'] = self.module_name d['module_name'] = self.module_name
if self.architecture_name: if self.platform_name:
d['architecture'] = self.architecture_name d['platform'] = self.platform_name
return d return d
@staticmethod @staticmethod
@ -81,8 +81,8 @@ def from_dict(d):
target.name = d['name'] target.name = d['name']
target.compiler_strategy = d['compiler_strategy'] target.compiler_strategy = d['compiler_strategy']
target.module_name = d['module_name'] target.module_name = d['module_name']
if 'architecture' in d: if 'platform' in d:
target.architecture_name = d['architecture'] target.platform_name = d['platform']
return target return target
@ -96,13 +96,13 @@ def __str__(self):
return self.name return self.name
@key_ordering @key_ordering
class Architecture(object): class Platform(object):
""" Abstract class that each type of Architecture will subclass. """ Abstract class that each type of Platform will subclass.
Will return a instance of it once it Will return a instance of it once it
is returned 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 front_end = None
back_end = None back_end = None
default = None # The default back end target. On cray ivybridge default = None # The default back end target. On cray ivybridge
@ -112,12 +112,12 @@ def __init__(self, name):
self.name = name self.name = name
def add_target(self, name, target): def add_target(self, name, target):
"""Used by the architecture specific subclass to list available targets. Raises an error """Used by the platform specific subclass to list available targets. Raises an error
if the architecture specifies a name that is reserved by spack as an alias. if the platform specifies a name that is reserved by spack as an alias.
""" """
if name in ['front_end', 'fe', 'back_end', 'be', 'default']: 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) 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 self.targets[name] = target
def target(self, name): def target(self, name):
@ -137,7 +137,7 @@ def target(self, name):
@classmethod @classmethod
def detect(self): def detect(self):
""" Subclass is responsible for implementing this method. """ 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. and False if it's not.
""" """
raise NotImplementedError() raise NotImplementedError()
@ -182,18 +182,18 @@ def get_sys_type_from_uname():
Front-end config Front-end config
""" """
try: try:
arch_proc = subprocess.Popen(['uname', '-i'], stdout = subprocess.PIPE) platform_proc = subprocess.Popen(['uname', '-i'], stdout = subprocess.PIPE)
arch, _ = arch_proc.communicate() platform, _ = platform_proc.communicate()
return arch.strip() return platform.strip()
except: except:
return None return None
@memoized @memoized
def all_architectures(): def all_platforms():
modules = [] modules = []
for name in list_modules(spack.arch_path): for name in list_modules(spack.platform_path):
mod_name = 'spack.architectures' + name mod_name = 'spack.platformss' + name
path = join_path(spack.arch_path, name) + ".py" path = join_path(spack.platform_path, name) + ".py"
mod = imp.load_source(mod_name, path) mod = imp.load_source(mod_name, path)
class_name = mod_to_class(name) class_name = mod_to_class(name)
if not hasattr(mod, class_name): if not hasattr(mod, class_name):
@ -208,16 +208,16 @@ def all_architectures():
@memoized @memoized
def sys_type(): 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 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...) a file path (/opt/cray...)
""" """
# Try to create an architecture object using the config file FIRST # Try to create a Platform object using the config file FIRST
architecture_list = all_architectures() platform_list = all_platforms()
architecture_list.sort(key = lambda a: a.priority) platform_list.sort(key = lambda a: a.priority)
for arch in architecture_list: for platform in platform_list:
if arch.detect(): if platform.detect():
return arch() return platform()

View File

@ -226,8 +226,8 @@ def set_build_environment_variables(pkg):
pkg_config_dirs.append(pcdir) pkg_config_dirs.append(pcdir)
path_put_first("PKG_CONFIG_PATH", pkg_config_dirs) path_put_first("PKG_CONFIG_PATH", pkg_config_dirs)
if pkg.spec.architecture.module_name: if pkg.spec.target.module_name:
load_module(pkg.spec.architecture.module_name) load_module(pkg.spec.target.module_name)
def set_module_variables_for_package(pkg): def set_module_variables_for_package(pkg):
"""Populate the module scope of install() with some useful functions. """Populate the module scope of install() with some useful functions.

View File

@ -72,19 +72,19 @@ def display_specs(specs, **kwargs):
hashes = True hashes = True
hlen = None hlen = None
# Make a dict with specs keyed by architecture and compiler. # Make a dict with specs keyed by target and compiler.
index = index_by(specs, ('architecture', 'compiler')) index = index_by(specs, ('target', 'compiler'))
# Traverse the index and print out each package # 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 if i > 0: print
header = "%s{%s} / %s{%s}" % ( header = "%s{%s} / %s{%s}" % (
spack.spec.architecture_color, architecture, spack.spec.target_color, target,
spack.spec.compiler_color, compiler) spack.spec.compiler_color, compiler)
tty.hline(colorize(header), char='-') tty.hline(colorize(header), char='-')
specs = index[(architecture,compiler)] specs = index[(target,compiler)]
specs.sort() specs.sort()
abbreviated = [s.format('$_$@$+', color=True) for s in specs] abbreviated = [s.format('$_$@$+', color=True) for s in specs]

View File

@ -208,30 +208,30 @@ def concretize_version(self, spec):
return True # Things changed return True # Things changed
def concretize_architecture(self, spec): def concretize_target(self, spec):
"""If the spec already has an architecture and it is a an architecture type, """If the spec already has an target and it is a an target type,
return. Otherwise, if it has an architecture that is a string type, generate an return. Otherwise, if it has a target that is a string type, generate a
architecture based on that type. If it has no architecture and the root of the target based on that type. If it has no target and the root of the
DAG has an architecture, then use that. Otherwise, take the system's default DAG has an target, then use that. Otherwise, take the system's default
architecture. target.
""" """
if spec.architecture is not None: if spec.target is not None:
if isinstance(spec.architecture,spack.architecture.Target): if isinstance(spec.target,spack.architecture.Target):
return False return False
else: else:
arch = spack.architecture.sys_type() platform = spack.architecture.sys_type()
spec.architecture = arch.target(spec.architecture) spec.target = platform.target(spec.target)
return True #changed return True #changed
if spec.root.architecture: if spec.root.target:
if isinstance(spec.root.architecture,spack.architecture.Target): if isinstance(spec.root.target,spack.architecture.Target):
spec.architecture = spec.root.architecture spec.target = spec.root.target
else: else:
arch = spack.architecture.sys_type() platform = spack.architecture.sys_type()
spec.architecture = arch.target(spec.root.architecture) spec.target = platform.target(spec.root.target)
else: else:
arch = spack.architecture.sys_type() platform = spack.architecture.sys_type()
spec.architecture = arch.target('default') spec.target = platform.target('default')
return True #changed return True #changed
@ -260,8 +260,8 @@ def concretize_compiler(self, spec):
build with the compiler that will be used by libraries that build with the compiler that will be used by libraries that
link to this one, to maximize compatibility. link to this one, to maximize compatibility.
""" """
# Pass on concretizing the compiler if the architecture is not yet determined # Pass on concretizing the compiler if the target is not yet determined
if not spec.architecture: if not spec.target:
#Although this usually means changed, this means awaiting other changes #Although this usually means changed, this means awaiting other changes
return True return True
@ -305,7 +305,7 @@ def _proper_compiler_style(cspec, target):
# copy concrete version into other_compiler # copy concrete version into other_compiler
index = len(matches)-1 index = len(matches)-1
while not _proper_compiler_style(matches[index], spec.architecture): while not _proper_compiler_style(matches[index], spec.target):
index -= 1 index -= 1
if index == 0: if index == 0:
raise NoValidVersionError(spec) raise NoValidVersionError(spec)

View File

@ -129,7 +129,7 @@ def __init__(self, n, f, m):
config_scopes = [('site', os.path.join(spack.etc_path, 'spack')), config_scopes = [('site', os.path.join(spack.etc_path, 'spack')),
('user', os.path.expanduser('~/.spack'))] ('user', os.path.expanduser('~/.spack'))]
_compiler_by_arch = {} _compiler_by_platform = {}
_read_config_file_result = {} _read_config_file_result = {}
def _read_config_file(filename): def _read_config_file(filename):
"""Read a given YAML configuration file""" """Read a given YAML configuration file"""
@ -156,7 +156,7 @@ def clear_config_caches():
s.files_read_from = [] s.files_read_from = []
s.result_dict = {} s.result_dict = {}
spack.config._read_config_file_result = {} spack.config._read_config_file_result = {}
spack.config._compiler_by_arch = {} spack.config._compiler_by_platform = {}
spack.compilers._cached_default_compiler = None spack.compilers._cached_default_compiler = None
@ -213,27 +213,27 @@ def get_config(category_name):
return category.result_dict 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 """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""" configuration"""
global _compiler_by_arch global _compiler_by_platform
if not arch: if not platform:
arch = str(spack.architecture.sys_type()) platform = str(spack.architecture.sys_type())
if arch in _compiler_by_arch: if platform in _compiler_by_platform:
return _compiler_by_arch[arch] return _compiler_by_platform[platform]
cc_config = get_config('compilers') cc_config = get_config('compilers')
if arch in cc_config and 'all' in cc_config: if platform in cc_config and 'all' in cc_config:
arch_compiler = dict(cc_config[arch]) platform_compiler = dict(cc_config[platform])
_compiler_by_arch[arch] = _merge_dict(arch_compiler, cc_config['all']) _compiler_by_platform[platform] = _merge_dict(platform_compiler, cc_config['all'])
elif arch in cc_config: elif platform in cc_config:
_compiler_by_arch[arch] = cc_config[arch] _compiler_by_platform[platform] = cc_config[platform]
elif 'all' in cc_config: elif 'all' in cc_config:
_compiler_by_arch[arch] = cc_config['all'] _compiler_by_platform[platform] = cc_config['all']
else: else:
_compiler_by_arch[arch] = {} _compiler_by_platform[platform] = {}
return _compiler_by_arch[arch] return _compiler_by_platform[platform]
def get_mirror_config(): def get_mirror_config():
@ -371,11 +371,11 @@ def add_to_mirror_config(addition_dict, scope=None):
add_to_config('mirrors', addition_dict, scope) 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""" """Add compilers to the configuration files"""
if not arch: if not platform:
arch = spack.architecture.sys_type() platform = spack.architecture.sys_type()
add_to_config('compilers', { str(arch) : addition_dict }, scope) add_to_config('compilers', { str(platform) : addition_dict }, scope)
clear_config_caches() clear_config_caches()

View File

@ -156,7 +156,7 @@ def remove_install_directory(self, spec):
class YamlDirectoryLayout(DirectoryLayout): class YamlDirectoryLayout(DirectoryLayout):
"""Lays out installation directories like this:: """Lays out installation directories like this::
<install root>/ <install root>/
<architecture>/ <target>/
<compiler>-<compiler version>/ <compiler>-<compiler version>/
<name>-<version>-<variants>-<hash> <name>-<version>-<variants>-<hash>
@ -201,7 +201,7 @@ def relative_path_for_spec(self, spec):
spec.dag_hash(self.hash_len)) spec.dag_hash(self.hash_len))
path = join_path( path = join_path(
spec.architecture, spec.target,
"%s-%s" % (spec.compiler.name, spec.compiler.version), "%s-%s" % (spec.compiler.name, spec.compiler.version),
dir_name) dir_name)

View File

@ -193,7 +193,7 @@ class Dotkit(EnvModule):
@property @property
def file_name(self): def file_name(self):
return join_path(Dotkit.path, self.spec.architecture, return join_path(Dotkit.path, self.spec.target,
self.spec.format('$_$@$%@$+$#.dk')) self.spec.format('$_$@$%@$+$#.dk'))
@property @property
@ -230,7 +230,7 @@ class TclModule(EnvModule):
@property @property
def file_name(self): 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 @property

View File

@ -592,7 +592,7 @@ def compiler(self):
"""Get the spack.compiler.Compiler object used to build this package.""" """Get the spack.compiler.Compiler object used to build this package."""
if not self.spec.concrete: if not self.spec.concrete:
raise ValueError("Can only get a compiler for a concrete package.") 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): def url_version(self, version):

View File

@ -1,8 +1,8 @@
import os import os
from spack.architecture import Architecture, Target from spack.architecture import Platform, Target
class Bgq(Architecture): class Bgq(Platform):
priority = 30 priority = 30
front_end = 'power7' front_end = 'power7'
back_end = 'powerpc' back_end = 'powerpc'

View File

@ -1,8 +1,8 @@
import os import os
from spack.architecture import Architecture, Target from spack.architecture import Platform, Target
class Cray(Architecture): class Cray(Platform):
priority = 20 priority = 20
front_end = 'sandybridge' front_end = 'sandybridge'
back_end = 'ivybridge' back_end = 'ivybridge'

View File

@ -1,7 +1,7 @@
import subprocess import subprocess
from spack.architecture import Architecture, Target from spack.architecture import Platform, Target
class Darwin(Architecture): class Darwin(Platform):
priority = 89 priority = 89
front_end = 'x86_64' front_end = 'x86_64'
back_end = 'x86_64' back_end = 'x86_64'
@ -13,6 +13,6 @@ def __init__(self):
@classmethod @classmethod
def detect(self): def detect(self):
arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE) platform = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
arch, _ = arch.communicate() platform, _ = platform.communicate()
return 'darwin' in arch.strip().lower() return 'darwin' in platform.strip().lower()

View File

@ -1,7 +1,7 @@
import subprocess import subprocess
from spack.architecture import Architecture, Target from spack.architecture import Platform, Target
class Linux(Architecture): class Linux(Platform):
priority = 90 priority = 90
front_end = 'x86_64' front_end = 'x86_64'
back_end = 'x86_64' back_end = 'x86_64'
@ -13,6 +13,6 @@ def __init__(self):
@classmethod @classmethod
def detect(self): def detect(self):
arch = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE) platform = subprocess.Popen(['uname', '-a'], stdout = subprocess.PIPE)
arch, _ = arch.communicate() platform, _ = platform.communicate()
return 'linux' in arch.strip().lower() return 'linux' in platform.strip().lower()

View File

@ -163,11 +163,11 @@ def variant_compare(self, pkgname, a, b):
return self._component_compare(pkgname, 'variant', a, b, False, None) return self._component_compare(pkgname, 'variant', a, b, False, None)
def architecture_compare(self, pkgname, a, b): def target_compare(self, pkgname, a, b):
"""Return less-than-0, 0, or greater than 0 if architecture a of pkgname is """Return less-than-0, 0, or greater than 0 if target a of pkgname is
respecively less-than, equal-to, or greater-than architecture b of pkgname. respecively less-than, equal-to, or greater-than target b of pkgname.
One architecture is less-than another if it is preferred over the other.""" One target is less-than another if it is preferred over the other."""
return self._component_compare(pkgname, 'architecture', a, b, False, None) return self._component_compare(pkgname, 'target', a, b, False, None)
def compiler_compare(self, pkgname, a, b): def compiler_compare(self, pkgname, a, b):

View File

@ -63,7 +63,7 @@
if it comes immediately after the compiler name. Otherwise it will be if it comes immediately after the compiler name. Otherwise it will be
associated with the current package spec. 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 cross-compilation is required
Here is the EBNF grammar for a spec:: Here is the EBNF grammar for a spec::
@ -72,9 +72,9 @@
dep_list = { ^ spec } dep_list = { ^ spec }
spec = id [ options ] spec = id [ options ]
options = { @version-list | +variant | -variant | ~variant | options = { @version-list | +variant | -variant | ~variant |
%compiler | =architecture } %compiler | =target }
variant = id variant = id
architecture = id target = id
compiler = id [ version-list ] compiler = id [ version-list ]
version-list = version [ { , version } ] version-list = version [ { , version } ]
version = id | id: | :id | id:id version = id | id: | :id | id:id
@ -119,7 +119,7 @@
# Convenient names for color formats so that other things can use them # Convenient names for color formats so that other things can use them
compiler_color = '@g' compiler_color = '@g'
version_color = '@c' version_color = '@c'
architecture_color = '@m' target_color = '@m'
enabled_variant_color = '@B' enabled_variant_color = '@B'
disabled_variant_color = '@r' disabled_variant_color = '@r'
dependency_color = '@.' dependency_color = '@.'
@ -130,7 +130,7 @@
See spack.color for descriptions of the color codes. """ See spack.color for descriptions of the color codes. """
color_formats = {'%' : compiler_color, color_formats = {'%' : compiler_color,
'@' : version_color, '@' : version_color,
'=' : architecture_color, '=' : target_color,
'+' : enabled_variant_color, '+' : enabled_variant_color,
'~' : disabled_variant_color, '~' : disabled_variant_color,
'^' : dependency_color, '^' : dependency_color,
@ -407,7 +407,7 @@ def __init__(self, spec_like, *dep_like, **kwargs):
self.name = other.name self.name = other.name
self.dependents = other.dependents self.dependents = other.dependents
self.versions = other.versions self.versions = other.versions
self.architecture = other.architecture self.target = other.target
self.compiler = other.compiler self.compiler = other.compiler
self.dependencies = other.dependencies self.dependencies = other.dependencies
self.variants = other.variants self.variants = other.variants
@ -452,11 +452,11 @@ def _set_compiler(self, compiler):
self.compiler = compiler self.compiler = compiler
def _set_architecture(self, architecture): def _set_target(self, target):
"""Called by the parser to set the architecture.""" """Called by the parser to set the target."""
if self.architecture: raise DuplicateArchitectureError( if self.target: raise DuplicateTargetError(
"Spec for '%s' cannot have two architectures." % self.name) "Spec for '%s' cannot have two targets." % self.name)
self.architecture = architecture self.target = target
def _add_dependency(self, spec): def _add_dependency(self, spec):
@ -512,7 +512,7 @@ def is_virtual(name):
@property @property
def concrete(self): def concrete(self):
"""A spec is concrete if it can describe only ONE build of a package. """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. variants, or depdenencies are ambiguous,then it is not concrete.
""" """
if self._concrete: if self._concrete:
@ -521,7 +521,7 @@ def concrete(self):
self._concrete = bool(not self.virtual self._concrete = bool(not self.virtual
and self.versions.concrete and self.versions.concrete
and self.variants.concrete and self.variants.concrete
and self.architecture and self.target
and self.compiler and self.compiler.concrete and self.compiler and self.compiler.concrete
and self.dependencies.concrete) and self.dependencies.concrete)
return self._concrete return self._concrete
@ -656,10 +656,10 @@ def to_node_dict(self):
'dependencies' : dict((d, self.dependencies[d].dag_hash()) 'dependencies' : dict((d, self.dependencies[d].dag_hash())
for d in sorted(self.dependencies)) for d in sorted(self.dependencies))
} }
if self.architecture: if self.target:
d['arch'] = self.architecture.to_dict() d['target'] = self.target.to_dict()
else: else:
d['arch'] = None d['target'] = None
if self.compiler: if self.compiler:
d.update(self.compiler.to_dict()) d.update(self.compiler.to_dict())
else: else:
@ -685,7 +685,7 @@ def from_node_dict(node):
spec = Spec(name) spec = Spec(name)
spec.versions = VersionList.from_dict(node) 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: if node['compiler'] is None:
spec.compiler = 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 # to presets below, their constraints will all be merged, but we'll
# still need to select a concrete package later. # still need to select a concrete package later.
changed |= any( changed |= any(
(spack.concretizer.concretize_architecture(self), (spack.concretizer.concretize_target(self),
spack.concretizer.concretize_compiler(self), spack.concretizer.concretize_compiler(self),
spack.concretizer.concretize_version(self), spack.concretizer.concretize_version(self),
spack.concretizer.concretize_variants(self))) spack.concretizer.concretize_variants(self)))
@ -1145,10 +1145,10 @@ def constrain(self, other, deps=True):
raise UnsatisfiableVariantSpecError(self.variants[v], raise UnsatisfiableVariantSpecError(self.variants[v],
other.variants[v]) other.variants[v])
if self.architecture is not None and other.architecture is not None: if self.target is not None and other.target is not None:
if self.architecture != other.architecture: if self.target != other.target:
raise UnsatisfiableArchitectureSpecError(self.architecture, raise UnsatisfiableTargetSpecError(self.target,
other.architecture) other.target)
changed = False changed = False
if self.compiler is not None and other.compiler is not None: 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.versions.intersect(other.versions)
changed |= self.variants.constrain(other.variants) changed |= self.variants.constrain(other.variants)
old = self.architecture old = self.target
self.architecture = self.architecture or other.architecture self.target = self.target or other.target
changed |= (self.architecture != old) changed |= (self.target != old)
if deps: if deps:
changed |= self._constrain_dependencies(other) 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): if not self.variants.satisfies(other.variants, strict=strict):
return False return False
# Architecture satisfaction is currently just string equality. # Target satisfaction is currently just class equality.
# If not strict, None means unconstrained. # If not strict, None means unconstrained.
if self.architecture and other.architecture: if self.target and other.target:
if self.architecture != other.architecture: if self.target != other.target:
return False return False
elif strict and (other.architecture and not self.architecture): elif strict and (other.target and not self.target):
return False return False
# If we need to descend into dependencies, do it, otherwise we're done. # If we need to descend into dependencies, do it, otherwise we're done.
@ -1352,7 +1352,7 @@ def _dup(self, other, **kwargs):
changed = True changed = True
if hasattr(self, 'name'): if hasattr(self, 'name'):
changed = (self.name != other.name and self.versions != other.versions and \ 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.variants != other.variants and self._normal != other._normal and \
self.concrete != other.concrete and self.external != other.external and \ self.concrete != other.concrete and self.external != other.external and \
self.external_module != other.external_module) self.external_module != other.external_module)
@ -1360,7 +1360,7 @@ def _dup(self, other, **kwargs):
# Local node attributes get copied first. # Local node attributes get copied first.
self.name = other.name self.name = other.name
self.versions = other.versions.copy() self.versions = other.versions.copy()
self.architecture = other.architecture self.target = other.target
self.compiler = other.compiler.copy() if other.compiler else None self.compiler = other.compiler.copy() if other.compiler else None
if kwargs.get('cleardeps', True): if kwargs.get('cleardeps', True):
self.dependents = DependencyMap() self.dependents = DependencyMap()
@ -1490,7 +1490,7 @@ def ne_dag(self, other):
def _cmp_node(self): def _cmp_node(self):
"""Comparison key for just *this node* and not its deps.""" """Comparison key for just *this node* and not its deps."""
return (self.name, self.versions, self.variants, return (self.name, self.versions, self.variants,
self.architecture, self.compiler) self.target, self.compiler)
def eq_node(self, other): def eq_node(self, other):
@ -1524,7 +1524,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
$% Compiler with '%' prefix $% Compiler with '%' prefix
$%@ Compiler with '%' prefix & compiler version with '@' prefix $%@ Compiler with '%' prefix & compiler version with '@' prefix
$+ Options $+ Options
$= Architecture with '=' prefix $= Target with '=' prefix
$# 7-char prefix of DAG hash with '-' prefix $# 7-char prefix of DAG hash with '-' prefix
$$ $ $$ $
@ -1536,7 +1536,7 @@ def format(self, format_string='$_$@$%@$+$=', **kwargs):
${COMPILERNAME} Compiler name ${COMPILERNAME} Compiler name
${COMPILERVER} Compiler version ${COMPILERVER} Compiler version
${OPTIONS} Options ${OPTIONS} Options
${ARCHITECTURE} Architecture ${TARGET} Target
${SHA1} Dependencies 8-char sha1 prefix ${SHA1} Dependencies 8-char sha1 prefix
${SPACK_ROOT} The spack root directory ${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. Anything else is copied verbatim into the output stream.
*Example:* ``$_$@$+`` translates to the name, version, and options *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., $6# to customize short hash length
TODO: allow, e.g., $## for full hash. TODO: allow, e.g., $## for full hash.
@ -1593,8 +1593,8 @@ def write(s, c):
if self.variants: if self.variants:
write(fmt % str(self.variants), c) write(fmt % str(self.variants), c)
elif c == '=': elif c == '=':
if self.architecture: if self.target:
write(fmt % (c + str(self.architecture)), c) write(fmt % (c + str(self.target)), c)
elif c == '#': elif c == '#':
out.write('-' + fmt % (self.dag_hash(7))) out.write('-' + fmt % (self.dag_hash(7)))
elif c == '$': elif c == '$':
@ -1641,9 +1641,9 @@ def write(s, c):
elif named_str == 'OPTIONS': elif named_str == 'OPTIONS':
if self.variants: if self.variants:
write(fmt % str(self.variants), '+') write(fmt % str(self.variants), '+')
elif named_str == 'ARCHITECTURE': elif named_str == 'TARGET':
if self.architecture: if self.target:
write(fmt % str(self.architecture), '=') write(fmt % str(self.target), '=')
elif named_str == 'SHA1': elif named_str == 'SHA1':
if self.dependencies: if self.dependencies:
out.write(fmt % str(self.dep_hash(8))) out.write(fmt % str(self.dep_hash(8)))
@ -1691,10 +1691,10 @@ def __cmp__(self, other):
return spack.pkgsort.variant_compare(pkgname, return spack.pkgsort.variant_compare(pkgname,
self.variants, other.variants) self.variants, other.variants)
#Architecture #Target
if self.architecture != other.architecture: if self.target != other.target:
return spack.pkgsort.architecture_compare(pkgname, return spack.pkgsort.target_compare(pkgname,
self.architecture, other.architecture) self.target, other.target)
#Dependency is not configurable #Dependency is not configurable
if self.dep_hash() != other.dep_hash(): if self.dep_hash() != other.dep_hash():
@ -1811,7 +1811,7 @@ def spec(self):
spec.name = self.token.value spec.name = self.token.value
spec.versions = VersionList() spec.versions = VersionList()
spec.variants = VariantMap(spec) spec.variants = VariantMap(spec)
spec.architecture = None spec.target = None
spec.compiler = None spec.compiler = None
spec.external = None spec.external = None
spec.external_module = None spec.external_module = None
@ -1842,7 +1842,7 @@ def spec(self):
spec._set_compiler(self.compiler()) spec._set_compiler(self.compiler())
elif self.accept(EQ): elif self.accept(EQ):
spec._set_architecture(self.architecture()) spec._set_target(self.target())
else: else:
break break
@ -1860,7 +1860,7 @@ def variant(self):
return self.token.value return self.token.value
def architecture(self): def target(self):
self.expect(ID) self.expect(ID)
return self.token.value return self.token.value
@ -2000,10 +2000,10 @@ def __init__(self, pkg, variant):
"Package %s has no variant %s!" % (pkg, variant)) "Package %s has no variant %s!" % (pkg, variant))
class DuplicateArchitectureError(SpecError): class DuplicateTargetError(SpecError):
"""Raised when the same architecture occurs in a spec twice.""" """Raised when the same target occurs in a spec twice."""
def __init__(self, message): def __init__(self, message):
super(DuplicateArchitectureError, self).__init__(message) super(DuplicateTargetError, self).__init__(message)
class InconsistentSpecError(SpecError): class InconsistentSpecError(SpecError):
@ -2082,11 +2082,11 @@ def __init__(self, provided, required):
provided, required, "variant") provided, required, "variant")
class UnsatisfiableArchitectureSpecError(UnsatisfiableSpecError): class UnsatisfiableTargetSpecError(UnsatisfiableSpecError):
"""Raised when a spec architecture conflicts with package constraints.""" """Raised when a spec target conflicts with package constraints."""
def __init__(self, provided, required): def __init__(self, provided, required):
super(UnsatisfiableArchitectureSpecError, self).__init__( super(UnsatisfiableTargetSpecError, self).__init__(
provided, required, "architecture") provided, required, "target")
class UnsatisfiableProviderSpecError(UnsatisfiableSpecError): class UnsatisfiableProviderSpecError(UnsatisfiableSpecError):

View File

@ -6,13 +6,14 @@
import platform import platform
import spack import spack
from spack.architecture import * from spack.architecture import *
from spack.architectures.cray import Cray from spack.platforms.cray import Cray
from spack.architectures.linux import Linux from spack.platforms.linux import Linux
from spack.architectures.bgq import Bgq from spack.platforms.bgq import Bgq
from spack.platforms.darwin import Darwin
class ArchitectureTest(unittest.TestCase): class ArchitectureTest(unittest.TestCase):
def test_Architecture_class_and_compiler_strategies(self): def test_platform_class_and_compiler_strategies(self):
a = Cray() a = Cray()
t = a.target('default') t = a.target('default')
self.assertEquals(t.compiler_strategy, 'MODULES') self.assertEquals(t.compiler_strategy, 'MODULES')
@ -21,15 +22,15 @@ def test_Architecture_class_and_compiler_strategies(self):
self.assertEquals(s.compiler_strategy, 'PATH') self.assertEquals(s.compiler_strategy, 'PATH')
def test_sys_type(self): def test_sys_type(self):
output_arch_class = sys_type() output_platform_class = sys_type()
my_arch_class = None my_arch_class = None
if os.path.exists('/opt/cray/craype'): if os.path.exists('/opt/cray/craype'):
my_arch_class = Cray() my_platform_class = Cray()
elif os.path.exists('/bgsys'): elif os.path.exists('/bgsys'):
my_arch_class = Bgq() my_platform_class = Bgq()
elif 'Linux' in platform.system(): elif 'Linux' in platform.system():
my_arch_class = Linux() my_platform_class = Linux()
# elif 'Darwin' in platform.system(): elif 'Darwin' in platform.system():
# my_arch_class = Darwin() my_platform_class = Darwin()
self.assertEqual(str(output_arch_class), str(my_arch_class)) self.assertEqual(str(output_platform_class), str(my_platform_class))

View File

@ -46,8 +46,8 @@ def check_spec(self, abstract, concrete):
if abstract.compiler and abstract.compiler.concrete: if abstract.compiler and abstract.compiler.concrete:
self.assertEqual(abstract.compiler, concrete.compiler) self.assertEqual(abstract.compiler, concrete.compiler)
if abstract.architecture and abstract.architecture.concrete: if abstract.target and abstract.target.concrete:
self.assertEqual(abstract.architecture, concrete.architecture) self.assertEqual(abstract.target, concrete.target)
def check_concretize(self, abstract_spec): def check_concretize(self, abstract_spec):

View File

@ -91,21 +91,21 @@ def test_default_works(self):
self.assertEqual(pkg.has_a_default(), 'default') self.assertEqual(pkg.has_a_default(), 'default')
def test_architecture_match(self): def test_target_match(self):
pkg = spack.db.get('multimethod=x86_64') 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') 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') 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') 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') 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): def test_dependency_match(self):

View File

@ -240,10 +240,10 @@ def test_unsatisfiable_compiler_version(self):
self.assertRaises(spack.spec.UnsatisfiableCompilerSpecError, spec.normalize) self.assertRaises(spack.spec.UnsatisfiableCompilerSpecError, spec.normalize)
def test_unsatisfiable_architecture(self): def test_unsatisfiable_target(self):
set_pkg_dep('mpileaks', 'mpich=bgqos_0') set_pkg_dep('mpileaks', 'mpich=bgqos_0')
spec = Spec('mpileaks ^mpich=sles_10_ppc64 ^callpath ^dyninst ^libelf ^libdwarf') 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): def test_invalid_dep(self):

View File

@ -110,7 +110,7 @@ def test_satisfies_compiler_version(self):
self.check_unsatisfiable('foo %gcc@4.7', '%gcc@4.7.3') 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=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib')
self.check_satisfies('foo=bgqos_0', '=bgqos_0') 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') 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=bgqos_0', 'libelf=bgqos_0')
self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0') self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0')

View File

@ -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') @when('=x86_64')
def different_by_architecture(self): def different_by_target(self):
return 'x86_64' return 'x86_64'
@when('=ppc64') @when('=ppc64')
def different_by_architecture(self): def different_by_target(self):
return 'ppc64' return 'ppc64'
@when('=ppc32') @when('=ppc32')
def different_by_architecture(self): def different_by_target(self):
return 'ppc32' return 'ppc32'
@when('=arm64') @when('=arm64')
def different_by_architecture(self): def different_by_target(self):
return 'arm64' return 'arm64'