From 3fabdb6e9b5af649b11c08b077fc3d5cf48ad5b4 Mon Sep 17 00:00:00 2001 From: Robert Pavel Date: Thu, 10 Sep 2020 15:53:13 -0600 Subject: [PATCH] Adding Cuda Variant to SW4Lite (#18590) * Adding Cuda Variant to SW4Lite Added cuda variant of sw4lite as per guidance in README * Updated SW4Lite+cuda to Current Header Conventions Updated sw4lite+cuda to use current conventions for spackage include dirs * Fixing FLake8 Issue with Sw4lite+cuda Fix Fixed overly long line and further underlined sticky note reminding me to run flake8 BEFORE pushing * Switching to Spack Compiler Wrapper Switching to spack compiler wrapper for consistency --- .../repos/builtin/packages/sw4lite/package.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/var/spack/repos/builtin/packages/sw4lite/package.py b/var/spack/repos/builtin/packages/sw4lite/package.py index 72b86390b6..815360c259 100644 --- a/var/spack/repos/builtin/packages/sw4lite/package.py +++ b/var/spack/repos/builtin/packages/sw4lite/package.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) -class Sw4lite(MakefilePackage): +class Sw4lite(MakefilePackage, CudaPackage): """Sw4lite is a bare bone version of SW4 intended for testing performance optimizations in a few important numerical kernels of SW4.""" @@ -52,6 +52,15 @@ def build_targets(self): cxxflags.append('-DSW4_CROUTINES') targets.append('ckernel=yes') + if '+cuda' in self.spec: + targets.append('NVCC = {0}'.format( + self.spec['cuda'].prefix.bin.nvcc)) + targets.append('HOSTCOMP = {0}'.format(spack_cxx)) + targets.append('MPIPATH= {0} '.format(self.spec['mpi'].prefix)) + targets.append('gpuarch= {0}'.format(self.cuda_flags(cuda_arch))) + targets.append('MPIINC = {0}'.format( + self.spec['mpi'].headers.directories[0])) + targets.append('FC=' + spec['mpi'].mpifc) targets.append('CXX=' + spec['mpi'].mpicxx) @@ -70,6 +79,12 @@ def build_targets(self): return targets + def build(self, spec, prefix): + if '+cuda' in spec: + make('-f', 'Makefile.cuda') + else: + make('-f', 'Makefile') + def install(self, spec, prefix): mkdir(prefix.bin) install('*/sw4lite', prefix.bin)