Skip to content
230 changes: 230 additions & 0 deletions repos/spack_repo/builtin/packages/devicexlib/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
# Copyright Spack Project Developers. See COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

from spack_repo.builtin.build_systems.autotools import AutotoolsPackage
from spack_repo.builtin.build_systems.cuda import CudaPackage
from spack_repo.builtin.build_systems.rocm import ROCmPackage

from spack.package import *


class Devicexlib(AutotoolsPackage, CudaPackage, ROCmPackage):
"""Library wrapping device-oriented routines and utilities.

deviceXlib provides wrappers for device data allocation and host-device data
transfers. It supports CUDA, OpenACC, and OpenMP programming paradigms, and
wraps a subset of routines from NVIDIA cuBLAS, Intel oneMKL BLAS, and AMD
rocBLAS libraries.
"""

homepage = "https://gitlab.com/max-centre/components/devicexlib"
url = "https://gitlab.com/max-centre/components/devicexlib/-/archive/0.9.0/devicexlib-0.9.0.tar.gz"
git = "https://gitlab.com/max-centre/components/devicexlib"

license("MIT")
maintainers("nicspalla")

version("develop", branch="develop")
version("0.9.1", sha256="900fe8b0849d451e7c541d00a1b92c723e0969bae47ebcabd295e14ebcc17d1e")
with default_args(deprecated=True):
version("0.9.0", sha256="77c57a31381a69a2eb2a77138b131a553c96aff03ca934c88b8a6d8434b39460")
version("0.8.6", sha256="36e6222bc59cf0ed7268cc3652a3661887109f7fe072cefe06884dcd6de2407d")
version("0.8.5", sha256="498d5c6804e697123d382d9dd35dedeb4b64228704f84711877c842b851d37df")

depends_on("c", type="build")
depends_on("fortran", type="build")

variant(
"openmp",
default=False,
description="Enable OpenMP support",
)

variant(
"openmp5",
default=False,
description="Build with OpenMP-GPU support",
)

variant(
"openacc",
default=False,
description="Build with OpenACC",
)

variant(
"cuda-fortran",
default=False,
description="Build with CUDA Fortran",
)

variant(
"nvtx",
default=False,
description="Enable NVTX support",
when="+cuda",
)

variant(
"roctx",
default=False,
description="Enable ROCTX support",
when="+rocm",
)

variant(
"mkl",
default=False,
description="Enable MKL-GPU support",
)

with when("@0.9.0: +openacc"):
variant(
"openacc-debug",
default=False,
description="Enable OpenACC DEBUG macro",
)

with when("+cuda"):
variant(
"cuda_rt",
values=str,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, a generic string seems a bit too broad for this variant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think that float is better?

default="none",
when="%nvhpc",
description=(
'Specify the CUDA runtime version, e.g. "11.8", only if you '
"want the secondary version installed with the NVHPC SDK."
),
)

with when("+cuda-fortran"):
requires(
"%nvhpc",
msg="CUDA Fortran is available only with NVIDIA compilers",
)

with when("+openacc"):
requires(
"%nvhpc",
"%gcc@10:+nvptx",
policy="one_of",
msg="OpenACC is available only with NVIDIA or GCC compilers",
)

with when("+openmp5"):
requires(
"%oneapi",
"%cce",
"%gcc@10:+nvptx",
policy="one_of",
msg=("OpenMP offloading is available only with GCC, oneAPI, or Cray compilers"),
)

depends_on("blas")

depends_on("intel-oneapi-mkl", when="+mkl")
Comment thread
nicspalla marked this conversation as resolved.

with when("+openmp"):
depends_on("openblas threads=openmp", when="^[virtuals=blas] openblas")

conflicts(
"cuda_arch=none",
when="+cuda",
msg="CUDA architecture is required",
)

conflicts(
"cuda_arch=none",
when="+cuda-fortran",
msg="CUDA architecture is required",
)

conflicts(
"cuda_rt=none",
when="@:0.8.5 +cuda",
msg="CUDA runtime version is required",
)

def enable_or_disable_cuda(self, activated):
return "--enable-cublas=yes" if activated else "--enable-cublas=no"

def enable_or_disable_rocm(self, activated):
return "--enable-rocblas=yes" if activated else "--enable-rocblas=no"

