Date: Monday, December 19, 2022 @ 15:54:20
  Author: tpkessler
Revision: 1361610

Migrate hip-runtime-amd from AUR to community

Added:
  hip-runtime-amd/
  hip-runtime-amd/repos/
  hip-runtime-amd/trunk/
  hip-runtime-amd/trunk/PKGBUILD
  hip-runtime-amd/trunk/test.cpp
  hip-runtime-amd/trunk/test.sh

----------+
 PKGBUILD |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.cpp |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test.sh  |    6 +++++
 3 files changed, 130 insertions(+)

Added: hip-runtime-amd/trunk/PKGBUILD
===================================================================
--- hip-runtime-amd/trunk/PKGBUILD                              (rev 0)
+++ hip-runtime-amd/trunk/PKGBUILD      2022-12-19 15:54:20 UTC (rev 1361610)
@@ -0,0 +1,58 @@
+# Maintainer: Torsten Keßler <tpkessler at archlinux dot org>
+# Contributor: acxz <akashpatel2008 at yahoo dot com>
+pkgname=hip-runtime-amd
+pkgver=5.4.1
+pkgrel=2
+pkgdesc="Heterogeneous Interface for Portability ROCm"
+arch=('x86_64')
+url='https://docs.amd.com/bundle/HIP-Programming-Guide-v5.4/page/Introduction_to_HIP_Programming_Guide.html'
+license=('MIT')
+depends=('mesa' 'comgr' 'rocminfo' 'rocm-llvm' 'libelf')
+makedepends=('cmake' 'python' 'python-cppheaderparser')
+provides=('hip')
+conflicts=('hip')
+_hip='https://github.com/ROCm-Developer-Tools/HIP'
+_opencl='https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime'
+_rocclr='https://github.com/ROCm-Developer-Tools/ROCclr'
+_hipamd='https://github.com/ROCm-Developer-Tools/hipamd'
+source=("$pkgname-$pkgver.tar.gz::$_hip/archive/rocm-$pkgver.tar.gz"
+        "$pkgname-opencl-$pkgver.tar.gz::$_opencl/archive/rocm-$pkgver.tar.gz"
+        "$pkgname-rocclr-$pkgver.tar.gz::$_rocclr/archive/rocm-$pkgver.tar.gz"
+        "$pkgname-hipamd-$pkgver.tar.gz::$_hipamd/archive/rocm-$pkgver.tar.gz")
+sha256sums=('12e82877b55324f1910e760f4c5ec105bf6547b69215997d8d098fc463d399c3'
+            '2b3d7b365f569ce64d1408d6e745d005aa10eca3623891be50f6b1b2e802d875'
+            'c0926fa5dad71cd02f21504d82e218d482779df579a400604e13864e6b2a7d9c'
+            '8ca75fa4a472dfbc8059b7f5ad717466c0db544c516950b3fa32c5de32980216')
+_dirhip="$(basename "$_hip")-$(basename "${source[0]}" ".tar.gz")"
+_diropencl="$(basename "$_opencl")-$(basename "${source[1]}" ".tar.gz")"
+_dirrocclr="$(basename "$_rocclr")-$(basename "${source[2]}" ".tar.gz")"
+_dirhipamd="$(basename "$_hipamd")-$(basename "${source[3]}" ".tar.gz")"
+
+build() {
+  # build fails if cmake and make are called from outside the build directory
+  mkdir build && cd build
+
+  # Disable assertations as a temporary workaround for hipRTC
+  # 
https://github.com/ROCmSoftwarePlatform/rocFFT/issues/389#issuecomment-1341370581
+  CXXFLAGS="$CXXFLAGS -DNDEBUG" \
+  cmake \
+    -Wno-dev \
+    -S "$srcdir/$_dirhipamd" \
+    -DHIP_COMMON_DIR="$srcdir/$_dirhip" \
+    -DAMD_OPENCL_PATH="$srcdir/$_diropencl" \
+    -DROCCLR_PATH="$srcdir/$_dirrocclr" \
+    -DHIP_PLATFORM=amd \
+    -DCMAKE_BUILD_TYPE=None \
+    -DROCM_DIR=/opt/rocm \
+    -DCMAKE_INSTALL_PREFIX=/opt/rocm
+
+  cmake --build .
+}
+
+package() {
+  DESTDIR="$pkgdir" cmake --install build
+
+  install -Dm644 "$srcdir/$_dirhip/LICENSE.txt" 
"$pkgdir/usr/share/licenses/$pkgname/LICENSE"
+  echo '/opt/rocm/hip/lib' > "$pkgname.conf"
+  install -Dm644 "$pkgname.conf" "$pkgdir/etc/ld.so.conf.d/$pkgname.conf"
+}

Added: hip-runtime-amd/trunk/test.cpp
===================================================================
--- hip-runtime-amd/trunk/test.cpp                              (rev 0)
+++ hip-runtime-amd/trunk/test.cpp      2022-12-19 15:54:20 UTC (rev 1361610)
@@ -0,0 +1,66 @@
+#include <iostream>
+#include <cmath>
+#include <vector>
+#include <hip/hip_runtime.h>
+
+__global__
+void saxpy(int n, float a, const float *x, float *y)
+{
+    int i = hipThreadIdx_x + hipBlockDim_x * hipBlockIdx_x;
+    if(i < n){
+        y[i] = a * x[i] + y[i];
+    }
+}
+
+__global__
+void sset(int n, float a, float *x)
+{
+    int i = hipThreadIdx_x + hipBlockDim_x * hipBlockIdx_x;
+    if(i < n){
+        x[i] = a;
+    }
+}
+
+int main()
+{
+    hipDeviceProp_t prop;
+    hipGetDeviceProperties(&prop, 0);
+    std::cout << "Agent " << prop.name << "\n";
+    std::cout << "System version " << prop.major
+        << "." << prop.minor << "\n";
+
+    int n = 1024;
+    float *x;
+    float *y;
+    hipMalloc((void**)&x, sizeof *x * n);
+    hipMalloc((void**)&y, sizeof *y * n);
+
+    std::vector<float> xin(n);
+    for(int i = 0; i < n; i++){
+        xin[i] = -1.0 + 2.0 * i / n;
+    }
+    hipMemcpy(x, xin.data(), sizeof *x * n, hipMemcpyHostToDevice);
+
+    float ac = -14.412f;
+    hipLaunchKernelGGL(sset, dim3(1), dim3(n), 0, 0, n, ac, y);
+
+    float a = 5321.124f;
+    hipLaunchKernelGGL(saxpy, dim3(1), dim3(n), 0, 0, n, a, x, y);
+
+    std::vector<float> yout(n);
+    hipMemcpy(yout.data(), y, sizeof *y * n, hipMemcpyDeviceToHost);
+
+    hipFree(x);
+    hipFree(y);
+
+    for(int i = 0; i < n; i++){
+        yout[i] -= a * xin[i];
+        if(std::abs(yout[i] - ac) > 0.001f){
+            std::cout << "Test failed at index " << i
+                << " with entry " << yout[i]
+                << " (" << ac << ")\n";
+            return 1;
+        }
+    }
+    std::cout << "TESTS PASSED!" << std::endl;
+}

Added: hip-runtime-amd/trunk/test.sh
===================================================================
--- hip-runtime-amd/trunk/test.sh                               (rev 0)
+++ hip-runtime-amd/trunk/test.sh       2022-12-19 15:54:20 UTC (rev 1361610)
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+OUT=$(mktemp -d)
+
+/opt/rocm/bin/hipcc -o "$OUT/test" test.cpp
+"$OUT"/test


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

Reply via email to