Date: Wednesday, December 28, 2022 @ 13:15:20 Author: tpkessler Revision: 1370829
Migrate rocrand from AUR to community Added: rocrand/ rocrand/repos/ rocrand/trunk/ rocrand/trunk/PKGBUILD rocrand/trunk/test.cpp rocrand/trunk/test.sh ----------+ PKGBUILD | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ test.cpp | 36 ++++++++++++++++++++++++++++++++++++ test.sh | 5 +++++ 3 files changed, 90 insertions(+) Added: rocrand/trunk/PKGBUILD =================================================================== --- rocrand/trunk/PKGBUILD (rev 0) +++ rocrand/trunk/PKGBUILD 2022-12-28 13:15:20 UTC (rev 1370829) @@ -0,0 +1,49 @@ +# Maintainer: Torsten Keßler <tpkessler at archlinux dot org> +# Contributor: Jakub Okoński <[email protected]> +pkgname=rocrand +pkgver=5.4.1 +pkgrel=2 +pkgdesc='Pseudo-random and quasi-random number generator on ROCm' +arch=('x86_64') +url='https://rocrand.readthedocs.io/en/latest/' +license=('MIT') +depends=('hip') +makedepends=('rocm-cmake' 'gcc-fortran' 'python') +optdepends=('gcc-fortran: Use Fortran wrapper' + 'python: Use Python wrapper') +_git='https://github.com/ROCmSoftwarePlatform/rocRAND' +_hiprand='https://github.com/ROCmSoftwarePlatform/hipRAND' +source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz" + "$pkgname-hiprand-$pkgver.tar.gz::$_hiprand/archive/20ac3db9d7462c15a3e96a6f0507cd5f2ee089c4.tar.gz") +sha256sums=('44eb2ec7fbbc782796173e0d3c10a65088fd76c0c3f06cc7cd1523505fe15257' + 'ee38a68c9e88056b7ecd41553e496e455dbb3fe08871ff3545430d6733070e6b') +_dirname="$(basename "$_git")-$(basename "${source[0]}" ".tar.gz")" +_hipname="$(basename "$_hiprand")-$(basename "${source[1]}" ".tar.gz")" + +prepare() { + rm -r "$srcdir/$_dirname/hipRAND" + ln -s "$srcdir/$_hipname" "$srcdir/$_dirname/hipRAND" +} + +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/hip/bin/hipcc \ + -DCMAKE_INSTALL_PREFIX=/opt/rocm + cmake --build build +} + +package() { + DESTDIR="$pkgdir" cmake --install build + + echo '/opt/rocm/hiprand/lib' > rocrand.conf + echo '/opt/rocm/rocrand/lib' >> rocrand.conf + install -Dm644 rocrand.conf "$pkgdir/etc/ld.so.conf.d/$pkgname.conf" + install -Dm644 "$_dirname/LICENSE.txt" "$pkgdir/usr/share/licenses/$pkgname/LICENSE" +} Added: rocrand/trunk/test.cpp =================================================================== --- rocrand/trunk/test.cpp (rev 0) +++ rocrand/trunk/test.cpp 2022-12-28 13:15:20 UTC (rev 1370829) @@ -0,0 +1,36 @@ +#include <hiprand/hiprand.hpp> +#include <vector> +#include <numeric> +#include <cmath> +#include <iostream> + +int main() +{ + size_t size = 1024 * 1024; + float mean = -1.24f; + float std = 0.43f; + hiprandGenerator_t gen; + hiprandCreateGenerator(&gen, HIPRAND_RNG_PSEUDO_DEFAULT); + + float *x; + hipMalloc((void**)&x, sizeof *x * size); + hiprandGenerateNormal(gen, x, size, mean, std); + + std::vector<float> x_d(size); + hipMemcpy(x_d.data(), x, sizeof *x * size, hipMemcpyDeviceToHost); + + float mean_hat = std::accumulate(x_d.begin(), x_d.end(), 0.0f) / size; + + // Tolerance set so that test may at most fail in 1 of 10,000 runs + float tol = 3e-1; + if(std::abs(mean - mean_hat) > tol){ + std::cout << "Tolerance in mean not reached:\n" + << mean_hat << " differs more than " << tol + << " from " << mean << std::endl; + return 1; + } + std::cout << "TESTS PASSED!" << std::endl; + + hiprandDestroyGenerator(gen); + hipFree(x); +} Added: rocrand/trunk/test.sh =================================================================== --- rocrand/trunk/test.sh (rev 0) +++ rocrand/trunk/test.sh 2022-12-28 13:15:20 UTC (rev 1370829) @@ -0,0 +1,5 @@ +#! /usr/bin/env sh + +OUT=$(mktemp -d) +/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lhiprand -lrocrand +"$OUT"/test Property changes on: rocrand/trunk/test.sh ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property
