MAGMA ZGESV wrong answer

30 views
Skip to first unread message

Roland Greffe

unread,
Jan 30, 2025, 10:53:49 AMJan 30
to MAGMA User
Hello,
I'm using the magma_zgesv_gpu routine in order to factorize and solve linear systems, and some matrices don't give me the same solutions as others solvers (numpy's linalg.solve for example). I'm getting a solution vector where some elements are correct and others are close to 0.0 when they shouldn't be. Is this some kind of expected behavior given the used matrix and vector, or did I make a mistake in my code (My code is basically copied from testing_zgesv.cpp)? I've attached the used matrix (sparsely stored) and vector.
Thanks in advance for your help,
Roland Greffe
numpy_solution.txt
matrix.csv
vector.csv

Natalie Beams

unread,
Jan 30, 2025, 10:55:08 AMJan 30
to MAGMA User, Roland Greffe
Hi Roland, 

I know you said your code is very similar to testing_zgesv.cpp, but could you still share it? It would be helpful for us to be able to reproduce what you are seeing. 

Thanks,
Natalie

Roland Greffe

unread,
Jan 31, 2025, 12:09:46 PMJan 31
to MAGMA User, Natalie Beams, Roland Greffe
Hello,
Yes of course ! Here it is.
Best regards,
Roland Greffe
zgesv.cpp

Natalie Beams

unread,
Jan 31, 2025, 1:11:08 PMJan 31
to MAGMA User, Roland Greffe, Natalie Beams
Hi Roland, 

Thanks for sharing your code. Looking at the part where you read in the matrix from the file, it looks like you are using row-major order.
MAGMA uses column major.

If I swap i and j there, i.e., replace

h_A[j + i*lda] = value; // row major -- column index changes fastest

with 

h_A[i + j*lda] = value;  // column major -- row index changes fastest

the output appears to match the numpy results you shared.


-- Natalie

Andrew Cunningham

unread,
Feb 5, 2025, 10:26:04 AMFeb 5
to Roland Greffe, MAGMA User, Natalie Beams
testing_zgesv.cpp performs the operations using both MKL ( as the refererene) and magma. 

If you have any questions about magma correctness, the first place to start is to use MKL as the standard to compare against. 


-- 
You received this message because you are subscribed to the Google Groups "MAGMA User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to magma-user+...@icl.utk.edu.
To view this discussion visit https://groups.google.com/a/icl.utk.edu/d/msgid/magma-user/0ea1b576-a952-40f3-bf25-a0d36e8de6d4n%40icl.utk.edu.
<zgesv.cpp>

Roland Greffe

unread,
Feb 5, 2025, 10:26:08 AMFeb 5
to MAGMA User, Natalie Beams, Roland Greffe

Hi Natalie,
Thank you so much for your time ! It was indeed the issue. I forgot that Magma used column major.
Best regards,
Roland Greffe
Reply all
Reply to author
Forward
0 new messages