From 631e235ef3907916335f965fa179b94455295f31 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Sun, 1 May 2016 11:05:51 +0200 Subject: Added Adol-C package --- var/spack/repos/builtin/packages/adol-c/package.py | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 var/spack/repos/builtin/packages/adol-c/package.py (limited to 'var') diff --git a/var/spack/repos/builtin/packages/adol-c/package.py b/var/spack/repos/builtin/packages/adol-c/package.py new file mode 100644 index 0000000000..a65ec7dd7c --- /dev/null +++ b/var/spack/repos/builtin/packages/adol-c/package.py @@ -0,0 +1,69 @@ +from spack import * +import sys + +class AdolC(Package): + """A package for the automatic differentiation of first and higher derivatives of vector functions in C and C++ programs by operator overloading.""" + homepage = "https://projects.coin-or.org/ADOL-C" + url = "http://www.coin-or.org/download/source/ADOL-C/ADOL-C-2.6.1.tgz" + + version('head', svn='https://projects.coin-or.org/svn/ADOL-C/trunk/') + version('2.6.1', '1032b28427d6e399af4610e78c0f087b') + + variant('doc', default=True, description='Install documentation') + variant('openmp', default=False, description='Enable OpenMP support') + variant('sparse', default=False, description='Enable sparse drivers') + variant('tests', default=True, description='Build all included examples as a test case') + + def install(self, spec, prefix): + make_args = ['--prefix=%s' % prefix] + + # --with-cflags=FLAGS use CFLAGS=FLAGS (default: -O3 -Wall -ansi) + # --with-cxxflags=FLAGS use CXXFLAGS=FLAGS (default: -O3 -Wall) + + if '+openmp' in spec: + make_args.extend([ + '--with-openmp-flag=-fopenmp' # FIXME: Is this required? -I -L + ]) + + if '+sparse' in spec: + make_args.extend([ + '--enable-sparse' + ]) + + # We can simply use the bundled examples to check + # whether Adol-C works as expected + if '+tests' in spec: + make_args.extend([ + '--enable-docexa', # Documeted examples + '--enable-addexa' # Additional examples + ]) + if '+openmp' in spec: + make_args.extend([ + '--enable-parexa' # Parallel examples + ]) + + configure(*make_args) + make() + make("install") + + # Copy the config.h file, as some packages might require it + source_directory = self.stage.source_path + config_h = join_path(source_directory,'ADOL-C/src/config.h') + install(config_h, join_path(prefix.include,'adolc')) + + # Install documentation to {prefix}/share + if '+doc' in spec: + install_tree('ADOL-C/doc',join_path(prefix.share,'doc')) + + # Install examples to {prefix}/share + if '+tests' in spec: + install_tree('ADOL-C/examples',join_path(prefix.share,'examples')) + + # Run some examples that don't require user input + # TODO: Check that bundled examples produce the correct results + with working_dir(join_path(source_directory,'ADOL-C/examples')): + Executable('tapeless_scalar') + Executable('tapeless_vector') + + with working_dir(join_path(source_directory,'ADOL-C/examples/additional_examples')): + Executable('checkpointing/checkpointing') -- cgit v1.2.3-60-g2f50 From 5ae727668235f8a226cdac9e714d9daa004af64c Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Mon, 2 May 2016 11:01:14 +0200 Subject: Fixes to installation with OpenMP (tested) and execution of test-suite --- .../builtin/packages/adol-c/openmp_exam.patch | 13 +++++++++ var/spack/repos/builtin/packages/adol-c/package.py | 33 ++++++++++++++-------- 2 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 var/spack/repos/builtin/packages/adol-c/openmp_exam.patch (limited to 'var') diff --git a/var/spack/repos/builtin/packages/adol-c/openmp_exam.patch b/var/spack/repos/builtin/packages/adol-c/openmp_exam.patch new file mode 100644 index 0000000000..8e21c72d92 --- /dev/null +++ b/var/spack/repos/builtin/packages/adol-c/openmp_exam.patch @@ -0,0 +1,13 @@ +diff --git a/ADOL-C/examples/additional_examples/openmp_exam/liborpar.cpp b/ADOL-C/examples/additional_examples/openmp_exam/liborpar.cpp +index fc6fc28..14103d2 100644 +--- a/ADOL-C/examples/additional_examples/openmp_exam/liborpar.cpp ++++ b/ADOL-C/examples/additional_examples/openmp_exam/liborpar.cpp +@@ -27,7 +27,7 @@ using namespace std; + #include + #include + +-#include "adolc.h" ++#include + + #ifdef _OPENMP + #include diff --git a/var/spack/repos/builtin/packages/adol-c/package.py b/var/spack/repos/builtin/packages/adol-c/package.py index a65ec7dd7c..70933542ca 100644 --- a/var/spack/repos/builtin/packages/adol-c/package.py +++ b/var/spack/repos/builtin/packages/adol-c/package.py @@ -13,6 +13,8 @@ class AdolC(Package): variant('openmp', default=False, description='Enable OpenMP support') variant('sparse', default=False, description='Enable sparse drivers') variant('tests', default=True, description='Build all included examples as a test case') + + patch('openmp_exam.patch') def install(self, spec, prefix): make_args = ['--prefix=%s' % prefix] @@ -21,9 +23,12 @@ class AdolC(Package): # --with-cxxflags=FLAGS use CXXFLAGS=FLAGS (default: -O3 -Wall) if '+openmp' in spec: - make_args.extend([ - '--with-openmp-flag=-fopenmp' # FIXME: Is this required? -I -L - ]) + if spec.satisfies('%gcc'): + make_args.extend([ + '--with-openmp-flag=-fopenmp' # FIXME: Is this required? -I -L + ]) + else: + raise InstallError("OpenMP flags for compilers other than GCC are not implemented.") if '+sparse' in spec: make_args.extend([ @@ -48,22 +53,28 @@ class AdolC(Package): # Copy the config.h file, as some packages might require it source_directory = self.stage.source_path - config_h = join_path(source_directory,'ADOL-C/src/config.h') + config_h = join_path(source_directory,'ADOL-C','src','config.h') install(config_h, join_path(prefix.include,'adolc')) # Install documentation to {prefix}/share if '+doc' in spec: - install_tree('ADOL-C/doc',join_path(prefix.share,'doc')) + install_tree(join_path('ADOL-C','doc'), + join_path(prefix.share,'doc')) # Install examples to {prefix}/share if '+tests' in spec: - install_tree('ADOL-C/examples',join_path(prefix.share,'examples')) + install_tree(join_path('ADOL-C','examples'), + join_path(prefix.share,'examples')) # Run some examples that don't require user input # TODO: Check that bundled examples produce the correct results - with working_dir(join_path(source_directory,'ADOL-C/examples')): - Executable('tapeless_scalar') - Executable('tapeless_vector') + with working_dir(join_path(source_directory,'ADOL-C','examples')): + Executable('./tapeless_scalar')() + Executable('./tapeless_vector')() - with working_dir(join_path(source_directory,'ADOL-C/examples/additional_examples')): - Executable('checkpointing/checkpointing') + with working_dir(join_path(source_directory,'ADOL-C','examples','additional_examples')): + Executable('./checkpointing/checkpointing')() + + if '+openmp' in spec: + with working_dir(join_path(source_directory,'ADOL-C','examples','additional_examples')): + Executable('./checkpointing/checkpointing')() -- cgit v1.2.3-60-g2f50