Protptype cray compiler detection and support
This commit is contained in:
parent
cc6252cdfa
commit
d00314c621
9 changed files with 116 additions and 5 deletions
17
lib/spack/env/cc
vendored
17
lib/spack/env/cc
vendored
|
@ -70,6 +70,23 @@ for param in $parameters; do
|
|||
fi
|
||||
done
|
||||
|
||||
|
||||
#
|
||||
# Cray module environment-related stuff.
|
||||
#
|
||||
if [ ! -z "$SPACK_CRAYPE" ]; then
|
||||
cur_pe=$(module list 2>&1 | grep PrgEnv | grep -o 'PrgEnv-[^/]*')
|
||||
if [ ! -z "$cur_pe" ]; then
|
||||
module swap $cur_pe $SPACK_CRAYPE
|
||||
else
|
||||
module load $SPACK_CRAYPE
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -z "$SPACK_COMP_MODULE" ]; then
|
||||
module load $SPACK_COMP_MODULE
|
||||
fi
|
||||
|
||||
#
|
||||
# Figure out the type of compiler, the language, and the mode so that
|
||||
# the compiler script knows what to do.
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
SPACK_SHORT_SPEC = 'SPACK_SHORT_SPEC'
|
||||
SPACK_DEBUG_LOG_DIR = 'SPACK_DEBUG_LOG_DIR'
|
||||
|
||||
SPACK_CRAYPE = 'SPACK_CRAYPE'
|
||||
SPACK_COMP_MODULE = 'SPACK_COMP_MODULE'
|
||||
|
||||
|
||||
class MakeExecutable(Executable):
|
||||
"""Special callable executable object for make so the user can
|
||||
|
@ -105,6 +108,12 @@ def set_compiler_environment_variables(pkg):
|
|||
|
||||
os.environ['SPACK_COMPILER_SPEC'] = str(pkg.spec.compiler)
|
||||
|
||||
if compiler.PrgEnv:
|
||||
os.environ['SPACK_CRAYPE'] = compiler.PrgEnv
|
||||
os.environ['SPACK_COMP_MODULE'] = compiler.module
|
||||
|
||||
|
||||
|
||||
|
||||
def set_build_environment_variables(pkg):
|
||||
"""This ensures a clean install environment when we build packages.
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
import os
|
||||
import re
|
||||
import itertools
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
import llnl.util.tty as tty
|
||||
|
@ -98,7 +99,14 @@ class Compiler(object):
|
|||
cxx11_flag = "-std=c++11"
|
||||
|
||||
|
||||
def __init__(self, cspec, cc, cxx, f77, fc):
|
||||
# Cray PrgEnv name that can be used to load this compiler
|
||||
PrgEnv = None
|
||||
|
||||
# Name of module used to switch versions of this compiler
|
||||
PrgEnv_compiler = None
|
||||
|
||||
|
||||
def __init__(self, cspec, cc, cxx, f77, fc, module=None):
|
||||
def check(exe):
|
||||
if exe is None:
|
||||
return None
|
||||
|
@ -111,6 +119,8 @@ def check(exe):
|
|||
self.fc = check(fc)
|
||||
|
||||
self.spec = cspec
|
||||
self.module = module
|
||||
|
||||
|
||||
|
||||
@property
|
||||
|
@ -255,6 +265,61 @@ def find(cls, *path):
|
|||
return list(compilers.values())
|
||||
|
||||
|
||||
@classmethod
|
||||
def find_in_modules(cls):
|
||||
compilers = []
|
||||
|
||||
if cls.PrgEnv:
|
||||
if not cls.PrgEnv_compiler:
|
||||
tty.die('Must supply PrgEnv_compiler with PrgEnv')
|
||||
|
||||
output = _shell('module avail %s' % cls.PrgEnv_compiler)
|
||||
matches = re.findall(r'(%s)/([^\s(]*)' % cls.PrgEnv_compiler, output)
|
||||
|
||||
for name, version in matches:
|
||||
v = version + '-craype'
|
||||
comp = cls(spack.spec.CompilerSpec(name + '@' + v),
|
||||
'cc', 'CC', 'ftn', 'ftn', name +'/' + v)
|
||||
|
||||
compilers.append(comp)
|
||||
|
||||
return compilers
|
||||
|
||||
|
||||
def _cur_prgenv():
|
||||
out, err = subprocess.Popen(
|
||||
['module list'], shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||
matches = re.findall(r'(PrgEnv-[^/]*)/', err)
|
||||
return matches[0]
|
||||
|
||||
|
||||
def _module_shell(module, *args):
|
||||
cmd = 'module swap %s %s;' % (_cur_prgenv(), module)
|
||||
cmd += 'module load %s;' % compiler
|
||||
cmd += 'module unload cray-libsci;'
|
||||
|
||||
# +
|
||||
# 'module load craype-network-gemini;' +
|
||||
# 'module load %s;' % module +
|
||||
# 'module swap gcc/4.6.1;' +
|
||||
# 'module load eswrap; ' +
|
||||
# 'module load craype-mc12; ' +
|
||||
# 'module load cray-shmem; ' +
|
||||
# 'module load cray-mpich; ')
|
||||
cmd += ' '.join(args)
|
||||
out, err = subprocess.Popen([cmd + ' '.join(args)], shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||
return out
|
||||
|
||||
|
||||
def _shell(*args):
|
||||
return subprocess.Popen([' '.join(args)], shell=True,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
|
||||
|
||||
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
"""Return a string represntation of the compiler toolchain."""
|
||||
return self.__str__()
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
_imported_compilers_module = 'spack.compilers'
|
||||
_required_instance_vars = ['cc', 'cxx', 'f77', 'fc']
|
||||
_optional_instance_vars = ['module']
|
||||
|
||||
_default_order = ['gcc', 'intel', 'pgi', 'clang', 'xlc']
|
||||
|
||||
|
@ -127,11 +128,18 @@ def add_compilers_to_config(scope, *compilers):
|
|||
compiler_config_tree = {}
|
||||
for compiler in compilers:
|
||||
compiler_entry = {}
|
||||
|
||||
for c in _required_instance_vars:
|
||||
val = getattr(compiler, c)
|
||||
if not val:
|
||||
val = "None"
|
||||
compiler_entry[c] = val
|
||||
|
||||
for c in _optional_instance_vars:
|
||||
val = getattr(compiler, c)
|
||||
if val:
|
||||
compiler_entry[c] = val
|
||||
|
||||
compiler_config_tree[str(compiler.spec)] = compiler_entry
|
||||
spack.config.add_to_compiler_config(compiler_config_tree, scope)
|
||||
|
||||
|
@ -220,6 +228,7 @@ def class_for_compiler_name(compiler_name):
|
|||
|
||||
|
||||
def all_compiler_types():
|
||||
# return [class_for_compiler_name(c) for c in ['gcc']]
|
||||
return [class_for_compiler_name(c) for c in supported_compilers()]
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class Clang(Compiler):
|
|||
|
||||
|
||||
@classmethod
|
||||
def default_version(self, comp):
|
||||
def default_version(cls, comp):
|
||||
"""The '--version' option works for clang compilers.
|
||||
Output looks like this::
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ class Gcc(Compiler):
|
|||
# MacPorts builds gcc versions with prefixes and -mp-X.Y suffixes.
|
||||
suffixes = [r'-mp-\d\.\d']
|
||||
|
||||
PrgEnv = 'gnu'
|
||||
PrgEnv_compiler = 'gcc'
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
if self.version < ver('4.3'):
|
||||
|
@ -56,9 +59,9 @@ def fc_version(cls, fc):
|
|||
return get_compiler_version(
|
||||
fc, '-dumpversion',
|
||||
# older gfortran versions don't have simple dumpversion output.
|
||||
r'(?:GNU Fortran \(GCC\))?(\d+\.\d+(?:\.\d+)?)')
|
||||
r'(?:GNU Fortran \(GCC\))?(\d+\.\d+(?:\.\d+)?)', module)
|
||||
|
||||
|
||||
@classmethod
|
||||
def f77_version(cls, f77):
|
||||
return cls.fc_version(f77)
|
||||
return cls.fc_version(f77, module)
|
||||
|
|
|
@ -37,6 +37,9 @@ class Intel(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['ifort']
|
||||
|
||||
PrgEnv = 'intel'
|
||||
PrgEnv_compiler = 'intel'
|
||||
|
||||
@property
|
||||
def cxx11_flag(self):
|
||||
if self.version < ver('11.1'):
|
||||
|
|
|
@ -37,6 +37,9 @@ class Pgi(Compiler):
|
|||
# Subclasses use possible names of Fortran 90 compiler
|
||||
fc_names = ['pgf95', 'pgf90']
|
||||
|
||||
PrgEnv = 'pgi'
|
||||
PrgEnv_compiler = 'pgi'
|
||||
|
||||
@classmethod
|
||||
def default_version(cls, comp):
|
||||
"""The '-V' option works for all the PGI compilers.
|
||||
|
|
|
@ -45,8 +45,9 @@ def cxx11_flag(self):
|
|||
else:
|
||||
return "-qlanglvl=extended0x"
|
||||
|
||||
|
||||
@classmethod
|
||||
def default_version(self, comp):
|
||||
def default_version(cls, comp):
|
||||
"""The '-qversion' is the standard option fo XL compilers.
|
||||
Output looks like this::
|
||||
|
||||
|
@ -72,6 +73,7 @@ def default_version(self, comp):
|
|||
return get_compiler_version(
|
||||
comp, '-qversion',r'([0-9]?[0-9]\.[0-9])')
|
||||
|
||||
|
||||
@classmethod
|
||||
def fc_version(cls, fc):
|
||||
"""The fortran and C/C++ versions of the XL compiler are always two units apart.
|
||||
|
|
Loading…
Reference in a new issue