Minor bug in magma_?tritri[_gpu]

Open discussion for MAGMA

Minor bug in magma_?tritri[_gpu]

Postby ReL » Tue Jul 31, 2012 8:16 am

Hello,

I have just noticed something while reading the source code of magma_?trtri:
Code: Select all
#define A(i, j)  (a   +(j)*lda  + (i))
...
        /*  Check for singularity if non-unit */
        if (nounit)
        {
                for (*info=0; *info < n; *info=*info+1)
                {
                        if(A(*info,*info)==0)
                                return *info;
                }
                *info=0;
        }

It seems you are comparing the pointer address with 0 instead of checking the corresponding value *A(*info,*info).

A similar problem exists in magma_?trtri_gpu
Code: Select all
#define dA(i, j) (dA+(j)*ldda + (i))
...
        /*  Check for singularity if non-unit */
        if (nounit)
        {
                for (*info=0; *info < n; *info=*info+1)
                {
                        if(dA(*info,*info)==0)
                                return *info;
                }
                *info=0;
        }

I don't think this code makes sense when dA is on the GPU memory. The only reason it doesn't crash is that the pointer address is being compared to 0 instead of the corresponding value (which you can't get just by dereferencing the pointer if I'm not mistaken).

Rémi
ReL
 
Posts: 13
Joined: Tue Jun 05, 2012 7:20 am
Location: France

Re: Minor bug in magma_?tritri[_gpu]

Postby mgates3 » Tue Jul 31, 2012 1:05 pm

Good catch. For the CPU interface, that should be

Code: Select all
    /* Check for singularity if non-unit */
    if (nounit) {
        for ( j=0; j<n; ++j ) {
            if ( MAGMA_Z_EQUAL( *A(j,j), c_zero )) {
                *info = j+1;  // Fortran index
                return *info;
            }
        }
    }


For the GPU interface, obviously dereferencing the pointer won't work, as you point out. For the moment, I disabled the check. I'll think about how to solve it.
-mark
mgates3
 
Posts: 442
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests