Date: Monday, December 26, 2022 @ 16:59:07
Author: tpkessler
Revision: 1368500
archrelease: copy trunk to community-testing-x86_64
Added:
rocprim/repos/community-testing-x86_64/
rocprim/repos/community-testing-x86_64/PKGBUILD
(from rev 1368499, rocprim/trunk/PKGBUILD)
rocprim/repos/community-testing-x86_64/test.cpp
(from rev 1368499, rocprim/trunk/test.cpp)
rocprim/repos/community-testing-x86_64/test.sh
(from rev 1368499, rocprim/trunk/test.sh)
----------+
PKGBUILD | 37 +++++++++++++++++++++++++++++++++++++
test.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
test.sh | 6 ++++++
3 files changed, 102 insertions(+)
Copied: rocprim/repos/community-testing-x86_64/PKGBUILD (from rev 1368499,
rocprim/trunk/PKGBUILD)
===================================================================
--- community-testing-x86_64/PKGBUILD (rev 0)
+++ community-testing-x86_64/PKGBUILD 2022-12-26 16:59:07 UTC (rev 1368500)
@@ -0,0 +1,37 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+# Contributor: Markus Näther <[email protected]>
+pkgname=rocprim
+pkgver=5.4.1
+pkgrel=2
+pkgdesc='Header-only library providing HIP parallel primitives'
+arch=('x86_64')
+url='https://codedocs.xyz/ROCmSoftwarePlatform/rocPRIM'
+_git='https://github.com/ROCmSoftwarePlatform/rocPRIM'
+license=('MIT')
+depends=('hip')
+makedepends=('rocm-cmake')
+source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz")
+sha256sums=('3a2e09eb5b65114444feed545c03fbf766af33ace1f14467d4190d63c688ca61')
+_dirname="$(basename "$_git")-$(basename "${source[0]}" ".tar.gz")"
+
+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 \
+ -S "$_dirname" \
+ -B build \
+ -DCMAKE_BUILD_TYPE=None \
+ -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
+ -DCMAKE_INSTALL_PREFIX=/opt/rocm \
+ -Damd_comgr_DIR=/opt/rocm/lib/cmake/amd_comgr
+ cmake --build build
+}
+
+package() {
+ DESTDIR="$pkgdir" cmake --install build
+
+ install -Dm644 "$_dirname/LICENSE.txt"
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}
Copied: rocprim/repos/community-testing-x86_64/test.cpp (from rev 1368499,
rocprim/trunk/test.cpp)
===================================================================
--- community-testing-x86_64/test.cpp (rev 0)
+++ community-testing-x86_64/test.cpp 2022-12-26 16:59:07 UTC (rev 1368500)
@@ -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);
+}
Copied: rocprim/repos/community-testing-x86_64/test.sh (from rev 1368499,
rocprim/trunk/test.sh)
===================================================================
--- community-testing-x86_64/test.sh (rev 0)
+++ community-testing-x86_64/test.sh 2022-12-26 16:59:07 UTC (rev 1368500)
@@ -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