* add hiprand
This commit is contained in:
parent
47207e90a0
commit
e92a1583de
27
rocm/hiprand/.SRCINFO
Normal file
27
rocm/hiprand/.SRCINFO
Normal file
@ -0,0 +1,27 @@
|
||||
pkgbase = hiprand
|
||||
pkgdesc = rocRAND marshalling library
|
||||
pkgver = 6.2.4
|
||||
pkgrel = 1
|
||||
url = https://rocm.docs.amd.com/projects/hipRAND/en/latest/
|
||||
arch = x86_64
|
||||
arch = powerpc64le
|
||||
arch = powerpc64
|
||||
arch = powerpc
|
||||
arch = riscv64
|
||||
license = MIT
|
||||
makedepends = cmake
|
||||
makedepends = rocm-cmake
|
||||
makedepends = gcc-fortran
|
||||
depends = rocm-core
|
||||
depends = glibc
|
||||
depends = gcc-libs
|
||||
depends = hip-runtime-amd
|
||||
depends = rocrand
|
||||
optdepends = gcc-fortran: Use Fortran wrapper
|
||||
options = !lto
|
||||
source = hiprand-6.2.4.tar.gz::https://github.com/ROCm/hipRAND/archive/rocm-6.2.4.tar.gz
|
||||
source = hiprand-rocm-bin-path.patch
|
||||
sha256sums = b6010f5e0c63a139acd92197cc1c0d64a428f7a0ad661bce0cd1e553ad6fd6eb
|
||||
sha256sums = 144fb5162222d81559e847d31226f7b56215fa558a549c8be534cfba3fbca241
|
||||
|
||||
pkgname = hiprand
|
5
rocm/hiprand/.nvchecker.toml
Normal file
5
rocm/hiprand/.nvchecker.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[hiprand]
|
||||
source = 'github'
|
||||
github = 'ROCm/hipRAND'
|
||||
use_latest_release = true
|
||||
prefix = 'rocm-'
|
48
rocm/hiprand/PKGBUILD
Normal file
48
rocm/hiprand/PKGBUILD
Normal file
@ -0,0 +1,48 @@
|
||||
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
|
||||
# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
|
||||
pkgname=hiprand
|
||||
pkgver=6.2.4
|
||||
pkgrel=1
|
||||
pkgdesc='rocRAND marshalling library'
|
||||
arch=(x86_64 powerpc64le powerpc riscv64)
|
||||
url='https://rocm.docs.amd.com/projects/hipRAND/en/latest/'
|
||||
license=('MIT')
|
||||
depends=('rocm-core' 'glibc' 'gcc-libs' 'hip-runtime-amd' 'rocrand')
|
||||
makedepends=('cmake' 'rocm-cmake' 'gcc-fortran')
|
||||
optdepends=('gcc-fortran: Use Fortran wrapper')
|
||||
_git='https://github.com/ROCm/hipRAND'
|
||||
source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz"
|
||||
"$pkgname-rocm-bin-path.patch")
|
||||
sha256sums=('b6010f5e0c63a139acd92197cc1c0d64a428f7a0ad661bce0cd1e553ad6fd6eb'
|
||||
'144fb5162222d81559e847d31226f7b56215fa558a549c8be534cfba3fbca241')
|
||||
options=(!lto)
|
||||
_dirname="$(basename "$_git")-$(basename "${source[0]}" ".tar.gz")"
|
||||
|
||||
prepare() {
|
||||
cd "$_dirname"
|
||||
patch -Np1 -i "$srcdir/$pkgname-rocm-bin-path.patch"
|
||||
}
|
||||
|
||||
build() {
|
||||
# -fcf-protection is not supported by HIP, see
|
||||
# https://rocm.docs.amd.com/projects/llvm-project/en/latest/reference/rocmcc.html#support-status-of-other-clang-options
|
||||
local cmake_args=(
|
||||
-Wno-dev
|
||||
-S "$_dirname"
|
||||
-B build
|
||||
-D CMAKE_BUILD_TYPE=None
|
||||
-D CMAKE_TOOLCHAIN_FILE=toolchain-linux.cmake
|
||||
-D CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc
|
||||
-D CMAKE_CXX_FLAGS="${CXXFLAGS} -fcf-protection=none"
|
||||
-D CMAKE_INSTALL_PREFIX=/opt/rocm
|
||||
-D BUILD_FORTRAN_WRAPPER=ON
|
||||
)
|
||||
cmake "${cmake_args[@]}"
|
||||
cmake --build build
|
||||
}
|
||||
|
||||
package() {
|
||||
DESTDIR="$pkgdir" cmake --install build
|
||||
|
||||
install -Dm644 "$_dirname/LICENSE.txt" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
}
|
14
rocm/hiprand/hiprand-rocm-bin-path.patch
Normal file
14
rocm/hiprand/hiprand-rocm-bin-path.patch
Normal file
@ -0,0 +1,14 @@
|
||||
--- hipRAND-rocm-6.0.0/toolchain-linux.cmake.bak 2023-12-22 09:46:40.269044060 +0100
|
||||
+++ hipRAND-rocm-6.0.0/toolchain-linux.cmake 2023-12-22 09:46:47.957023549 +0100
|
||||
@@ -4,9 +4,9 @@
|
||||
#set(CMAKE_GENERATOR_PLATFORM x64)
|
||||
|
||||
if (DEFINED ENV{ROCM_PATH})
|
||||
- set(rocm_bin "$ENV{ROCM_PATH}/hip/bin")
|
||||
+ set(rocm_bin "$ENV{ROCM_PATH}/bin")
|
||||
else()
|
||||
- set(rocm_bin "/opt/rocm/hip/bin")
|
||||
+ set(rocm_bin "/opt/rocm/bin")
|
||||
endif()
|
||||
|
||||
|
36
rocm/hiprand/test.cpp
Normal file
36
rocm/hiprand/test.cpp
Normal file
@ -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);
|
||||
}
|
5
rocm/hiprand/test.sh
Executable file
5
rocm/hiprand/test.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
OUT=$(mktemp -d)
|
||||
/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lhiprand -lrocrand
|
||||
"$OUT"/test
|
Loading…
x
Reference in New Issue
Block a user