From f6dd85b2b0d80316b9cbcebe7d0e88fc7c0459c3 Mon Sep 17 00:00:00 2001 From: mic84 Date: Wed, 13 Jan 2021 18:53:57 -0800 Subject: [PATCH] amrex: fix handling of CUDA arch (#20786) * amrex: fix handling of CUDA arch * amrex: fix style * amrex: fix bug * Update var/spack/repos/builtin/packages/amrex/package.py * Update var/spack/repos/builtin/packages/amrex/package.py Co-authored-by: Axel Huebl --- .../repos/builtin/packages/amrex/package.py | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/var/spack/repos/builtin/packages/amrex/package.py b/var/spack/repos/builtin/packages/amrex/package.py index c0f75af44a..d3414e575e 100644 --- a/var/spack/repos/builtin/packages/amrex/package.py +++ b/var/spack/repos/builtin/packages/amrex/package.py @@ -121,6 +121,14 @@ def url_for_version(self, version): url = "https://github.com/AMReX-Codes/amrex/archive/{0}.tar.gz" return url.format(version.dotted) + def get_cuda_arch_string(self, values): + if 'none' in values: + return 'Auto' + else: + # Use format x.y instead of CudaPackage xy format + vf = tuple(float(x) / 10.0 for x in values) + return ';'.join(str(x) for x in vf) + # # For versions <= 20.11 # @@ -152,11 +160,8 @@ def cmake_args(self): args.append('-DCMAKE_Fortran_MODDIR_FLAG=-M') if '+cuda' in self.spec: - cuda_arch = spec.variants['cuda_arch'].value - if cuda_arch == 'none': - args.append('-DCUDA_ARCH=Auto') - else: - args.append('-DCUDA_ARCH={0}'.format(cuda_arch[0])) + cuda_arch = self.spec.variants['cuda_arch'].value + args.append('-DCUDA_ARCH=' + self.get_cuda_arch_string(cuda_arch)) return args @@ -192,11 +197,7 @@ def cmake_args(self): args.append('-DAMReX_GPU_BACKEND=CUDA') args.append('-DAMReX_CUDA_ERROR_CAPTURE_THIS=ON') args.append('-DAMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL=ON') - - cuda_arch = spec.variants['cuda_arch'].value - if cuda_arch == 'none': - args.append('-DAMReX_CUDA_ARCH=Auto') - else: - args.append('-DAMReX_CUDA_ARCH={0}'.format(cuda_arch[0])) + cuda_arch = self.spec.variants['cuda_arch'].value + args.append('-DCUDA_ARCH=' + self.get_cuda_arch_string(cuda_arch)) return args