* add rocprim
This commit is contained in:
parent
ade2876ce4
commit
de7328facf
15
rocprim/.SRCINFO
Normal file
15
rocprim/.SRCINFO
Normal file
@ -0,0 +1,15 @@
|
||||
pkgbase = rocprim
|
||||
pkgdesc = Header-only library providing HIP parallel primitives
|
||||
pkgver = 6.0.2
|
||||
pkgrel = 1
|
||||
url = https://rocm.docs.amd.com/projects/rocPRIM/en/latest/index.html
|
||||
arch = any
|
||||
license = MIT
|
||||
makedepends = cmake
|
||||
makedepends = rocm-cmake
|
||||
depends = rocm-core
|
||||
depends = hip
|
||||
source = rocprim-6.0.2.tar.gz::https://github.com/ROCm/rocPRIM/archive/rocm-6.0.2.tar.gz
|
||||
sha256sums = d3998720d3206965335902f8f67ca497b320a33b810cd19b2a2264505cb38779
|
||||
|
||||
pkgname = rocprim
|
5
rocprim/.nvchecker.toml
Normal file
5
rocprim/.nvchecker.toml
Normal file
@ -0,0 +1,5 @@
|
||||
[rocprim]
|
||||
source = 'github'
|
||||
github = 'ROCm/rocPRIM'
|
||||
use_latest_release = true
|
||||
prefix = 'rocm-'
|
38
rocprim/PKGBUILD
Normal file
38
rocprim/PKGBUILD
Normal file
@ -0,0 +1,38 @@
|
||||
# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
|
||||
# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
|
||||
# Contributor: Markus Näther <naetherm@informatik.uni-freiburg.de>
|
||||
pkgname=rocprim
|
||||
pkgver=6.0.2
|
||||
pkgrel=1
|
||||
pkgdesc='Header-only library providing HIP parallel primitives'
|
||||
arch=('any')
|
||||
url='https://rocm.docs.amd.com/projects/rocPRIM/en/latest/index.html'
|
||||
_git='https://github.com/ROCm/rocPRIM'
|
||||
license=('MIT')
|
||||
depends=('rocm-core' 'hip')
|
||||
makedepends=('cmake' 'rocm-cmake')
|
||||
source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz")
|
||||
sha256sums=('d3998720d3206965335902f8f67ca497b320a33b810cd19b2a2264505cb38779')
|
||||
_dirname="$(basename "$_git")-$(basename "${source[0]}" ".tar.gz")"
|
||||
|
||||
build() {
|
||||
# -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_CXX_COMPILER=/opt/rocm/bin/hipcc
|
||||
-D CMAKE_CXX_FLAGS="${CXXFLAGS} -fcf-protection=none"
|
||||
-D CMAKE_INSTALL_PREFIX=/opt/rocm
|
||||
-D CMAKE_BUILD_TYPE=None
|
||||
)
|
||||
cmake "${cmake_args[@]}"
|
||||
cmake --build build
|
||||
}
|
||||
|
||||
package() {
|
||||
DESTDIR="$pkgdir" cmake --install build
|
||||
|
||||
install -Dm644 "$_dirname/LICENSE.txt" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
}
|
59
rocprim/test.cpp
Normal file
59
rocprim/test.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <rocprim/rocprim.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
int main()
|
||||
{
|
||||
auto xpy = [] __device__(float x, float y) -> float{
|
||||
return x + y;
|
||||
};
|
||||
|
||||
size_t size = 1024;
|
||||
std::vector<float> xin(size);
|
||||
std::vector<float> yin(size);
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_real_distribution<float> dist(-1.0, 1.0);
|
||||
|
||||
auto myrand = [&]() -> float {return dist(gen);};
|
||||
|
||||
std::generate(xin.begin(), xin.end(), myrand);
|
||||
std::generate(yin.begin(), yin.end(), myrand);
|
||||
|
||||
std::vector<float> zref(size);
|
||||
for(size_t i = 0; i < size; i++){
|
||||
zref[i] = xin[i] + yin[i];
|
||||
}
|
||||
|
||||
float *x;
|
||||
float *y;
|
||||
float *z;
|
||||
hipMalloc((void**)&x, sizeof *x * size);
|
||||
hipMalloc((void**)&y, sizeof *y * size);
|
||||
hipMalloc((void**)&z, sizeof *z * size);
|
||||
|
||||
hipMemcpy(x, xin.data(), sizeof *x * size, hipMemcpyHostToDevice);
|
||||
hipMemcpy(y, yin.data(), sizeof *y * size, hipMemcpyHostToDevice);
|
||||
|
||||
rocprim::transform(x, y, z, size, xpy);
|
||||
|
||||
std::vector<float> zout(size);
|
||||
hipMemcpy(zout.data(), z, sizeof *z * size, hipMemcpyDeviceToHost);
|
||||
|
||||
for(size_t i = 0; i < size; i++){
|
||||
if(std::abs(zout[i] - zref[i]) > 0.001f){
|
||||
std::cout << "Element mismatch at index " << i << "\n";
|
||||
std::cout << "Got " << zout[i] << " but expected " << zref[i] << "\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
std::cout << "TESTS PASSED!" << std::endl;
|
||||
|
||||
hipFree(x);
|
||||
hipFree(y);
|
||||
hipFree(z);
|
||||
}
|
6
rocprim/test.sh
Executable file
6
rocprim/test.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#! /usr/bin/env sh
|
||||
|
||||
OUT=$(mktemp -d)
|
||||
# rocPRIM uses C++14 extensions but hipcc uses C++11 by default
|
||||
/opt/rocm/bin/hipcc -std=gnu++14 -o "$OUT"/test test.cpp
|
||||
"$OUT"/test
|
Loading…
x
Reference in New Issue
Block a user