public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/rocsparse] epel10: Reuse Archlinux smoke test
@ 2026-06-12 12:35 Tom Rix
  0 siblings, 0 replies; only message in thread
From: Tom Rix @ 2026-06-12 12:35 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/rocsparse
            Branch : epel10
            Commit : 670a23ea932ccabe27a8de43f1f369b208a098e9
            Author : Tom Rix <Tom.Rix@amd.com>
            Date   : 2026-02-11T08:46:55-08:00
            Stats  : +110/-1 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/rocsparse/c/670a23ea932ccabe27a8de43f1f369b208a098e9?branch=epel10

            Log:
            Reuse Archlinux smoke test

Licensed as 0BSD
repo https://gitlab.archlinux.org/archlinux/packaging/packages/rocsparse.git
commit 2bf1c7fdfa48198061ad71a5734d68e6a5fed74f

Signed-off-by: Tom Rix <Tom.Rix@amd.com>

---
diff --git a/rocsparse.spec b/rocsparse.spec
index e2aa3cf..8087829 100644
--- a/rocsparse.spec
+++ b/rocsparse.spec
@@ -131,7 +131,7 @@ Version:        %{rocm_version}
 Release:        1%{?dist}
 %endif
 Summary:        SPARSE implementation for ROCm
-License:        MIT
+License:        MIT AND 0BSD
 URL:            https://github.com/ROCm/rocm-libraries
 
 %if %{with gitcommit}

diff --git a/test.cpp b/test.cpp
new file mode 100644
index 0000000..4382efc
--- /dev/null
+++ b/test.cpp
@@ -0,0 +1,100 @@
+#include <rocsparse/rocsparse.h>
+#include <hip/hip_runtime.h>
+#include <iostream>
+#include <vector>
+#include <random>
+#include <algorithm>
+
+int main()
+{
+    using rint = rocsparse_int;
+    rint n = 4096;
+
+    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::vector<float> xin(n);
+    std::generate(xin.begin(), xin.end(), myrand);
+
+    rocsparse_handle handle;
+    rocsparse_create_handle(&handle); 
+
+    std::vector<rint> row_ptr(n + 1);
+    std::vector<rint> col(3 * n);
+    std::vector<float> data(3 * n);
+    
+    //Second order finite differences matrix in 1D
+    row_ptr[0] = 0;
+    for(size_t i = 0; i < n; i++){
+        rint off = row_ptr[i];
+        if(i > 0){
+            col[off] = i - 1;
+            data[off++] = -1.0f;
+        }
+        col[off] = i;
+        data[off++] = 2.0f;
+        if(i < n - 1){
+            col[off] = i + 1;
+            data[off++] = -1.0f;
+        }
+        row_ptr[i + 1] = off;
+    }
+
+    rint *rp;
+    rint *c;
+    float *d;
+
+    float *x;
+    float *y;
+    hipMalloc((void **)&rp, sizeof *rp * (n + 1));
+    hipMalloc((void **)&c, sizeof *c * 3 * n);
+    hipMalloc((void **)&d, sizeof *d * 3 * n);
+
+    hipMalloc((void **)&x, sizeof *x * n);
+    hipMalloc((void **)&y, sizeof *y * n);
+
+    hipMemcpy(rp, row_ptr.data(), sizeof *rp * (n + 1), hipMemcpyHostToDevice);
+    hipMemcpy(c, col.data(), sizeof *c * 3 * n, hipMemcpyHostToDevice);
+    hipMemcpy(d, data.data(), sizeof *d * 3 * n, hipMemcpyHostToDevice);
+
+    hipMemcpy(x, xin.data(), sizeof *x * n, hipMemcpyHostToDevice);
+
+    float alpha = 14.124f;
+    float beta = 0.0f;
+
+    rocsparse_mat_descr descr;
+    rocsparse_create_mat_descr(&descr);
+
+    rocsparse_scsrmv(handle, rocsparse_operation_none,
+        n, n, 3 * n - 2, &alpha, descr, d, rp, c, nullptr,
+        x, &beta, y);
+
+    std::vector<float> yout(n);
+    hipMemcpy(yout.data(), y, sizeof *y * n, hipMemcpyDeviceToHost);
+
+    float tol = 0.0001f;
+    for(rint i = 0; i < n; i++){
+        for(rint jj = row_ptr[i]; jj < row_ptr[i + 1]; jj++){
+            rint j = col[jj];
+            yout[i] -= alpha * data[jj] * xin[j];
+        }
+        if(std::abs(yout[i]) > tol){
+            std::cout << "Entry " << i << " is not computed correctly.\n";
+            std::cout << "Expected 0 but got " <<  yout[i] << std::endl;
+            return 1;
+        }
+    }
+
+    std::cout << "TESTS PASSED!" << std::endl;
+
+    rocsparse_destroy_handle(handle);
+    rocsparse_destroy_mat_descr(descr);
+    hipFree(rp);
+    hipFree(c);
+    hipFree(d);
+    hipFree(x);
+    hipFree(y);
+}

diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..eb05d60
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,9 @@
+#! /usr/bin/env sh
+
+BPATH=/usr/bin
+IPATH=/usr/include
+LPATH=/usr/lib64
+
+OUT=$(mktemp -d)
+${BPATH}/hipcc -o "$OUT"/test test.cpp -I${IPATH} -L${LPATH} -lrocsparse -lamdhip64
+"$OUT"/test

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-12 12:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12 12:35 [rpms/rocsparse] epel10: Reuse Archlinux smoke test Tom Rix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox