Function sgetrs return NaN

Open discussion for MAGMA

Function sgetrs return NaN

Postby red_cat » Tue Nov 06, 2012 5:52 am

When I solve SLE after matrix factorization (attached) with function sgetrs_gpu and nrhs>1, I get NaN in solution vector. If nrhs=1, answer is true. dgetrf.cpp is code for solution attached test matrix.
What am I doing wrong?
Attachments
dgetrf.cpp
code
(1.32 KiB) Downloaded 91 times
test_magma.tar.gz
test matrix and vector
(417.21 KiB) Downloaded 87 times
red_cat
 
Posts: 3
Joined: Tue Nov 06, 2012 5:28 am

Re: Function sgetrs return NaN

Postby mgates3 » Tue Nov 06, 2012 4:05 pm

When I run this code, I get the correct answer.

There are a few things to improve in the code.
* You allocate A twice, once with malloc and once with magma_malloc_cpu, leading to a memory leak.
* Check whether info != 0 after all LAPACK and MAGMA functions that take info.
* Verify that A, b, ipiv, A_ptr, and b_ptr are not NULL after allocating them.
* There is no need to copy A_ptr back to A after getrf, unless you need it for some other purpose.

Also, a change in future versions of MAGMA:
* If you use magma_malloc_cpu(), use magma_free_cpu() to free the memory. On POSIX this doesn't matter, but on Windows the aligned-memory malloc must be paired with an aligned-memory free. Using magma_malloc_cpu() is not required; it is similar to malloc but uses posix_memalign or similar to ensure that memory allocations are aligned to 32 byte boundaries (which MKL requires for reproducibility).

-m
mgates3
 
Posts: 329
Joined: Fri Jan 06, 2012 2:13 pm

Re: Function sgetrs return NaN

Postby red_cat » Wed Nov 07, 2012 7:59 am

mgates3 wrote:There are a few things to improve in the code.
* You allocate A twice, once with malloc and once with magma_malloc_cpu, leading to a memory leak.
* Check whether info != 0 after all LAPACK and MAGMA functions that take info.
* Verify that A, b, ipiv, A_ptr, and b_ptr are not NULL after allocating them.
* There is no need to copy A_ptr back to A after getrf, unless you need it for some other purpose.


Thanks for your remarks, I was inattentive. But problem is not solved. And if I use "magma_free_cpu", then linker out "undefined reference" error.
Attachments
main.cpp
(1.48 KiB) Downloaded 84 times
red_cat
 
Posts: 3
Joined: Tue Nov 06, 2012 5:28 am

Re: Function sgetrs return NaN

Postby mgates3 » Wed Nov 07, 2012 12:14 pm

I have been unable to reproduce the problem. If you give more specifics, it would be helpful -- what OS, BLAS and LAPACK library, NVIDIA card, CUDA version, MAGMA version, etc. are you using? A copy of your MAGMA make.inc is helpful. Does magma/testing/testing_sgetrf_gpu run correctly?

Particularly some older cards exhibit some bugs. You can try commenting out these lines in magma/src/sgetrf_gpu.cpp and magma/src/sgetrs_gpu.cpp and re-compiling MAGMA.

//#if (defined(PRECISION_s) || defined(PRECISION_d))
// #define magma_zgemm magmablas_zgemm
// #define magma_ztrsm magmablas_ztrsm
//#endif

//#if (defined(PRECISION_s) || defined(PRECISION_d))
// #define magma_ztrsm magmablas_ztrsm
//#endif

Regarding magma_free_cpu, as I said, that is a feature in future MAGMA releases. It doesn't exist in 1.2.1. I just wanted you to be aware of the upcoming change.
-mark
mgates3
 
Posts: 329
Joined: Fri Jan 06, 2012 2:13 pm

Re: Function sgetrs return NaN

Postby red_cat » Thu Nov 08, 2012 12:35 am

OS - Linux Ubuntu 12.04 (kernel 3.2.0-31-generic),
BLAS and LAPACK by Intel MKL (v. 10.3.9.293)
MAGMA 1.2.1
GPU - GeForce 9600
CUDA 4.2, V0.2.1221

testing_sgetrf_gpu does run correctly.
Attachments
make.inc.txt
(1.18 KiB) Downloaded 83 times
red_cat
 
Posts: 3
Joined: Tue Nov 06, 2012 5:28 am

Re: Function sgetrs return NaN

Postby mgates3 » Wed Nov 14, 2012 7:10 pm

On further testing, it appears that the problem is indeed with the magmablas_strsm on the old pre-Fermi architecture. As I indicated previously, comment that section out of src/*getrs_gpu.cpp, as shown below. You can test with testing_sgesv_gpu, which does magma_sgetrf_gpu followed by magma_sgetrs_gpu.

//#if (defined(PRECISION_s) || defined(PRECISION_d))
// #define magma_ztrsm magmablas_ztrsm
//#endif

I made this change for the next release of magma, as well.
-mark
mgates3
 
Posts: 329
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: Baidu [Spider], mgates3 and 2 guests