diff options
-rw-r--r-- | .coveragerc | 34 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .style.yapf | 3 | ||||
-rw-r--r-- | .travis.yml | 18 | ||||
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | flake8.ini | 3 | ||||
-rw-r--r-- | lib/spack/docs/packaging_guide.rst | 19 | ||||
-rw-r--r-- | lib/spack/spack/compiler.py | 37 | ||||
-rw-r--r-- | lib/spack/spack/compilers/clang.py | 25 | ||||
-rw-r--r-- | lib/spack/spack/compilers/gcc.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/compilers/intel.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/compilers/nag.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/compilers/pgi.py | 11 | ||||
-rw-r--r-- | lib/spack/spack/compilers/xl.py | 6 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/gdb/package.py | 1 | ||||
-rw-r--r-- | var/spack/repos/builtin/packages/kripke/package.py | 32 |
16 files changed, 207 insertions, 13 deletions
diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000000..a1271a94fc --- /dev/null +++ b/.coveragerc @@ -0,0 +1,34 @@ +# -*- conf -*- +# .coveragerc to control coverage.py +[run] +branch = True +source = lib +omit = + lib/spack/spack/test/* + lib/spack/env/* + lib/spack/docs/* + lib/spack/external/* + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain about missing debug-only code: + def __repr__ + if self\.debug + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + + # Don't complain if non-runnable code isn't run: + if 0: + if False: + if __name__ == .__main__.: + +ignore_errors = True + +[html] +directory = htmlcov diff --git a/.gitignore b/.gitignore index 4b97de5d50..643e5d9b03 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ /share/spack/dotkit /share/spack/modules /TAGS +/htmlcov +.coverage diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000000..4741fb4f3b --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +based_on_style = pep8 +column_limit = 80 diff --git a/.travis.yml b/.travis.yml index 1bed6b0874..4ff4d5f483 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,20 +6,32 @@ python: # Use new Travis infrastructure (Docker can't sudo yet) sudo: false -# No need to install any deps. -install: true +# Install coveralls to obtain code coverage +install: + - "pip install coveralls" + - "pip install flake8" before_install: # Need this for the git tests to succeed. - git config --global user.email "spack@example.com" - git config --global user.name "Test User" + # Need this to be able to compute the list of changed files + - git fetch origin develop:develop script: - . share/spack/setup-env.sh - spack compilers - spack config get compilers - - spack test - spack install -v libdwarf + # Run unit tests with code coverage + - coverage run bin/spack test + # Checks if the file that have been changed are flake8 conformant + - CHANGED_PYTHON_FILES=`git diff develop... --name-only | perl -ne 'print if /\.py$/'` + - if [[ ${CHANGED_PYTHON_FILES} ]] ; then flake8 --format pylint --config flake8.ini ${CHANGED_PYTHON_FILES} ; fi + + +after_success: + - coveralls notifications: email: @@ -1,7 +1,8 @@  ============ -[](https://travis-ci.org/LLNL/spack) +[](https://travis-ci.org/LLNL/spack) +[](https://coveralls.io/github/LLNL/spack?branch=develop) Spack is a package management tool designed to support multiple versions and configurations of software on a wide variety of platforms diff --git a/flake8.ini b/flake8.ini new file mode 100644 index 0000000000..757c71705e --- /dev/null +++ b/flake8.ini @@ -0,0 +1,3 @@ +[flake8] +ignore = W391,F403 +max-line-length = 120
\ No newline at end of file diff --git a/lib/spack/docs/packaging_guide.rst b/lib/spack/docs/packaging_guide.rst index 34d11308f5..31c676d4f5 100644 --- a/lib/spack/docs/packaging_guide.rst +++ b/lib/spack/docs/packaging_guide.rst @@ -1831,6 +1831,25 @@ successfully find ``libdwarf.h`` and ``libdwarf.so``, without the packager having to provide ``--with-libdwarf=/path/to/libdwarf`` on the command line. +Compiler flags +~~~~~~~~~~~~~~ +In rare circumstances such as compiling and running small unit tests, a package +developer may need to know what are the appropriate compiler flags to enable +features like ``OpenMP``, ``c++11``, ``c++14`` and alike. To that end the +compiler classes in ``spack`` implement the following _properties_ : +``openmp_flag``, ``cxx11_flag``, ``cxx14_flag``, which can be accessed in a +package by ``self.compiler.cxx11_flag`` and alike. Note that the implementation +is such that if a given compiler version does not support this feature, an +error will be produced. Therefore package developers can also use these properties +to assert that a compiler supports the requested feature. This is handy when a +package supports additional variants like + +.. code-block:: python + + variant('openmp', default=True, description="Enable OpenMP support.") + + + Message Parsing Interface (MPI) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It is common for high performance computing software/packages to use ``MPI``. diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py index 20896f9eec..b53c17494c 100644 --- a/lib/spack/spack/compiler.py +++ b/lib/spack/spack/compiler.py @@ -94,12 +94,6 @@ class Compiler(object): # Names of generic arguments used by this compiler arg_rpath = '-Wl,-rpath,%s' - # argument used to get C++11 options - cxx11_flag = "-std=c++11" - - # argument used to get C++14 options - cxx14_flag = "-std=c++1y" - def __init__(self, cspec, cc, cxx, f77, fc): def check(exe): @@ -120,6 +114,37 @@ class Compiler(object): def version(self): return self.spec.version + # This property should be overridden in the compiler subclass if + # OpenMP is supported by that compiler + @property + def openmp_flag(self): + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support OpenMP.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") + + + # This property should be overridden in the compiler subclass if + # C++11 is supported by that compiler + @property + def cxx11_flag(self): + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support C++11.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") + + + # This property should be overridden in the compiler subclass if + # C++14 is supported by that compiler + @property + def cxx14_flag(self): + # If it is not overridden, assume it is not supported and warn the user + tty.die("The compiler you have chosen does not currently support C++14.", + "If you think it should, please edit the compiler subclass and", + "submit a pull request or issue.") + + + # # Compiler classes have methods for querying the version of # specific compiler executables. This is used when discovering compilers. diff --git a/lib/spack/spack/compilers/clang.py b/lib/spack/spack/compilers/clang.py index e406d86a24..8c646905c7 100644 --- a/lib/spack/spack/compilers/clang.py +++ b/lib/spack/spack/compilers/clang.py @@ -26,6 +26,8 @@ import re import spack.compiler as cpr from spack.compiler import * from spack.util.executable import * +import llnl.util.tty as tty +from spack.version import ver class Clang(Compiler): # Subclasses use possible names of C compiler @@ -47,6 +49,29 @@ class Clang(Compiler): 'f77' : 'f77', 'fc' : 'f90' } + @property + def is_apple(self): + ver_string = str(self.version) + return ver_string.endswith('-apple') + + @property + def openmp_flag(self): + if self.is_apple: + tty.die("Clang from Apple does not support Openmp yet.") + else: + return "-fopenmp" + + @property + def cxx11_flag(self): + if self.is_apple: + # FIXME: figure out from which version Apple's clang supports c++11 + return "-std=c++11" + else: + if self.version < ver('3.3'): + tty.die("Only Clang 3.3 and above support c++11.") + else: + return "-std=c++11" + @classmethod def default_version(self, comp): """The '--version' option works for clang compilers. diff --git a/lib/spack/spack/compilers/gcc.py b/lib/spack/spack/compilers/gcc.py index 2e57e44856..91c498ac82 100644 --- a/lib/spack/spack/compilers/gcc.py +++ b/lib/spack/spack/compilers/gcc.py @@ -50,6 +50,10 @@ class Gcc(Compiler): 'fc' : 'gcc/gfortran' } @property + def openmp_flag(self): + return "-fopenmp" + + @property def cxx11_flag(self): if self.version < ver('4.3'): tty.die("Only gcc 4.3 and above support c++11.") diff --git a/lib/spack/spack/compilers/intel.py b/lib/spack/spack/compilers/intel.py index 69e9764790..9b1cf07c36 100644 --- a/lib/spack/spack/compilers/intel.py +++ b/lib/spack/spack/compilers/intel.py @@ -23,6 +23,8 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty +from spack.version import ver class Intel(Compiler): # Subclasses use possible names of C compiler @@ -44,6 +46,13 @@ class Intel(Compiler): 'fc' : 'intel/ifort' } @property + def openmp_flag(self): + if self.version < ver('16.0'): + return "-openmp" + else: + return "-qopenmp" + + @property def cxx11_flag(self): if self.version < ver('11.1'): tty.die("Only intel 11.1 and above support c++11.") @@ -68,5 +77,3 @@ class Intel(Compiler): """ return get_compiler_version( comp, '--version', r'\((?:IFORT|ICC)\) ([^ ]+)') - - diff --git a/lib/spack/spack/compilers/nag.py b/lib/spack/spack/compilers/nag.py index 527a05a090..e9038c1039 100644 --- a/lib/spack/spack/compilers/nag.py +++ b/lib/spack/spack/compilers/nag.py @@ -1,4 +1,5 @@ from spack.compiler import * +import llnl.util.tty as tty class Nag(Compiler): # Subclasses use possible names of C compiler @@ -20,6 +21,16 @@ class Nag(Compiler): 'f77' : 'nag/nagfor', 'fc' : 'nag/nagfor' } + @property + def openmp_flag(self): + return "-openmp" + + @property + def cxx11_flag(self): + # NAG does not have a C++ compiler + # However, it can be mixed with a compiler that does support it + return "-std=c++11" + @classmethod def default_version(self, comp): """The '-V' option works for nag compilers. diff --git a/lib/spack/spack/compilers/pgi.py b/lib/spack/spack/compilers/pgi.py index c6a1078bd9..94c6b8365c 100644 --- a/lib/spack/spack/compilers/pgi.py +++ b/lib/spack/spack/compilers/pgi.py @@ -23,6 +23,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty class Pgi(Compiler): # Subclasses use possible names of C compiler @@ -43,6 +44,15 @@ class Pgi(Compiler): 'f77' : 'pgi/pgfortran', 'fc' : 'pgi/pgfortran' } + @property + def openmp_flag(self): + return "-mp" + + @property + def cxx11_flag(self): + return "-std=c++11" + + @classmethod def default_version(cls, comp): """The '-V' option works for all the PGI compilers. @@ -54,4 +64,3 @@ class Pgi(Compiler): """ return get_compiler_version( comp, '-V', r'pg[^ ]* ([^ ]+) \d\d\d?-bit target') - diff --git a/lib/spack/spack/compilers/xl.py b/lib/spack/spack/compilers/xl.py index c1d55109a3..61a2e730dc 100644 --- a/lib/spack/spack/compilers/xl.py +++ b/lib/spack/spack/compilers/xl.py @@ -24,6 +24,8 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## from spack.compiler import * +import llnl.util.tty as tty +from spack.version import ver class Xl(Compiler): # Subclasses use possible names of C compiler @@ -45,6 +47,10 @@ class Xl(Compiler): 'fc' : 'xl/xlf90' } @property + def openmp_flag(self): + return "-qsmp=omp" + + @property def cxx11_flag(self): if self.version < ver('13.1'): tty.die("Only xlC 13.1 and above have some c++11 support.") diff --git a/var/spack/repos/builtin/packages/gdb/package.py b/var/spack/repos/builtin/packages/gdb/package.py index b346fe80c2..0e9e8fc099 100644 --- a/var/spack/repos/builtin/packages/gdb/package.py +++ b/var/spack/repos/builtin/packages/gdb/package.py @@ -34,6 +34,7 @@ class Gdb(Package): homepage = "https://www.gnu.org/software/gdb" url = "http://ftp.gnu.org/gnu/gdb/gdb-7.10.tar.gz" + version('7.11', 'f585059252836a981ea5db9a5f8ce97f') version('7.10.1', 'b93a2721393e5fa226375b42d567d90b') version('7.10', 'fa6827ad0fd2be1daa418abb11a54d86') version('7.9.1', 'f3b97de919a9dba84490b2e076ec4cb0') diff --git a/var/spack/repos/builtin/packages/kripke/package.py b/var/spack/repos/builtin/packages/kripke/package.py new file mode 100644 index 0000000000..7d067ea44d --- /dev/null +++ b/var/spack/repos/builtin/packages/kripke/package.py @@ -0,0 +1,32 @@ +from spack import * + +class Kripke(Package): + """Kripke is a simple, scalable, 3D Sn deterministic particle + transport proxy/mini app. + """ + homepage = "https://codesign.llnl.gov/kripke.php" + url = "https://codesign.llnl.gov/downloads/kripke-openmp-1.1.tar.gz" + + version('1.1', '7fe6f2b26ed983a6ce5495ab701f85bf') + + variant('mpi', default=True, description='Build with MPI.') + variant('openmp', default=True, description='Build with OpenMP enabled.') + + depends_on('mpi', when="+mpi") + + def install(self, spec, prefix): + with working_dir('build', create=True): + def enabled(variant): + return (1 if variant in spec else 0) + + cmake('-DCMAKE_INSTALL_PREFIX:PATH=.', + '-DENABLE_OPENMP=%d' % enabled('+openmp'), + '-DENABLE_MPI=%d' % enabled('+mpi'), + '..', + *std_cmake_args) + make() + + # Kripke does not provide install target, so we have to copy + # things into place. + mkdirp(prefix.bin) + install('kripke', prefix.bin) |