GETRI gives wrong result

Support for issues specific to the Linux operating systems.

GETRI gives wrong result

Postby djegesm » Sun Nov 28, 2010 2:45 pm

Hi,

I have an Ubuntu 9.10 with NVIDIA UNIX x86_64 Kernel Module 256.35 for Tesla C2070

Using the code below getri does not give me the right inverse.
I have no idea why it doesn't work.
It seems like, that other functions give also wrong answers, although i haven't tested many of them.
It could be that the problem occurs because of my computer settings/setup, but I just don't know where to look for it..
Any help is appreciated!

Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <culapack.h>

int newgetri(int N, float *A,int LDA)
{
    culaStatus status;
    culaInt* IPIV = NULL;
    culaFloat* MM = NULL;
    int i,j;

    IPIV = (culaInt*)malloc(N*sizeof(culaInt));
    MM = (culaFloat*)malloc(N*N*sizeof(culaFloat));
    memset(IPIV, 0, N*sizeof(culaInt));
    memcpy(MM,A,N*N*sizeof(culaFloat));

    status = culaInitialize();

    printf("Calling culaSgetri\n");
    for(i=0;i<LDA;i++)
    {
      for(j=0;j<N;j++)
        printf("%f ", A[i*LDA+j]);
      printf("\n");
    }


    status = culaSgetri(N, MM, N, IPIV);
    printf("FINISHED with calculation\n Status %d\n",status);
    memcpy(A,MM,N*N*sizeof(culaFloat));
    for(i=0;i<LDA;i++)
    {
     for(j=0;j<N;j++)
     printf("%f ", A[i*LDA+j]);
    printf("\n");
    }

   culaShutdown();

   free(MM);
   free(IPIV);

   return status;
}

int main()
{
int M=3;  int N=3;
culaFloat* A = NULL;
int i,j;
     
A = (culaFloat*)malloc(M*N*sizeof(culaFloat));
memset(A, 0.0, M*N*sizeof(culaFloat));
                     
float E=1.0;
float T=0.0;
                               
A[0]=E;
A[4]=E;
A[8]=E;
A[1]=T;
A[3]=T;
A[5]=T;
A[7]=T;
A[6]=0.0;
A[2]=0.0;

newgetri(N,A,M);
newgetri(N, A, M);

free(A)         ;

return 0;
};


I compile it like:
Code: Select all
gcc -m64 geev_mod.c -o geev  -I/usr/local/cula/include -L/usr/local/cula/lib64 -lcula -lcublas -lcudart


Thanks in advance!
David
Attachments
SYSINFO.txt
(8.8 KiB) Downloaded 391 times
djegesm
 
Posts: 2
Joined: Wed Nov 17, 2010 11:46 am

Re: GETRI gives wrong result

Postby john » Mon Nov 29, 2010 9:46 am

You need to first call getrf prior to calling getri. It's also worth noting that if your intent is to solve a system of equations that it's better to call gesv instead of getrf/getri/trmm.

Also, be careful with your matrix storage. LAPACK is column major, and so is CULA. Your equation should be A[i+j*LDA] to access A(i,j).
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm

Re: GETRI gives wrong result

Postby djegesm » Tue Nov 30, 2010 2:06 pm

Thank you for the reply.
I totally overlooked that first i need to call getrf. Also in pycula this implementation is wrong. I might write them about this issue.

Now it works fine
Thanks again!

David
djegesm
 
Posts: 2
Joined: Wed Nov 17, 2010 11:46 am

Re: GETRI gives wrong result

Postby luiceur » Mon Jul 09, 2012 3:48 am

Is it possible to use culaSgetri from the Free version? I got undefined reference to `culaSgetri' when I try to compile with the Free version
luiceur
 
Posts: 4
Joined: Fri Jul 06, 2012 4:06 am

Re: GETRI gives wrong result

Postby john » Tue Jul 24, 2012 10:53 am

That's correct, it is not in CULA Free.
john
Administrator
 
Posts: 587
Joined: Thu Jul 23, 2009 2:31 pm


Return to Linux Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron