Errors with magma_dpoatrf with Quadro FX 580

Open discussion for MAGMA

Errors with magma_dpoatrf with Quadro FX 580

Postby bcouliba » Fri Mar 29, 2013 4:57 am

Hi,

I'm using magma for matrix inversion on the Quadro FX580. I use magma's double routines

But if the size of my matrix exceeds 32x32 i got a "Can not bind to texture" and also can't get my
correct result from the GPU(because the result of m*inv(m) != id).

Is anyone hnows what this problem relates to?
Attachments
result_magma.png
Screensave
result_magma.png (98.24 KiB) Viewed 1138 times
bcouliba
 
Posts: 4
Joined: Thu Mar 28, 2013 11:31 am

Re: Errors with magma_dpoatrf with Quadro FX 580

Postby bcouliba » Fri Mar 29, 2013 5:16 am

Thanks.

Kind regards.

Boubacar
bcouliba
 
Posts: 4
Joined: Thu Mar 28, 2013 11:31 am

Re: Errors with magma_dpoatrf with Quadro FX 580

Postby mgates3 » Mon Apr 01, 2013 3:55 pm

The Quadro FX 580 is CUDA capability 1.1 (as shown in your post), which means it can do only single precision, not double precision.

Also, you need to compile MAGMA with GPU_TARGET = Tesla in your make.inc file. (This is a misnomer; by "Tesla" we really mean 1.x cards, as opposed to Fermi 2.x or Kepler 3.x cards.) If this was set differently, please 'make clean' and 'make' again.

-mark
mgates3
 
Posts: 408
Joined: Fri Jan 06, 2012 2:13 pm

Re: Errors with magma_dpoatrf with Quadro FX 580

Postby bcouliba » Wed Apr 03, 2013 4:55 am

Hi,
Thanks Mark for your explanations. I'll try your recommandations as fast as i can.

I just want to know "Does the "magma_?getmatrix's" function work fine?" because
i got the memory mapping errors a lot.

Thanks.

Boubacar
bcouliba
 
Posts: 4
Joined: Thu Mar 28, 2013 11:31 am

Re: Errors with magma_dpoatrf with Quadro FX 580

Postby mgates3 » Wed Apr 03, 2013 1:37 pm

The magma_[sdcz]getmatrix functions should work fine. They are just light-weight wrappers around cublas getmatrix, intended for portability. We use them throughout MAGMA. Memory mapping errors usually occur if you overflow an array on the GPU somewhere -- after overflowing, even other arrays can have memory errors.
-mark
mgates3
 
Posts: 408
Joined: Fri Jan 06, 2012 2:13 pm

Re: Errors with magma_dpoatrf with Quadro FX 580

Postby bcouliba » Thu Apr 04, 2013 9:53 am

Hi Mark,
As you suggested me last time, i recompiled magma with GPU_TARGET = Tesla. i always got the problem of
"CUBLAS ERROR: mapping memory" when i tried to retrieve my data from GPU.
So to be very comprehensive, here is my code source.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <magma.h>
#include <magmablas.h>
#include <cublas.h>
#include <cuda_runtime_api.h>
#include <cuda.h>
#include "testings.h"


/*Read the matrix from file 'name' and store it to M*/
int msread(float **M, char *name)
{
   FILE *fMat;
   char *ligne;
   char *val;
   int nbLig ;
   int i, j, len, n;
   double b;
   
   i = 0;
   j = 0;
   nbLig = 0;
   
   
   /*Checking the file name*/
   if(name == NULL || strcmp(name," ") == 0)
      printf("Error: File name missing...");
   
   /*Open the file specified in read mode*/
   fMat = fopen(name,"r");
   
   if(fMat == NULL){
      fprintf(stderr,"Ouverture de fichier impossible\n");
      exit(2);
   }
   ligne = NULL;

   ligne = NULL;
   getline(&ligne, &len, fMat);
   val = strtok(ligne, " ");
   printf("Number of rows = %s\n", val);
   /*Allocation de la taille necéssaire pour contenir la matrice*/
   // M->n = sqrt(nbLig);
   n = atoi(val);
   (*M) = malloc(n * n * sizeof(float));
   printf("Oui...\n");
   ligne = NULL;
   ligne = malloc(100 * sizeof(char));
   
   /*Reading the file and filling the matrix
   fseek(fMat,0L,SEEK_SET);*/
         
   for(i = 0;i < n;i++)
   {
      for(j = 0;j < n;j++)
      {
         
      getline(&ligne,&len,fMat);
            
      (*M)[(i * n) + j] = (float)atof(ligne);
      // printf("%f\n", (*M)[(i * n) + j]);
      }
   }
         
   printf("reading finished\n");
   /******************************************************
   Fermeture du fichier
   *******************************************************/
   free(ligne);
   fclose(fMat);
   
   /*return the size of the matrix read*/
   return n;
}

/*Function to initialize the matrix with size*size elements,
just by begin from 1 to size*size*/
void initm_s(float **M, int size)
{
   int i;
   
   
   /*Set the matrix values*/
   (*M) = malloc( size * size * sizeof(float));
   
   
   for( i = 0;i < size * size; i++)
   {
      (*M)[i] = i + 1;
   }
   printf("init matrix...\n");
}

