diff options
Diffstat (limited to 'dev-cpp/kokkos/kokkos-9999.ebuild')
| -rw-r--r-- | dev-cpp/kokkos/kokkos-9999.ebuild | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/dev-cpp/kokkos/kokkos-9999.ebuild b/dev-cpp/kokkos/kokkos-9999.ebuild index ee6ccf7fff8b..95f7a4721574 100644 --- a/dev-cpp/kokkos/kokkos-9999.ebuild +++ b/dev-cpp/kokkos/kokkos-9999.ebuild @@ -3,7 +3,7 @@ EAPI=8 -inherit cmake toolchain-funcs +inherit cmake cuda toolchain-funcs DESCRIPTION="C++ Performance Portability Programming EcoSystem" HOMEPAGE="https://github.com/kokkos" @@ -20,12 +20,31 @@ fi LICENSE="BSD" SLOT="0/${PV}" -IUSE="+openmp test" +IUSE="cuda +openmp test" RESTRICT="!test? ( test )" DEPEND="sys-apps/hwloc:=" RDEPEND="${DEPEND}" +# +# Try to translate the "${CUDAARCHS}" number coming from __nvcc_device_query +# into an option string that Kokkos' CMake configuration understands: +# +kokkos_arch_option() { + case "${1}" in + 3[0257]) echo "-DKokkos_ARCH_KEPLER${1}=ON" ;; + 5[023]) echo "-DKokkos_ARCH_MAXWELL${1}=ON" ;; + 6[01]) echo "-DKokkos_ARCH_PASCAL${1}=ON" ;; + 7[02]) echo "-DKokkos_ARCH_VOLTA${1}=ON" ;; + 75) echo "-DKokkos_ARCH_TURING${1}=ON" ;; + 8[06]) echo "-DKokkos_ARCH_AMPERE${1}=ON" ;; + 89) echo "-DKokkos_ARCH_ADA${1}=ON" ;; + 90) echo "-DKokkos_ARCH_HOPPER${1}=ON" ;; + 1[02]0) echo "-DKokkos_ARCH_BLACKWELL${1}=ON" ;; + *) die "Unknown CUDA architecture »${1}«" ;; + esac +} + pkg_pretend() { [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp } @@ -34,18 +53,51 @@ pkg_setup() { [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp } +src_prepare() { + cmake_src_prepare +} + src_configure() { local mycmakeargs=( -DCMAKE_INSTALL_INCLUDEDIR=include/kokkos - -DKokkos_ENABLE_TESTS=$(usex test) + -DKokkos_ENABLE_TESTS="$(usex test)" -DKokkos_ENABLE_AGGRESSIVE_VECTORIZATION=ON -DKokkos_ENABLE_SERIAL=ON -DKokkos_ENABLE_HWLOC=ON + -DKokkos_ENABLE_CUDA="$(usex cuda)" -DKokkos_HWLOC_DIR="${EPREFIX}/usr" - -DKokkos_ENABLE_OPENMP=$(usex openmp) + -DKokkos_ENABLE_OPENMP="$(usex openmp)" -DBUILD_SHARED_LIBS=ON ) + if use cuda; then + cuda_add_sandbox -w + + if [[ ! -n "${CUDAARCHS}" ]]; then + if ! SANDBOX_WRITE=/dev/nvidiactl test -w /dev/nvidiactl ; then + eerror + eerror "Can not access the GPU at /dev/nvidiactl." + eerror "User $(id -nu) is not in the group \"video\"." + eerror + ewarn + ewarn "Can not query the native device. You will need to set one of the" + ewarn "supported Kokkos_ARCH_{..} CMake variables, or the CUDAARCHS" + ewarn "environment variable to the appropriate architecture by hand..." + ewarn + else + local CUDAARCHS + CUDAARCHS="$(__nvcc_device_query || eerror "failed to query the native device")" + fi + fi + + if [[ -n "${CUDAARCHS}" ]]; then + einfo "Building with CUDAARCHS=${CUDAARCHS}" + mycmakeargs+=( + $(kokkos_arch_option "${CUDAARCHS}") + ) + fi + fi + cmake_src_configure } |
