First possibly working version of the crayport. Not sufficiently tested at all.
This commit is contained in:
parent
ee0bc0a0ec
commit
30bd0b1ab8
@ -61,18 +61,20 @@ def __init__(self,name, module_name=None):
|
|||||||
|
|
||||||
def set_architecture(self, architecture): # Target should get the architecture class.
|
def set_architecture(self, architecture): # Target should get the architecture class.
|
||||||
self.architecture = architecture
|
self.architecture = architecture
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def compiler_strategy(self):
|
def compiler_strategy(self):
|
||||||
if default_strategy:
|
if self.module_name: # If there is a module_name given then use MODULES
|
||||||
return default_strategy
|
|
||||||
elif self.module_name: # If there is a module_name given then use MODULES
|
|
||||||
return "MODULES"
|
return "MODULES"
|
||||||
else:
|
else:
|
||||||
return "PATH"
|
return "PATH"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class Architecture(object):
|
class Architecture(object):
|
||||||
""" Abstract class that each type of Architecture will subclass. Will return a instance of it once it
|
""" Abstract class that each type of Architecture will subclass. Will return a instance of it once it
|
||||||
is returned
|
is returned
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -110,12 +112,15 @@ 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 architecture detects if it is the current architecture
|
||||||
and False if it's not.
|
and False if it's not.
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.__str__
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
@ -123,7 +128,7 @@ def __str__(self):
|
|||||||
def get_sys_type_from_spack_globals():
|
def get_sys_type_from_spack_globals():
|
||||||
"""Return the SYS_TYPE from spack globals, or None if it isn't set."""
|
"""Return the SYS_TYPE from spack globals, or None if it isn't set."""
|
||||||
if not hasattr(spack, "sys_type"):
|
if not hasattr(spack, "sys_type"):
|
||||||
return None
|
return None
|
||||||
elif hasattr(spack.sys_type, "__call__"):
|
elif hasattr(spack.sys_type, "__call__"):
|
||||||
return spack.sys_type() #If in __init__.py there is a sys_type() then call that
|
return spack.sys_type() #If in __init__.py there is a sys_type() then call that
|
||||||
else:
|
else:
|
||||||
@ -147,7 +152,7 @@ def get_mac_sys_type():
|
|||||||
|
|
||||||
|
|
||||||
def get_sys_type_from_uname():
|
def get_sys_type_from_uname():
|
||||||
""" Returns a sys_type from the uname argument
|
""" Returns a sys_type from the uname argument
|
||||||
Front-end config
|
Front-end config
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@ -158,8 +163,8 @@ def get_sys_type_from_uname():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_sys_type_from_config_file():
|
def get_sys_type_from_config_file():
|
||||||
|
|
||||||
spack_home_dir = os.environ["HOME"] + "/.spack"
|
spack_home_dir = os.environ["HOME"] + "/.spack"
|
||||||
yaml_file = os.path.join(spack_home_dir, 'architecture.yaml')
|
yaml_file = os.path.join(spack_home_dir, 'architecture.yaml')
|
||||||
try:
|
try:
|
||||||
config_dict = yaml.load(open(yaml_file)) # Fix this to have yaml.load()
|
config_dict = yaml.load(open(yaml_file)) # Fix this to have yaml.load()
|
||||||
@ -167,7 +172,7 @@ def get_sys_type_from_config_file():
|
|||||||
front = arch['front']
|
front = arch['front']
|
||||||
back = arch['back']
|
back = arch['back']
|
||||||
return Architecture(front,back)
|
return Architecture(front,back)
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print "No architecture.yaml config file found"
|
print "No architecture.yaml config file found"
|
||||||
return None
|
return None
|
||||||
@ -182,7 +187,7 @@ def all_architectures():
|
|||||||
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):
|
||||||
tty.die('No class %s defined in %s' % (class_name, mod_name))
|
tty.die('No class %s defined in %s' % (class_name, mod_name))
|
||||||
cls = getattr(mod, class_name)
|
cls = getattr(mod, class_name)
|
||||||
if not inspect.isclass(cls):
|
if not inspect.isclass(cls):
|
||||||
tty.die('%s.%s is not a class' % (mod_name, class_name))
|
tty.die('%s.%s is not a class' % (mod_name, class_name))
|
||||||
@ -197,15 +202,15 @@ def sys_type():
|
|||||||
1. YAML file that the user specifies the name of the architecture. e.g Cray-XC40 or Cray-XC30
|
1. YAML file that the user specifies the name of the architecture. e.g Cray-XC40 or Cray-XC30
|
||||||
2. UNAME
|
2. UNAME
|
||||||
3. GLOBALS
|
3. GLOBALS
|
||||||
4. MAC OSX
|
4. MAC OSX
|
||||||
Yaml should be a priority here because we want the user to be able to specify the type of architecture to use.
|
Yaml should be a priority here because we want the user to be able to specify the type of architecture to use.
|
||||||
If there is no yaml present then it should move on to the next function and stop immediately once it gets a
|
If there is no yaml present then it should move on to the next function and stop immediately once it gets a
|
||||||
arch name
|
arch name
|
||||||
"""
|
"""
|
||||||
# Try to create an architecture object using the config file FIRST
|
# Try to create an architecture object using the config file FIRST
|
||||||
architecture_list = all_architectures()
|
architecture_list = all_architectures()
|
||||||
architecture_list.sort(key = lambda a: a.priority)
|
architecture_list.sort(key = lambda a: a.priority)
|
||||||
|
|
||||||
for arch in architecture_list:
|
for arch in architecture_list:
|
||||||
if arch.detect():
|
if arch.detect():
|
||||||
return arch()
|
return arch()
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import subprocess
|
import subprocess
|
||||||
from spack.architecture import Architecture
|
from spack.architecture import Architecture, Target
|
||||||
|
|
||||||
class Linux(Architecture):
|
class Linux(Architecture):
|
||||||
priority = 60
|
priority = 60
|
||||||
front_end = "x86_64"
|
front_end = 'linux'
|
||||||
back_end = "x86_64"
|
back_end = 'linux'
|
||||||
default = "x86_64"
|
default = 'linux'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Linux, self).__init__('linux')
|
super(Linux, self).__init__('linux')
|
||||||
|
self.add_target('linux', Target('linux'))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def detect(self):
|
def detect(self):
|
||||||
|
@ -88,13 +88,13 @@ def __call__(self, *args, **kwargs):
|
|||||||
|
|
||||||
def load_module(mod):
|
def load_module(mod):
|
||||||
"""Takes a module name and removes modules until it is possible to
|
"""Takes a module name and removes modules until it is possible to
|
||||||
load that module. It then loads the provided module. Depends on the
|
load that module. It then loads the provided module. Depends on the
|
||||||
modulecmd implementation of modules used in cray and lmod.
|
modulecmd implementation of modules used in cray and lmod.
|
||||||
"""
|
"""
|
||||||
#Create an executable of the module command that will output python code
|
#Create an executable of the module command that will output python code
|
||||||
modulecmd = which('modulecmd')
|
modulecmd = which('modulecmd')
|
||||||
modulecmd.add_default_arg('python')
|
modulecmd.add_default_arg('python')
|
||||||
|
|
||||||
# Read the module and remove any conflicting modules
|
# Read the module and remove any conflicting modules
|
||||||
# We do this without checking that they are already installed
|
# We do this without checking that they are already installed
|
||||||
# for ease of programming because unloading a module that is not
|
# for ease of programming because unloading a module that is not
|
||||||
@ -102,7 +102,7 @@ def load_module(mod):
|
|||||||
text = modulecmd('show', mod, return_oe=True).split()
|
text = modulecmd('show', mod, return_oe=True).split()
|
||||||
for i, word in enumerate(text):
|
for i, word in enumerate(text):
|
||||||
if word == 'conflict':
|
if word == 'conflict':
|
||||||
exec(compile(modulecmd('unload', text[i+1], return_oe=True), '<string>', 'exec'))
|
exec(compile(modulecmd('unload', text[i+1], return_oe=True), '<string>', 'exec'))
|
||||||
# Load the module now that there are no conflicts
|
# Load the module now that there are no conflicts
|
||||||
load = modulecmd('load', mod, return_oe=True)
|
load = modulecmd('load', mod, return_oe=True)
|
||||||
exec(compile(load, '<string>', 'exec'))
|
exec(compile(load, '<string>', 'exec'))
|
||||||
|
@ -307,8 +307,12 @@ def __repr__(self):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"""Return a string represntation of the compiler toolchain."""
|
"""Return a string represntation of the compiler toolchain."""
|
||||||
return "%s(%s)" % (
|
if self.modules:
|
||||||
self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc))))
|
return "%s(%s)" % (
|
||||||
|
self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc, self.modules))))
|
||||||
|
else:
|
||||||
|
return "%s(%s)" % (
|
||||||
|
self.name, '\n '.join((str(s) for s in (self.cc, self.cxx, self.f77, self.fc))))
|
||||||
|
|
||||||
|
|
||||||
class CompilerAccessError(spack.error.SpackError):
|
class CompilerAccessError(spack.error.SpackError):
|
||||||
|
@ -44,15 +44,15 @@
|
|||||||
|
|
||||||
_imported_compilers_module = 'spack.compilers'
|
_imported_compilers_module = 'spack.compilers'
|
||||||
_required_instance_vars = ['cc', 'cxx', 'f77', 'fc']
|
_required_instance_vars = ['cc', 'cxx', 'f77', 'fc']
|
||||||
_optional_instance_vars = ['module']
|
_optional_instance_vars = ['modules']
|
||||||
|
|
||||||
_default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc']
|
_default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc']
|
||||||
|
|
||||||
def _auto_compiler_spec(function):
|
def _auto_compiler_spec(function):
|
||||||
def converter(cspec_like):
|
def converter(cspec_like, *args):
|
||||||
if not isinstance(cspec_like, spack.spec.CompilerSpec):
|
if not isinstance(cspec_like, spack.spec.CompilerSpec):
|
||||||
cspec_like = spack.spec.CompilerSpec(cspec_like)
|
cspec_like = spack.spec.CompilerSpec(cspec_like)
|
||||||
return function(cspec_like)
|
return function(cspec_like, *args)
|
||||||
return converter
|
return converter
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,32 +97,6 @@ def concretize_version(self, spec):
|
|||||||
|
|
||||||
|
|
||||||
def concretize_architecture(self, spec):
|
def concretize_architecture(self, spec):
|
||||||
"""If the spec already had an architecture, return. Otherwise if
|
|
||||||
the root of the DAG has an architecture, then use that.
|
|
||||||
Otherwise take the system's default architecture.
|
|
||||||
|
|
||||||
Intuition: Architectures won't be set a lot, and generally you
|
|
||||||
want the host system's architecture. When architectures are
|
|
||||||
mised in a spec, it is likely because the tool requries a
|
|
||||||
cross-compiled component, e.g. for tools that run on BlueGene
|
|
||||||
or Cray machines. These constraints will likely come directly
|
|
||||||
from packages, so require the user to be explicit if they want
|
|
||||||
to mess with the architecture, and revert to the default when
|
|
||||||
they're not explicit.
|
|
||||||
"""
|
|
||||||
if spec.architecture is not None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if spec.root.architecture:
|
|
||||||
spec.architecture = spec.root.architecture
|
|
||||||
else:
|
|
||||||
spec.architecture = spack.architecture.sys_type()
|
|
||||||
|
|
||||||
assert(spec.architecture is not None)
|
|
||||||
return True # changed
|
|
||||||
|
|
||||||
|
|
||||||
def new_concretize_architecture(self, spec):
|
|
||||||
"""If the spec already has an architecture and it is a an architecture type,
|
"""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
|
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
|
architecture based on that type. If it has no architecture and the root of the
|
||||||
@ -146,7 +120,7 @@ def new_concretize_architecture(self, spec):
|
|||||||
else:
|
else:
|
||||||
arch = spack.architecture.sys_type()
|
arch = spack.architecture.sys_type()
|
||||||
spec.architecture = arch.target('default')
|
spec.architecture = arch.target('default')
|
||||||
|
|
||||||
return True #changed
|
return True #changed
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,6 +199,7 @@ def get_config(category_name):
|
|||||||
category.result_dict = _merge_dicts(category.result_dict, result)
|
category.result_dict = _merge_dicts(category.result_dict, result)
|
||||||
else:
|
else:
|
||||||
category.result_dict = result
|
category.result_dict = result
|
||||||
|
|
||||||
return category.result_dict
|
return category.result_dict
|
||||||
|
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ def get_compilers_config(arch=None):
|
|||||||
configuration"""
|
configuration"""
|
||||||
global _compiler_by_arch
|
global _compiler_by_arch
|
||||||
if not arch:
|
if not arch:
|
||||||
arch = spack.architecture.sys_type()
|
arch = str(spack.architecture.sys_type())
|
||||||
if arch in _compiler_by_arch:
|
if arch in _compiler_by_arch:
|
||||||
return _compiler_by_arch[arch]
|
return _compiler_by_arch[arch]
|
||||||
|
|
||||||
@ -305,7 +306,7 @@ def add_to_compiler_config(addition_dict, scope=None, arch=None):
|
|||||||
"""Add compilerss to the configuration files"""
|
"""Add compilerss to the configuration files"""
|
||||||
if not arch:
|
if not arch:
|
||||||
arch = spack.architecture.sys_type()
|
arch = spack.architecture.sys_type()
|
||||||
add_to_config('compilers', { arch : addition_dict }, scope)
|
add_to_config('compilers', { str(arch) : addition_dict }, scope)
|
||||||
clear_config_caches()
|
clear_config_caches()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user