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 <axel.huebl@plasma.ninja>
This commit is contained in:
mic84 2021-01-13 18:53:57 -08:00 committed by GitHub
parent 4f49b1a930
commit f6dd85b2b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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