Date: Monday, December 26, 2022 @ 17:05:48
  Author: tpkessler
Revision: 1368501

Migrate hipcub from AUR to community

Added:
  hipcub/
  hipcub/repos/
  hipcub/trunk/
  hipcub/trunk/PKGBUILD
  hipcub/trunk/test.cpp
  hipcub/trunk/test.sh

----------+
 PKGBUILD |   35 +++++++++++++++++++++++++++++++++++
 test.cpp |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 test.sh  |    6 ++++++
 3 files changed, 89 insertions(+)

Added: hipcub/trunk/PKGBUILD
===================================================================
--- hipcub/trunk/PKGBUILD                               (rev 0)
+++ hipcub/trunk/PKGBUILD       2022-12-26 17:05:48 UTC (rev 1368501)
@@ -0,0 +1,35 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+# Contributor: Markus Näther <[email protected]>
+pkgname=hipcub
+pkgver=5.4.1
+pkgrel=2
+pkgdesc='Header-only library on top of rocPRIM or CUB'
+arch=('x86_64')
+url='https://hipcub.readthedocs.io/en/latest/'
+license=('custom')
+depends=('rocprim' 'hip')
+makedepends=('rocm-cmake')
+_git='https://github.com/ROCmSoftwarePlatform/hipCUB'
+source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz")
+sha256sums=('1900cc34d925d588696ce9de34c4cbfda2f939cb74ed0e1069c3b1417f14393e')
+_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_INSTALL_PREFIX=/opt/rocm \
+    -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc
+  cmake --build build
+}
+
+package() {
+  DESTDIR="$pkgdir" cmake --install build
+  install -Dm644 "$_dirname/LICENSE.txt" 
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}

Added: hipcub/trunk/test.cpp
===================================================================
--- hipcub/trunk/test.cpp                               (rev 0)
+++ hipcub/trunk/test.cpp       2022-12-26 17:05:48 UTC (rev 1368501)
@@ -0,0 +1,48 @@
+#include <hipcub/hipcub.hpp>
+#include <vector>
+#include <iostream>
+#include <random>
+#include <algorithm>
+
+int main()
+{
+    size_t size = 1024;
+    std::vector<float> xin(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);
+
+    float *x;
+    float *xs;
+    hipMalloc((void**)&x, sizeof *x * size);
+    hipMalloc((void**)&xs, sizeof *xs * size);
+
+    hipMemcpy(x, xin.data(), sizeof *x * size, hipMemcpyHostToDevice);
+
+    void *tmp_storage = nullptr;
+    size_t tmp_storage_bytes = 0;
+    hipcub::DeviceRadixSort::SortKeys(tmp_storage, tmp_storage_bytes, x, xs, 
size);
+    hipMalloc((void**)&tmp_storage, tmp_storage_bytes);
+    hipcub::DeviceRadixSort::SortKeys(tmp_storage, tmp_storage_bytes, x, xs, 
size);
+
+    std::vector<float> xout(size);
+    hipMemcpy(xout.data(), xs, sizeof *xs * size, hipMemcpyDeviceToHost);
+
+    for(size_t i = 1; i < size; i++){
+        if(xout[i - 1] > xout[i]){
+            std::cout << "Elements not sorted at index " << i << "\n";
+            std::cout << x[i - 1] << " " << x[i] << std::endl;
+            return 1;
+        }
+    }
+    std::cout << "TESTS PASSED!" << std::endl;
+
+    hipFree(x);
+    hipFree(xs);
+    hipFree(tmp_storage);
+}

Added: hipcub/trunk/test.sh
===================================================================
--- hipcub/trunk/test.sh                                (rev 0)
+++ hipcub/trunk/test.sh        2022-12-26 17:05:48 UTC (rev 1368501)
@@ -0,0 +1,6 @@
+#! /usr/bin/env sh
+
+OUT=$(mktemp -d)
+# hipCUB 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


Property changes on: hipcub/trunk/test.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Reply via email to