diff --git a/rocsolver/.SRCINFO b/rocsolver/.SRCINFO new file mode 100644 index 0000000000..a90e0e696a --- /dev/null +++ b/rocsolver/.SRCINFO @@ -0,0 +1,22 @@ +pkgbase = rocsolver + pkgdesc = Subset of LAPACK functionality on the ROCm platform + pkgver = 6.0.2 + pkgrel = 1 + url = https://rocm.docs.amd.com/projects/rocSOLVER/en/latest/index.html + arch = x86_64 + license = BSD-2-Clause + makedepends = rocm-cmake + makedepends = python-pyaml + makedepends = fmt + depends = rocm-core + depends = glibc + depends = gcc-libs + depends = hip + depends = rocblas + depends = rocsparse + options = !lto + options = !buildflags + source = rocsolver-6.0.2.tar.gz::https://github.com/ROCmSoftwarePlatform/rocSOLVER/archive/rocm-6.0.2.tar.gz + sha256sums = 781d5df2886ab0d5087a215a33ac390dd27653b2a9b4a620c7d51b0ae56f63d2 + +pkgname = rocsolver diff --git a/rocsolver/.nvchecker.toml b/rocsolver/.nvchecker.toml new file mode 100644 index 0000000000..98272946ae --- /dev/null +++ b/rocsolver/.nvchecker.toml @@ -0,0 +1,5 @@ +[rocsolver] +source = 'github' +github = 'ROCm/rocSOLVER' +use_latest_release = true +prefix = 'rocm-' diff --git a/rocsolver/PKGBUILD b/rocsolver/PKGBUILD new file mode 100644 index 0000000000..c07ba52d21 --- /dev/null +++ b/rocsolver/PKGBUILD @@ -0,0 +1,43 @@ +# POWER Maintainer: Alexander Baldeck +# Maintainer: Torsten Keßler + +pkgname=rocsolver +pkgver=6.0.2 +pkgrel=1 +pkgdesc='Subset of LAPACK functionality on the ROCm platform' +arch=(x86_64 powerpc64le powerpc64 riscv64) +url='https://rocm.docs.amd.com/projects/rocSOLVER/en/latest/index.html' +license=('BSD-2-Clause') +depends=('rocm-core' 'glibc' 'gcc-libs' 'hip' 'rocblas' 'rocsparse') +makedepends=('rocm-cmake' 'python-pyaml' 'fmt') +_git='https://github.com/ROCmSoftwarePlatform/rocSOLVER' +source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz") +sha256sums=('781d5df2886ab0d5087a215a33ac390dd27653b2a9b4a620c7d51b0ae56f63d2') +options=(!debug !lto !buildflags) +_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://rocm.docs.amd.com/en/latest/reference/rocmcc.html#support-status-of-other-clang-options + local cmake_args=( + -Wno-dev + -S "$_dirname" + -B build + -D CMAKE_BUILD_TYPE=Release + -D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc + -D CMAKE_CXX_FLAGS="${CXXFLAGS} -fcf-protection=none" + -D CMAKE_INSTALL_PREFIX=/opt/rocm + -D ROCSOLVER_EMBED_FMT=ON + ) + cmake "${cmake_args[@]}" + cmake --build build +} + +package() { + DESTDIR="$pkgdir" cmake --install build + + install -Dm644 "$_dirname/LICENSE.md" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} diff --git a/rocsolver/test.cpp b/rocsolver/test.cpp new file mode 100644 index 0000000000..e7968fa54d --- /dev/null +++ b/rocsolver/test.cpp @@ -0,0 +1,68 @@ +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + size_t n = 128; + size_t size = n * n; + + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution 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 ain(size); + std::vector 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 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); +} diff --git a/rocsolver/test.sh b/rocsolver/test.sh new file mode 100755 index 0000000000..4615d4a735 --- /dev/null +++ b/rocsolver/test.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env sh + +OUT=$(mktemp -d) +/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lrocsolver -lrocblas +"$OUT"/test