Date: Saturday, May 6, 2023 @ 17:08:08
Author: tpkessler
Revision: 1459054
archrelease: copy trunk to community-staging-x86_64
Added:
rocsolver/repos/community-staging-x86_64/
rocsolver/repos/community-staging-x86_64/PKGBUILD
(from rev 1459053, rocsolver/trunk/PKGBUILD)
rocsolver/repos/community-staging-x86_64/test.cpp
(from rev 1459053, rocsolver/trunk/test.cpp)
rocsolver/repos/community-staging-x86_64/test.sh
(from rev 1459053, rocsolver/trunk/test.sh)
----------+
PKGBUILD | 43 ++++++++++++++++++++++++++++++++++++++
test.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test.sh | 5 ++++
3 files changed, 116 insertions(+)
Copied: rocsolver/repos/community-staging-x86_64/PKGBUILD (from rev 1459053,
rocsolver/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD (rev 0)
+++ community-staging-x86_64/PKGBUILD 2023-05-06 17:08:08 UTC (rev 1459054)
@@ -0,0 +1,43 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+
+pkgname=rocsolver
+pkgver=5.5.0
+pkgrel=1
+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=('6775aa5b96731208c12c5b450cf218d4c262a80b7ea20c2c3034c448bb2ca4d2')
+options=(!lto)
+_dirname="$(basename "$_git")-$(basename "${source[0]}" .tar.gz)"
+
+build() {
+ # Compile source code for supported GPU archs in parallel
+ export HIPCC_COMPILE_FLAGS_APPEND="-parallel-jobs=$(nproc)"
+ export HIPCC_LINK_FLAGS_APPEND="-parallel-jobs=$(nproc)"
+ # -fcf-protection is not supported by HIP, see
+ #
https://docs.amd.com/bundle/ROCm-Compiler-Reference-Guide-v5.5/page/Compiler_Options_and_Features.html#d2e2018
+ 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"
+}
Copied: rocsolver/repos/community-staging-x86_64/test.cpp (from rev 1459053,
rocsolver/trunk/test.cpp)
===================================================================
--- community-staging-x86_64/test.cpp (rev 0)
+++ community-staging-x86_64/test.cpp 2023-05-06 17:08:08 UTC (rev 1459054)
@@ -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);
+}
Copied: rocsolver/repos/community-staging-x86_64/test.sh (from rev 1459053,
rocsolver/trunk/test.sh)
===================================================================
--- community-staging-x86_64/test.sh (rev 0)
+++ community-staging-x86_64/test.sh 2023-05-06 17:08:08 UTC (rev 1459054)
@@ -0,0 +1,5 @@
+#! /usr/bin/env sh
+
+OUT=$(mktemp -d)
+/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lrocsolver -lrocblas
+"$OUT"/test