From d4831181eaa27576fa48e315a4621d69f1e8e99f Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Sat, 1 Aug 2020 01:01:39 +0200 Subject: Add libxc 5.0.0 (#17807) With experimental CUDA support and some patches to make it compile. Currently +shared and +cuda conflict, this has to be fixed upstream. --- ...d-implicit-pointer-cast-to-make-libxc-com.patch | 26 +++++++++++++++++ .../libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch | 33 ++++++++++++++++++++++ var/spack/repos/builtin/packages/libxc/package.py | 32 +++++++++++++++++++-- 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 var/spack/repos/builtin/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch create mode 100644 var/spack/repos/builtin/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch (limited to 'var') diff --git a/var/spack/repos/builtin/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch b/var/spack/repos/builtin/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch new file mode 100644 index 0000000000..366f680168 --- /dev/null +++ b/var/spack/repos/builtin/packages/libxc/0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch @@ -0,0 +1,26 @@ +From 205a08a30ee0d057d173f9eaa6fc6414f6960c22 Mon Sep 17 00:00:00 2001 +From: Xavier Andrade +Date: Wed, 27 May 2020 15:42:32 -0700 +Subject: [PATCH] Bugfix: avoid implicit pointer cast to make libxc compile + with a C++ compiler. + +--- + src/functionals.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/functionals.c b/src/functionals.c +index 3f668292..293f7f9b 100644 +--- a/src/functionals.c ++++ b/src/functionals.c +@@ -324,7 +324,7 @@ xc_func_set_ext_params_name(xc_func_type *p, const char *name, double par) + + assert(p != NULL && p->info->ext_params.n > 0); + +- ext_params = libxc_malloc(p->info->ext_params.n*sizeof(double)); ++ ext_params = (double *) libxc_malloc(p->info->ext_params.n*sizeof(double)); + for(ii=0; iiinfo->ext_params.n; ii++){ + if(strcmp(p->info->ext_params.names[ii], name) == 0) + ext_params[ii] = par; +-- +2.25.1 + diff --git a/var/spack/repos/builtin/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch b/var/spack/repos/builtin/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch new file mode 100644 index 0000000000..a4e4f104a3 --- /dev/null +++ b/var/spack/repos/builtin/packages/libxc/0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch @@ -0,0 +1,33 @@ +From 11b90a0a477925f19dfeb7e1f672058f25d83387 Mon Sep 17 00:00:00 2001 +From: Harmen Stoppels +Date: Fri, 31 Jul 2020 13:54:39 +0200 +Subject: [PATCH] Mark xc_erfcx a GPU_FUNCTION + +--- + src/faddeeva.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/faddeeva.c b/src/faddeeva.c +index ceec4736..03484713 100644 +--- a/src/faddeeva.c ++++ b/src/faddeeva.c +@@ -29,6 +29,8 @@ + + #include "config.h" + ++#include "util.h" ++ + #include + + /* erfcx(x) = exp(x^2) erfc(x) function, for real x, written by +@@ -477,6 +479,7 @@ return 0.97771701335885035464e0 + (0.22000938572830479551e-1 + (0.27951610702682 + return 1.0; + } + ++GPU_FUNCTION + double xc_erfcx(double x) + { + if (x >= 0) { +-- +2.25.1 + diff --git a/var/spack/repos/builtin/packages/libxc/package.py b/var/spack/repos/builtin/packages/libxc/package.py index 6b45e7f2bb..61597ebaa0 100644 --- a/var/spack/repos/builtin/packages/libxc/package.py +++ b/var/spack/repos/builtin/packages/libxc/package.py @@ -6,13 +6,14 @@ from spack import * -class Libxc(AutotoolsPackage): +class Libxc(AutotoolsPackage, CudaPackage): """Libxc is a library of exchange-correlation functionals for density-functional theory.""" homepage = "https://tddft.org/programs/libxc/" url = "https://www.tddft.org/programs/libxc/down.php?file=2.2.2/libxc-2.2.2.tar.gz" + version('5.0.0', sha256='1cdc57930f7b57da4eb9b2c55a50ba1c2c385936ddaf5582fee830994461a892') version('4.3.4', sha256='a8ee37ddc5079339854bd313272856c9d41a27802472ee9ae44b58ee9a298337') version('4.3.2', sha256='bc159aea2537521998c7fb1199789e1be71e04c4b7758d58282622e347603a6f') version('4.2.3', sha256='02e49e9ba7d21d18df17e9e57eae861e6ce05e65e966e1e832475aa09e344256') @@ -20,6 +21,14 @@ class Libxc(AutotoolsPackage): version('2.2.2', sha256='6ca1d0bb5fdc341d59960707bc67f23ad54de8a6018e19e02eee2b16ea7cc642') version('2.2.1', sha256='ade61c1fa4ed238edd56408fd8ee6c2e305a3d5753e160017e2a71817c98fd00') + variant('shared', default=True, description='Build shared libraries') + + conflicts('+shared +cuda', msg='Only ~shared supported with +cuda') + conflicts('+cuda', when='@:4', msg='CUDA support only in libxc 5.0.0 and above') + + patch('0001-Bugfix-avoid-implicit-pointer-cast-to-make-libxc-com.patch', when='@5.0.0') + patch('0002-Mark-xc_erfcx-a-GPU_FUNCTION.patch', when='@5.0.0') + @property def libs(self): """Libxc can be queried for the following parameters: @@ -36,7 +45,8 @@ class Libxc(AutotoolsPackage): # Libxc installs both shared and static libraries. # If a client ask for static explicitly then return # the static libraries - shared = ('static' not in query_parameters) + shared = (self.spec.variants['shared'].value and + 'static' not in query_parameters) # Libxc has a fortran90 interface: give clients the # possibility to query for it @@ -82,8 +92,24 @@ class Libxc(AutotoolsPackage): env.append_flags('CFLAGS', optflags) env.append_flags('FCFLAGS', optflags) + if '+cuda' in self.spec: + nvcc = self.spec['cuda'].prefix.bin.nvcc + env.set('CCLD', '{0} -ccbin {1}'.format(nvcc, spack_cc)) + env.set('CC', '{0} -x cu -ccbin {1}'.format(nvcc, spack_cc)) + + cuda_arch = self.spec.variants['cuda_arch'].value[0] + + if cuda_arch != 'none': + env.append_flags('CFLAGS', '-arch=sm_{0}'.format(cuda_arch)) + def configure_args(self): - args = ['--enable-shared'] + spec = self.spec + + args = [ + '--enable-shared' if '+shared' in spec else '--disable-shared', + '--enable-cuda' if '+cuda' in spec else '--disable-cuda' + ] + return args def check(self): -- cgit v1.2.3-70-g09d2