Date: Saturday, January 7, 2023 @ 16:54:15
  Author: tpkessler
Revision: 1381743

Move rosolver from AUR to community

Added:
  rocsolver/
  rocsolver/repos/
  rocsolver/trunk/
  rocsolver/trunk/PKGBUILD
  rocsolver/trunk/test.cpp
  rocsolver/trunk/test.sh

----------+
 PKGBUILD |   40 +++++++++++++++++++++++++++++++++++
 test.cpp |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.sh  |    5 ++++
 3 files changed, 113 insertions(+)

Added: rocsolver/trunk/PKGBUILD
===================================================================
--- rocsolver/trunk/PKGBUILD                            (rev 0)
+++ rocsolver/trunk/PKGBUILD    2023-01-07 16:54:15 UTC (rev 1381743)
@@ -0,0 +1,40 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+
+pkgname=rocsolver
+pkgver=5.4.1
+pkgrel=2
+pkgdesc='Subset of LAPACK functionality on the ROCm platform'
+arch=('x86_64')
+url='https://rocsolver.readthedocs.io/en/latest/'
+license=('BSD 2-Clause')
+depends=('hip' 'rocblas')
+makedepends=('rocm-cmake' 'python-pyaml' 'fmt')
+_git='https://github.com/ROCmSoftwarePlatform/rocSOLVER'
+source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz")
+sha256sums=('b1059c476fdef5fff4eab8152385d2dfb6ce914bfac298e612c560defe67aeec')
+options=(!lto)
+_dirname="$(basename "$_git")-$(basename "${source[0]}" .tar.gz)"
+
+build() {
+    # -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 \
+      -Wno-dev \
+      -B build \
+      -S "$_dirname" \
+      -DCMAKE_BUILD_TYPE=None \
+      -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
+      -DCMAKE_INSTALL_PREFIX=/opt/rocm \
+      -DROCSOLVER_EMBED_FMT=ON
+    cmake --build build
+}
+
+package() {
+    DESTDIR="$pkgdir" cmake --install build
+
+    echo "/opt/rocm/$pkgname/lib" > "$pkgname.conf"
+    install -Dm644 "$pkgname.conf" "$pkgdir/etc/ld.so.conf.d/$pkgname.conf"
+
+    install -Dm644 "$_dirname/LICENSE.md" 
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}

Added: rocsolver/trunk/test.cpp
===================================================================
--- rocsolver/trunk/test.cpp                            (rev 0)
+++ rocsolver/trunk/test.cpp    2023-01-07 16:54:15 UTC (rev 1381743)
@@ -0,0 +1,68 @@
+#include <rocsolver/rocsolver.h>
+#include <hip/hip_runtime.h>
+#include <vector>
+#include <random>
+#include <algorithm>
+#include <cmath>
+#include <iostream>
+
+int main()
+{
+    size_t n = 128;
+    size_t size = n * n;
+
+    std::random_device rd;
+    std::mt19937 gen(rd());
+    std::uniform_real_distribution<float> dist(-1.0, 1.0);
+    auto myrand = [&](){return dist(gen);};
+
+    float *a;
+    float *x;
+    hipMalloc((void**)&a, sizeof *a * size);
+    hipMalloc((void**)&x, sizeof *x * n);
+
+    std::vector<float> ain(size);
+    std::vector<float> xin(n);
+    std::generate(ain.begin(), ain.end(), myrand);
+    std::generate(xin.begin(), xin.end(), myrand);
+
+    hipMemcpy(a, ain.data(), sizeof *a * size, hipMemcpyHostToDevice);
+    hipMemcpy(x, xin.data(), sizeof *x * n, hipMemcpyHostToDevice);
+
+    rocblas_handle handle;
+    rocblas_create_handle(&handle);
+
+    rocblas_int *info;
+    hipMalloc((void**)&info, sizeof *info);
+    rocsolver_sgels(handle, rocblas_operation_none,
+        n, n, 1, a, n, x, n, info);
+
+    std::vector<float> xout(n);
+    hipMemcpy(xout.data(), x, sizeof *x * n, hipMemcpyDeviceToHost);
+    rocblas_int hinfo;
+    hipMemcpy(&hinfo, info, sizeof *info, hipMemcpyDeviceToHost);
+
+    if(hinfo != 0){
+        std::cout << "Matrix is rank deficient!\n";
+        return 1;
+    }
+
+    float tol = 0.001f;
+    for(size_t i = 0; i < n; i++){
+        for(size_t j = 0; j < n; j++){
+            xin[i] -= ain[i + j * n] * xout[j];
+        }
+        if(std::abs(xin[i]) > tol){
+            std::cout << "Missmatch at index " << i << "\n"
+                << "Desired: 0" << "\n"
+                << "Actual : " << xin[i] << std::endl;
+            return 1;
+        }
+    }
+
+    std::cout << "TESTS PASSED!" << std::endl;
+
+    hipFree(a);
+    hipFree(x);
+    rocblas_destroy_handle(handle);
+}

Added: rocsolver/trunk/test.sh
===================================================================
--- rocsolver/trunk/test.sh                             (rev 0)
+++ rocsolver/trunk/test.sh     2023-01-07 16:54:15 UTC (rev 1381743)
@@ -0,0 +1,5 @@
+#! /usr/bin/env sh
+
+OUT=$(mktemp -d)
+/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lrocsolver -lrocblas
+"$OUT"/test


Property changes on: rocsolver/trunk/test.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Reply via email to