Skip to content

Better error messages and tests for sm2 #2797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Better error messages and tests for sm2 #2797

wants to merge 1 commit into from

Conversation

kshyatt
Copy link
Member

@kshyatt kshyatt commented Jun 23, 2025

We can get rid of all this once we drop support for CUSPARSE 11 but in the meantime it's nice to have better error messages

@kshyatt kshyatt requested a review from amontoison June 23, 2025 20:18
@kshyatt kshyatt added cuda libraries Stuff about CUDA library wrappers. tests Adds or changes tests. labels Jun 23, 2025
Copy link
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/test/libraries/cusparse/interfaces.jl b/test/libraries/cusparse/interfaces.jl
index 6ebcaab6b..af839ceae 100644
--- a/test/libraries/cusparse/interfaces.jl
+++ b/test/libraries/cusparse/interfaces.jl
@@ -371,7 +371,7 @@ using LinearAlgebra, SparseArrays
         for elty in (Float32, Float64, ComplexF32, ComplexF64)
             m = 100
             A = sprand(elty, m, m, 0.1)
-            U2 = 2*I(m)
+            U2 = 2 * I(m)
             U3 = Diagonal(rand(elty, m))
             for SparseMatrixType in (CuSparseMatrixCSC, CuSparseMatrixCSR, CuSparseMatrixCOO)
                 B = SparseMatrixType(A)
@@ -445,8 +445,8 @@ using LinearAlgebra, SparseArrays
                     ldiv!(triangle(opa(dA)), opb(dB))
                     @test B ≈ collect(dB)
                     if CUSPARSE.version() < v"12.0"
-                        B_bad     = opb == identity ? rand(elty, m+1, n) : rand(elty, n, m+1)
-                        error_str = opb == identity ? "first dimensions of A ($m) and X ($(m+1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m+1)) when transxy is not 'N'"
+                        B_bad = opb == identity ? rand(elty, m + 1, n) : rand(elty, n, m + 1)
+                        error_str = opb == identity ? "first dimensions of A ($m) and X ($(m + 1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m + 1)) when transxy is not 'N'"
                         @test_throws DimensionMismatch(error_str) ldiv!(triangle(opa(dA)), opb(CuArray(B_bad)))
                     end
                 end
@@ -470,8 +470,8 @@ using LinearAlgebra, SparseArrays
                     dC = triangle(opa(dA)) \ opb(dB)
                     @test C ≈ collect(dC)
                     if CUSPARSE.version() < v"12.0"
-                        B_bad = opb == identity ? rand(elty, m+1, n) : rand(elty, n, m+1)
-                        error_str = opb == identity ? "first dimensions of A ($m) and X ($(m+1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m+1)) when transxy is not 'N'"
+                        B_bad = opb == identity ? rand(elty, m + 1, n) : rand(elty, n, m + 1)
+                        error_str = opb == identity ? "first dimensions of A ($m) and X ($(m + 1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m + 1)) when transxy is not 'N'"
                         @test_throws DimensionMismatch(error_str) ldiv!(triangle(opa(dA)), opb(CuArray(B_bad)))
                     end
                 end
@@ -553,8 +553,8 @@ using LinearAlgebra, SparseArrays
                         ldiv!(triangle(opa(dA)), opb(dB))
                         @test B ≈ collect(dB)
                         if CUSPARSE.version() < v"12.0"
-                            B_bad = opb == identity ? rand(elty, m+1, n) : rand(elty, n, m+1)
-                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m+1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m+1)) when transxy is not 'N'"
+                            B_bad = opb == identity ? rand(elty, m + 1, n) : rand(elty, n, m + 1)
+                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m + 1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m + 1)) when transxy is not 'N'"
                             @test_throws DimensionMismatch(error_str) ldiv!(triangle(opa(dA)), opb(CuArray(B_bad)))
                         end
                     end
@@ -581,8 +581,8 @@ using LinearAlgebra, SparseArrays
                         ldiv!(dC, triangle(opa(dA)), opb(dB))
                         @test C ≈ collect(dC)
                         if CUSPARSE.version() < v"12.0"
-                            B_bad = opb == identity ? rand(elty, m+1, n) : rand(elty, n, m+1)
-                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m+1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m+1)) when transxy is not 'N'"
+                            B_bad = opb == identity ? rand(elty, m + 1, n) : rand(elty, n, m + 1)
+                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m + 1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m + 1)) when transxy is not 'N'"
                             @test_throws DimensionMismatch(error_str) ldiv!(triangle(opa(dA)), opb(CuArray(B_bad)))
                         end
                     end
@@ -607,8 +607,8 @@ using LinearAlgebra, SparseArrays
                         dC = triangle(opa(dA)) \ opb(dB)
                         @test C ≈ collect(dC)
                         if CUSPARSE.version() < v"12.0"
-                            B_bad = opb == identity ? rand(elty, m+1, n) : rand(elty, n, m+1)
-                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m+1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m+1)) when transxy is not 'N'"
+                            B_bad = opb == identity ? rand(elty, m + 1, n) : rand(elty, n, m + 1)
+                            error_str = opb == identity ? "first dimensions of A ($m) and X ($(m + 1)) must match when transxy is 'N'" : "first dimension of A ($m) must match second dimension of X ($(m + 1)) when transxy is not 'N'"
                             @test_throws DimensionMismatch(error_str) ldiv!(triangle(opa(dA)), opb(CuArray(B_bad)))
                         end
                     end

@kshyatt
Copy link
Member Author

kshyatt commented Jun 24, 2025

Test fails don't look related to me? CI is very flaky right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuda libraries Stuff about CUDA library wrappers. tests Adds or changes tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants