summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMario Melara <maamelara@gmail.com>2015-10-07 14:55:05 -0700
committerMario Melara <maamelara@gmail.com>2015-10-07 14:55:05 -0700
commit06fe87974516c510b950b3fd9044ad34ee25aa3c (patch)
treebdf359c7bd74527ab5c9c1921d137b79302fa0d1 /lib
parentf4e72f33c8ba988507aba667e318d1861c7b2b20 (diff)
parentd00314c621bd427b142fecafc11c25006f3b5279 (diff)
downloadspack-06fe87974516c510b950b3fd9044ad34ee25aa3c.tar.gz
spack-06fe87974516c510b950b3fd9044ad34ee25aa3c.tar.bz2
spack-06fe87974516c510b950b3fd9044ad34ee25aa3c.tar.xz
spack-06fe87974516c510b950b3fd9044ad34ee25aa3c.zip
Merge branch 'features/crayproto' of https://github.com/scalability-llnl/spack into develop
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc17
-rw-r--r--lib/spack/spack/build_environment.py9
-rw-r--r--lib/spack/spack/compiler.py67
-rw-r--r--lib/spack/spack/compilers/__init__.py9
-rw-r--r--lib/spack/spack/compilers/clang.py2
-rw-r--r--lib/spack/spack/compilers/gcc.py7
-rw-r--r--lib/spack/spack/compilers/intel.py3
-rw-r--r--lib/spack/spack/compilers/pgi.py3
-rw-r--r--lib/spack/spack/compilers/xl.py4
9 files changed, 116 insertions, 5 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index fa85bb595e..b6c6e03e42 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -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.
diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py
index a133faa629..68388958f5 100644
--- a/lib/spack/spack/build_environment.py
+++ b/lib/spack/spack/build_environment.py
@@ -57,6 +57,9 @@ SPACK_DEBUG = 'SPACK_DEBUG'
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.
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index 1e800a8979..e7d450ee8b 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -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 @@ class Compiler(object):
self.fc = check(fc)
self.spec = cspec
+ self.module = module
+
@property
@@ -255,6 +265,61 @@ class Compiler(object):
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__()
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index b7b021a1ac..8c4cb38926 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -44,6 +44,7 @@ from spack.util.environment import get_path
_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()]
diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py
index 790901c86e..8d32608ff4 100644
--- a/lib/spack/spack/compilers/clang.py
+++ b/lib/spack/spack/compilers/clang.py
@@ -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::
diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py
index f0d27d590e..ff0b8889a8 100644
--- a/lib/spack/spack/compilers/gcc.py
+++ b/lib/spack/spack/compilers/gcc.py
@@ -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 @@ class Gcc(Compiler):
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)
diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py
index 2a72c4eaea..7c485fe69d 100644
--- a/lib/spack/spack/compilers/intel.py
+++ b/lib/spack/spack/compilers/intel.py
@@ -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'):
diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py
index d97f24c12e..8f1ed28825 100644
--- a/lib/spack/spack/compilers/pgi.py
+++ b/lib/spack/spack/compilers/pgi.py
@@ -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.
diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py
index 562186b865..179b720918 100644
--- a/lib/spack/spack/compilers/xl.py
+++ b/lib/spack/spack/compilers/xl.py
@@ -45,8 +45,9 @@ class Xl(Compiler):
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 @@ class Xl(Compiler):
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.