/*Function to print the contents of the float matrix */
void prints (float *m,int p, int q)
{
   int i, j, k;
   k = 0;
   for(i = 0;i < p;i++)
   {
      printf("\n");
      for(j = 0;j < q;j++)
      {
            printf("%f|",m[k]);
            k++;
      }
      
   }
   printf("\n");
}


/*Main function*/
int main(int argc, char **argv)
{
   int cores, ncudas, lda, info, ldda, *ipiv;
   int size, nb, lwork, k, i, j;
   double *dwork, *d_mat, *work, *inv_mat;
   float *s_mat, *s_work, *ds_mat, *c, *rep;
   CUdevice  dev;                                                 
   CUcontext context;
   
   /*Initializing Magma*/
   if( CUDA_SUCCESS != cuInit( 0 ) ) {                               
    fprintf(stderr, "CUDA: Not initialized\n" ); exit(-1);         
   }                                                                 
   if( CUDA_SUCCESS != cuDeviceGet( &dev, 0 ) ) {                   
    fprintf(stderr, "CUDA: Cannot get the device\n"); exit(-1);     
   }                                                                 
   if( CUDA_SUCCESS != cuCtxCreate( &context, 0, dev ) ) {           
    fprintf(stderr, "CUDA: Cannot create the context\n"); exit(-1);
   }                                                                 
   if( CUBLAS_STATUS_SUCCESS != cublasInit( ) ) {                   
    fprintf(stderr, "CUBLAS: Not initialized\n"); exit(-1);         
   }                                                                 
   printout_devices( );
   printf(".................................................\n%s",
   "Example with MAGMA\n.................................................\n");
   
   
   /*****Using the routines with single real *****/
   /*Reading the file   */
   lda = msread(&s_mat, argv[1]); //Stting the value of lda
   ldda = ((lda + 31)/32) * 32; // computing the value for ldda
   /*Initilizing the matrix
   initm_s(&s_mat, lda);*/
   
   // prints(s_mat, lda, 1);
   nb = magma_get_sgetri_nb(lda);
   lwork = nb * lda;
   printf("ok....%d\n", lda);
   /*Allocating the memories on GPU for the 2 arrays ds_mat & work*/
   info = cudaMalloc((void**)&ds_mat, ldda * lda * sizeof(float));
   printf("info cudaMalloc %d\n", info);
   info = cudaMallocHost((void**)&s_work, lwork * sizeof(float));
   printf("info cudaMallocHost %d\n", info);
   /*Allocating memories on CPU for result and permutation array*/
   rep = malloc( ldda * lda * sizeof(float));
   ipiv = malloc(lda * lda * sizeof(int));
   // if (ipiv == NULL)
      // printf("Error: leak of memory...\n");
   // printf("ok....%d\n", info);
   
   // printf("cudaMalloc %d\n", info);
   
   printf("Bottom...\n");
   
   /*Setting the data for GPU*/
   magma_ssetmatrix(lda, lda, s_mat, lda, ds_mat, ldda);
   // magma_sgetrf(lda, lda, s_mat, lda, ipiv, &info);
   printf("Return Code from sgetrf %d\n", info);
   
   /*trying the routine (magma_sgetrf and magma_ sgetri)for GPU*/
   printf("/*************GPU Version*****************/\n");
   magma_sgetrf_gpu(lda, lda, ds_mat, ldda, ipiv, &info);
   printf("info from magma_sgetrf_gpu %d\n", info);
   // magma_sgetmatrix(lda, lda, ds_mat, ldda, rep, lda);
   printf("/************Result after factorization***************/\n");
   // prints(rep,lda,3);
   
   
   info = 0; //resets info to 0
   magma_sgetri_gpu(lda, ds_mat, ldda, ipiv, s_work, lwork, &info);
   printf("info from magma_sgetri_gpu %d\n", info);
   magma_sgetmatrix(lda, lda, ds_mat, ldda, rep, lda);
   // info = cudaMemcpy(rep, ds_mat, lda * lda, cudaMemcpyDeviceToHost);
   
   
   /*Checking the error type from cudaMemcpy*/
   if (info == cudaErrorInvalidValue )
      printf("Error type invalidValue\n");
      
   if (info == cudaErrorInvalidDevicePointer )
      printf("Error type Device Pointer\n");
      
   if (info == cudaErrorInvalidMemcpyDirection )
      printf("Error type Memcpy Direction\n");
   
   if (info == cudaSuccess )
      printf("Error type Success\n");
   
   // printf("info cudaMemcpy %d\n", info);
   
   // prints(rep,lda,2); //printing the matrix
   
   
   /*Desallocating memories used*/
   free(ipiv);
   free(s_mat);
   cudaFree(ds_mat);
   // free(im.mat);
   // free(im);
   // free(c);
   cudaFreeHost(s_work);
   free(rep);
   
   /*Closing magma context*/
   cuCtxDetach( context );
   cublasShutdown();
   
   printf("/**************End**************************/\n");
   return 0;
}


i want to get your attention to a fact: i didn't get an error from sgetmatrix when i initialize the matrix with the function initm_s but i got one when i read from the file.
Also, first time when i call sgetmatrix just after the magma_sgetrf_gpu i got no error message; but only after the call of magma_sgetri_gpu i got the "memory mapping error".
i included the matrix from which i read.

Thanks for your help.

Kind regards
Boubacar
bcouliba
 
Posts: 4
Joined: Thu Mar 28, 2013 11:31 am


Return to User discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron