Date: Sunday, May 14, 2023 @ 10:28:24
  Author: tpkessler
Revision: 1461569

archrelease: copy trunk to community-staging-x86_64

Added:
  hipfft/repos/community-staging-x86_64/
  hipfft/repos/community-staging-x86_64/PKGBUILD
    (from rev 1461568, hipfft/trunk/PKGBUILD)
  hipfft/repos/community-staging-x86_64/test.cpp
    (from rev 1461568, hipfft/trunk/test.cpp)
  hipfft/repos/community-staging-x86_64/test.sh
    (from rev 1461568, hipfft/trunk/test.sh)

----------+
 PKGBUILD |   40 ++++++++++++++++++++++++++++++++++++++++
 test.cpp |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 test.sh  |    5 +++++
 3 files changed, 96 insertions(+)

Copied: hipfft/repos/community-staging-x86_64/PKGBUILD (from rev 1461568, 
hipfft/trunk/PKGBUILD)
===================================================================
--- community-staging-x86_64/PKGBUILD                           (rev 0)
+++ community-staging-x86_64/PKGBUILD   2023-05-14 10:28:24 UTC (rev 1461569)
@@ -0,0 +1,40 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+
+pkgname=hipfft
+pkgver=5.5.0
+pkgrel=2
+pkgdesc='rocFFT marshalling library.'
+arch=('x86_64')
+url='https://hipfft.readthedocs.io/en/latest/'
+license=('MIT')
+depends=('hip' 'rocfft')
+makedepends=('rocm-cmake' 'git')
+_git='https://github.com/ROCmSoftwarePlatform/hipFFT'
+source=("$pkgname-$pkgver.tar.gz::$_git/archive/rocm-$pkgver.tar.gz")
+sha256sums=('47ec6f7da7346c312b80daaa8f763e86c7bdc33ac8617cfa3344068e5b20dd9e')
+options=(!lto)
+_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.5/page/Compiler_Options_and_Features.html#d2e2018
+  CXXFLAGS="${CXXFLAGS} -fcf-protection=none" \
+  ROCM_PATH=/opt/rocm \
+  cmake \
+    -Wno-dev \
+    -B build \
+    -S "$_dirname" \
+    -DCMAKE_BUILD_TYPE=None \
+    -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc \
+    -DCMAKE_INSTALL_PREFIX=/opt/rocm
+  cmake --build build
+}
+
+package() {
+  DESTDIR="$pkgdir" cmake --install build
+
+  echo "/opt/rocm/$pkgname/lib" > "$pkgname.conf"
+  install -Dm644 "$pkgname.conf" "$pkgdir/etc/ld.so.conf.d/hipfft.conf"
+
+  install -Dm644 "$srcdir/$_dirname/LICENSE.md" 
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+}

Copied: hipfft/repos/community-staging-x86_64/test.cpp (from rev 1461568, 
hipfft/trunk/test.cpp)
===================================================================
--- community-staging-x86_64/test.cpp                           (rev 0)
+++ community-staging-x86_64/test.cpp   2023-05-14 10:28:24 UTC (rev 1461569)
@@ -0,0 +1,51 @@
+#include <hipfft/hipfft.h>
+#include <hip/hip_runtime.h>
+#include <vector>
+#include <numeric>
+#include <cmath>
+#include <iostream>
+
+int main()
+{
+    size_t size = 1024 * 1024;
+
+    hipfftComplex *x;
+    hipMalloc((void**)&x, sizeof *x * size);
+
+    std::vector<hipfftComplex> xin(size);
+    for(auto &xx: xin){
+        xx.x = 1.0f;
+        xx.y = 0.0f;
+    }
+    hipMemcpy(x, xin.data(), sizeof *x * size, hipMemcpyHostToDevice);
+
+    hipfftHandle plan;
+    hipfftPlan1d(&plan, size, HIPFFT_C2C, 1);
+
+    hipfftExecC2C(plan, x, x, HIPFFT_FORWARD);
+
+    std::vector<hipfftComplex> xout(size);
+    hipMemcpy(xout.data(), x, sizeof *x * size, hipMemcpyDeviceToHost);
+
+    std::vector<hipfftComplex> xref(size);
+    for(auto &xx: xref){
+        xx.x = 0.0f;
+        xx.y = 0.0f;
+    }
+    xref[0].x = 1.0f * size;
+    
+    float tol = 0.001f;
+    for(size_t i = 0; i < size; i++){
+        if(std::abs(xref[i].x - xout[i].x) + std::abs(xref[i].y - xout[i].y) > 
tol){
+            std::cout << "Element mismatch at index " << i << "\n";
+            std::cout << "Expected: " << xref[i].x << " " << xref[i].y << "\n";
+            std::cout << "Actual  : " << xout[i].x << " " << xout[i].y << "\n";
+            return 1;
+        }
+    }
+
+    std::cout << "TESTS PASSED!" << std::endl;
+
+    hipFree(x);
+    hipfftDestroy(plan);
+}

Copied: hipfft/repos/community-staging-x86_64/test.sh (from rev 1461568, 
hipfft/trunk/test.sh)
===================================================================
--- community-staging-x86_64/test.sh                            (rev 0)
+++ community-staging-x86_64/test.sh    2023-05-14 10:28:24 UTC (rev 1461569)
@@ -0,0 +1,5 @@
+#! /usr/bin/env sh
+
+OUT=$(mktemp -d)
+/opt/rocm/bin/hipcc -o "$OUT"/test test.cpp -lhipfft -lrocfft
+"$OUT"/test

Reply via email to