def enable_or_disable_mkl(self, activated):
return "--enable-mkl-gpu=yes" if activated else "--enable-mkl-gpu=no"

def setup_build_environment(self, env):
spec = self.spec

if "%nvhpc" in spec:
env.set("CC", "nvc")
env.set("FC", "nvfortran")
env.set("F90", "nvfortran")
env.set("CPP", "cpp -E")
env.set("FPP", "nvfortran -Mpreprocess -E")
env.set("F90SUFFIX", ".f90")

if "%gcc" in spec:
env.set("CC", "gcc")
env.set("FC", "gfortran")
env.set("F90", "gfortran")
env.set("CPP", "gcc -E -P")
env.set("FPP", "gfortran -E -P")
env.set("F90SUFFIX", ".f90")
Comment on lines +161 to +175
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are wrong in the current model. Spack allows to use %c=gcc and fortran=nvfortran etc. You can't assume that the toolchain is always homogeneous.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so do you suggest to simply remove them? or substitute them with something else?


def configure_args(self):
spec = self.spec

args = [
"--enable-cuda-env-check=no",
"--enable-parallel=no",
]

# OpenMP
args.extend(self.enable_or_disable("openmp"))

# GPU offloading
if "+cuda-fortran" in spec:
args.append("--enable-cuda-fortran")

if "+openacc" in spec:
args.append("--enable-openacc")

if "+openacc-debug" in spec:
args.append("--enable-openacc-debug")

if "+openmp5" in spec:
args.append("--enable-openmp5")

# BLAS
args.append(f"--with-blas-libs={spec['blas'].libs}")

# CUDA
args.extend(self.enable_or_disable("cuda"))

if "+cuda" in spec:
cuda_arch = spec.variants["cuda_arch"].value[0]
args.append(f"--with-cuda-cc={cuda_arch}")

if spec.variants["cuda_rt"].value != "none":
args.append(f"--with-cuda-runtime={spec.variants['cuda_rt'].value}")

if "%nvhpc" not in spec:
args.append(f"--with-cuda-path={spec['cuda'].home}")

# ROCm
args.extend(self.enable_or_disable("rocm"))

if "+rocm" in spec:
args.append(f"--with-rocm-path={spec['hip'].home}")

# MKL
args.extend(self.enable_or_disable("mkl"))

return args

@property
def build_targets(self):
return ["all"]
90 changes: 90 additions & 0 deletions repos/spack_repo/builtin/packages/yambo/cuda_runtime.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
--- a/configure
+++ b/configure
@@ -1860,7 +1860,8 @@ Optional Packages:
--with-cuda-path=<path> Path to libcuda install directory
--with-cuda-cc=VAL GPU architecture (Kepler: 35, Pascal: 60, Volta: 70,
Ampere: 80) [default=70]
- --with-cuda-runtime=VAL CUDA runtime (Pascal: 8+, Volta: 9+) [default=10.1]
+ --with-cuda-runtime=VAL CUDA runtime (Pascal: 8+, Volta: 9+) [default=none,
+ checks if the NVHPC_CUDA_HOME variable is set.]
--with-cuda-int-libs=VAL
CUDA internal libraries ()
[default=cuda,cufft,cublas,cusolver,cudart]
@@ -16049,7 +16050,7 @@ if test ${with_cuda_runtime+y}
then :
withval=$with_cuda_runtime;
else $as_nop
- with_cuda_runtime=10.1
+ with_cuda_runtime=none
fi

#
@@ -16194,17 +16195,26 @@ if test x"$enable_cuda_fortran" != "xno" ; then
#
# Flags to be passed to the devicexlib library
#
- DEVXLIB_FLAGS="--enable-openmp --enable-cuda-fortran --with-cuda-cc=${with_cuda_cc} --with-cuda-runtime=${with_cuda_runtime}"
+ DEVXLIB_FLAGS="--enable-openmp --enable-cuda-fortran --with-cuda-cc=${with_cuda_cc}"
+ if test "x$with_cuda_runtime" != "xnone" ; then
+ DEVXLIB_FLAGS+=" --with-cuda-runtime=${with_cuda_runtime}"
+ fi
#
case "${FCVERSION}" in
*nvfortran*)
- GPU_FLAGS="-cuda -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime}"
+ GPU_FLAGS="-cuda -gpu=cc${with_cuda_cc}"
+ if test "x$with_cuda_runtime" != "xnone" ; then
+ GPU_FLAGS+=" -gpu=cuda${with_cuda_runtime}";
+ fi
if test x"$use_int_cuda_libs" = "xyes" ; then
GPU_FLAGS+=" -cudalib=${with_cuda_int_libs}";
fi
;;
*)
- GPU_FLAGS="-Mcuda=cc${with_cuda_cc},cuda${with_cuda_runtime}"
+ GPU_FLAGS="-Mcuda=cc${with_cuda_cc}"
+ if test "x$with_cuda_runtime" != "xnone" ; then
+ GPU_FLAGS+=" -gpu=cuda${with_cuda_runtime}"
+ fi
if test x"$use_int_cuda_libs" = "xyes" ; then
GPU_FLAGS+=" -Mcudalib=${with_cuda_int_libs}"
fi
@@ -16338,14 +16348,17 @@ if test x"$enable_openacc" != "xno" ; then
case "${FCVERSION}" in
*nvfortran*)
DEVXLIB_FLAGS+="--enable-openmp"
- GPU_FLAGS="-acc=gpu,multicore -acclibs -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime} " # -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime}"
+ GPU_FLAGS="-acc=gpu,multicore -acclibs -gpu=cc${with_cuda_cc}"
+ if test "x$with_cuda_runtime" != "xnone" ; then
+ GPU_FLAGS+=" -gpu=cuda${with_cuda_runtime}"
+ fi
if test x"$use_int_cuda_libs" = "xyes" ; then
GPU_FLAGS+=" -cudalib=${with_cuda_int_libs}";
fi
;;
*pgfortran*)
DEVXLIB_FLAGS+="--enable-openmp"
- GPU_FLAGS="-acc -acclibs -ta=tesla:cc${with_cuda_cc} " # -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime}"
+ GPU_FLAGS="-acc -acclibs -ta=tesla:cc${with_cuda_cc} "
if test x"$use_int_cuda_libs" = "xyes" ; then
GPU_FLAGS+=" -cudalib=${with_cuda_int_libs}";
fi
@@ -16354,7 +16367,6 @@ if test x"$enable_openacc" != "xno" ; then
GPU_FLAGS="-fopenacc -foffload=-lm -foffload=-lgfortran"
# -foffload=nvptx-none
# -foffload=amdgcn-amdhsa -foffload=-march=gfx908
- # -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime}
esac
#
fi
@@ -16366,8 +16378,8 @@ if test x"$enable_openmp5" != "xno" ; then
# Flags to be passed to the devicexlib library
#
def_gpu="-D_GPU -D_OPENMP_GPU"
- GPU_FLAGS="-fopenmp" # -gpu=cc${with_cuda_cc},cuda${with_cuda_runtime}"
- DEVXLIB_FLAGS="--enable-openmp5" # --with-cuda-cc=${with_cuda_cc} --with-cuda-runtime=${with_cuda_runtime}"
+ GPU_FLAGS="-fopenmp"
+ DEVXLIB_FLAGS="--enable-openmp5"
if test x"$LIBROCM_LIBS" != "x" ; then
DEVXLIB_FLAGS+=" --enable-rocblas --with-rocm-libs=$LIBROCM_LIBS";
def_gpu="$def_gpu -D_HIP"
11 changes: 11 additions & 0 deletions repos/spack_repo/builtin/packages/yambo/hdf5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -12970,7 +12970,7 @@ ac_compiler_gnu=$ac_cv_fc_compiler_gnu
#
if test x"$with_hdf5_libs" != "x" ; then try_HDF5_LIBS="$with_hdf5_libs" ; fi
#
- if test -d "$try_hdf5_libdir" ; then try_HDF5_LIBS="-L$try_hdf5_libdir -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5" ; fi
+ if test -d "$try_hdf5_libdir" ; then try_HDF5_LIBS="-L$try_hdf5_libdir -lhdf5_hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5" ; fi
#
if test -d "$try_hdf5_incdir" ; then try_HDF5_INCS="$IFLAG$try_hdf5_incdir" ; fi
#
Loading
Loading