Date: Tuesday, March 7, 2023 @ 17:49:16
  Author: tpkessler
Revision: 1416725

upgpkg: magma 2.7.1-2: Merge GPU backends in one split package

Modified:
  magma/trunk/PKGBUILD

----------+
 PKGBUILD |   69 +++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 54 insertions(+), 15 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2023-03-07 17:27:15 UTC (rev 1416724)
+++ PKGBUILD    2023-03-07 17:49:16 UTC (rev 1416725)
@@ -1,20 +1,23 @@
 # Maintainer: Sven-Hendrik Haase <[email protected]>
+# Maintainer: Torsten Keßler <[email protected]>
 # Contributor: bartus <arch-user-repoᘓbartus.33mail.com>
 # Contributor: pingplug <[email protected]>
 # Contributor: cornholio <[email protected]>
 
-pkgname=magma
+_pkgname=magma
+pkgbase=$_pkgname
+pkgname=(magma-cuda magma-hip)
 pkgver=2.7.1
-pkgrel=1
-pkgdesc="Matrix Algebra on GPU and Multicore Architectures"
+pkgrel=2
+_pkgdesc="Matrix Algebra on GPU and Multicore Architectures"
 arch=('x86_64')
 url="https://icl.utk.edu/magma/";
 license=('custom')
-depends=('blas' 'lapack' 'cuda')
-makedepends=('gcc11-fortran' 'cmake' 'ninja')
+depends=('blas' 'lapack')
+makedepends=('gcc-fortran' 'cmake' 'ninja' 'cuda' 'hip-runtime-amd' 'hipblas' 
'hipsparse')
 optdepends=('python: for examples and tests'
-            'gcc11-fortran: Fortran interface')
-source=("${pkgname}-${pkgver}.tar.gz::https://icl.utk.edu/projectsfiles/${pkgname}/downloads/${pkgname}-${pkgver}.tar.gz";
+            'gcc-fortran: Fortran interface')
+source=("${_pkgname}-${pkgver}.tar.gz::https://icl.utk.edu/projectsfiles/${_pkgname}/downloads/${_pkgname}-${pkgver}.tar.gz";
         'add_cuda_archs.patch')
 sha256sums=('d9c8711c047a38cae16efde74bee2eb3333217fd2711e1e9b8606cbbb4ae1a50'
             '1ed3706a65a124ecef71012273687307aac70bfc80bc99a978002dfb0ee000cc')
@@ -21,17 +24,16 @@
 options=(!lto)
 
 prepare() {
-  cd "${pkgname}-${pkgver}"
+  cp -r "${_pkgname}-${pkgver}" "${_pkgname}-${pkgver}-cuda"
+  cp -r "${_pkgname}-${pkgver}" "${_pkgname}-${pkgver}-hip"
 
+  cd "${_pkgname}-${pkgver}-cuda"
   patch -Np1 -i "${srcdir}/add_cuda_archs.patch"
 }
 
 build() {
-  cd "${pkgname}-${pkgver}"
-
-  CC=/usr/bin/gcc-11 \
-  CXX=/usr/bin/g++-11 \
-  FC=/usr/bin/gfortran-11 \
+  echo "Build with cuda backend"
+  cd "${srcdir}/${_pkgname}-${pkgver}-cuda"
   cmake \
     -Bbuild \
     -GNinja \
@@ -40,10 +42,26 @@
     -DBUILD_SHARED_LIBS=ON \
     -DGPU_TARGET="sm_52 sm_53 sm_60 sm_61 sm_62 sm_70 sm_72 sm_75 sm_80 sm_86 
sm_87 sm_89 sm_90"
   ninja -C build
+
+  echo "Build with rocm/hip backend"
+  cd "${srcdir}/${_pkgname}-${pkgver}-hip"
+  # -fcf-protection is not supported by HIP, see
+  # 
https://docs.amd.com/bundle/ROCm-Compiler-Reference-Guide-v5.4/page/Appendix_A.html
+  CXXFLAGS="${CXXFLAGS} -fcf-protection=none" \
+  cmake \
+    -Bbuild \
+    -GNinja \
+    -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DCMAKE_INSTALL_PREFIX=/usr \
+    -DBUILD_SHARED_LIBS=ON \
+    -DMAGMA_ENABLE_HIP=ON \
+    -DGPU_TARGET="gfx803 gfx900 gfx906:xnack- gfx908:xnack- gfx90a:xnack+ 
gfx90a:xnack- gfx1010 gfx1011 gfx1012 gfx1030"
+    #List of GPU targets from rocBLAS
+  ninja -C build
 }
 
-package() {
-  cd "${pkgname}-${pkgver}"
+_package() {
   DESTDIR="${pkgdir}" ninja -Cbuild install
 
   install -d "${pkgdir}"/usr/share/magma/example
@@ -53,4 +71,25 @@
   install -Dm644 "${srcdir}"/magma-${pkgver}/COPYRIGHT 
"${pkgdir}"/usr/share/licenses/magma/LICENSE
 }
 
+package_magma-cuda() {
+  pkgdesc="${_pkgdesc} (with CUDA)"
+  depends+=(cuda)
+  provides=(magma)
+  conflicts=(magma)
+
+  cd "${srcdir}/${_pkgname}-${pkgver}-cuda"
+  _package
+}
+
+package_magma-hip() {
+  pkgdesc="${_pkgdesc} (with ROCm/HIP)"
+  depends+=(hip-runtime-amd hipblas hipsparse)
+  provides=(magma)
+  conflicts=(magma)
+  replaces=(hipmagma)
+
+  cd "${srcdir}/${_pkgname}-${pkgver}-hip"
+  _package
+}
+
 # vim:set ts=2 sw=2 et:

Reply via email to