Installation MAGMA for CUDA 6.5 on UBUNTU 12.04 X64
Posted: Sun May 17, 2015 9:17 am
Dear Sir/Madam,
I am a postgraduate student at National Technical University of Athens (N.T.U.A) and I use CUDA for my study.
I need some helpful informations about MAGMA and CUDA. Any guidance you can give me on CUDA (installation and the compiling) will be valuable.
The data of the machine x64 and CUDA in my project are the following.
----------------------------------
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
----------------------------------
VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 635M]
NVIDIA CUDA 6.5
----------------------------------
The challenging issues on my project are :
0) to which directory I must installed magma files?
1) which version of fortran I should download?
2) which version of MAGMA 1.6 is the best for CUDA 6.5?
3)what is the difference between make.inc.acml – make.inc.atlas – make.inc.goto - ...
4) which paths I should modify?
5) which the compile command?
How to compile this example?
I would greatly appreciate it if you provide me with any information on the above. I look forward to hearing of you. Τhank you in advance for your time.
Best regards.
Example:
# include < stdio.h >
# include < cuda.h >
# include " magma.h "
# include " magma_lapack.h "
int main ( int argc , char ** argv ){
magma_init ();
magma_timestr_t start , end ;
float gpu_time ;
magma_int_t * piv , info ; // piv - array of indices of inter -
magma_int_t m = 8192 , n =8192; // changed rows ; a - m * n matrix
magma_int_t nrhs = 100;
// b - n * nrhs , c - m * nrhs matrices
magma_int_t mn = m * n ;
// size of a
magma_int_t nnrhs = n * nrhs ;
// size of b
magma_int_t mnrhs = m * nrhs ;
// size of c
float * a ;
// a - m * n matrix on the host
float * b ;
// b - n * nrhs matrix on the host
float * c ;
// c - m * nrhs matrix on the host
float * d_a ;
// d_a - m * n matrix a on the device
float * d_c ;
// d_c - m * nrhs matrix c on the device
magma_int_t ione = 1;
magma_int_t ISEED [4] = {0 ,0 ,0 ,1};
// seed
magma_err_t err ;
const float alpha = 1.0;
// alpha =1
const float beta = 0.0;
// beta =0
// allocate matrices
err = m agma_s malloc _cpu ( &a , mn );
// host memory for a
err = m agma_s malloc _cpu ( &b , nnrhs ); // host memory for b
err = m agma_s malloc _cpu ( &c , mnrhs ); // host memory for c
err = magma_smalloc ( & d_a , mn );
// device memory for a
err = magma_smalloc ( &d_c , mnrhs ); // device memory for c
piv =( magma_int_t *) malloc ( m * sizeof ( magma_int_t )); // host mem .
// generate matrices
// for piv
lapackf77_slarnv (&ione , ISEED ,&mn , a );
// random a
lapackf77_slaset ( MagmaUpperLowerStr ,&n ,&nrhs ,&alpha ,&alpha ,
b ,&n ); // b - n * nrhs matrix of ones
printf ( " upper left corner of the expected solution :\ n " );
magma_sprint ( 4 , 4 , b , m ); // part of the expected solution
// right hand side c = a * b
blasf77_sgemm ( " N " ," N " ,&m ,&nrhs ,&n ,&alpha ,a ,&m ,b ,&m ,&beta ,c ,&m );
magma_ssetmatrix ( m , n , a , m , d_a , m );
// copy a -> d_a
magma_ssetmatrix ( m , nrhs , c , m , d_c , m ); // copy c -> d_c
// MAGMA
// solve the linear system d_a * x = d_c , d_a -m * n matrix ,
// d_c -m * nrhs matrix , d_c is overwritten by the solution ;
// LU decomposition with partial pivoting and row interchanges
// is used , row i is interchanged with row piv ( i )
start = get_current_time ();
magma sgetrf gpu( m, n, d a, m, piv, &info);
magma sgetrs gpu(MagmaNoTrans,m,nrhs,d a,m,piv,d c,m,&info);
end = get_current_time ();
gpu_time = GetTimerValue ( start , end )/1e3 ;
printf ( " magma_sgetrf_gpu + magma_sgetrs_gpu time : %7.5 f sec .\ n " ,
gpu_time ); // Magma time
magma_sgetmatrix ( m , nrhs , d_c , m , c , m );
printf ( " upper left corner of the Magma solution :\ n " );
magma_sprint ( 4 , 4 , c , m );
// part of the Magma solution
free ( a );
free ( b );
free ( c );
free ( piv );
magma_free ( d_a );
magma_free ( d_c );
magma_finalize ();
return 0;
}
// upper left corner of the expected solution :
// [
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
// 1.0000 1.0000 1.0000 1.0000
// ];
// magma_sgetrf_gpu + magma_sgetrs_gpu time : 1.98868 sec .
//
// upper left corner of the Magma solution :
// [
//0.9999 0.9999 0.9999 0.9999
//1.0223 1.0223 1.0223 1.0223
// 1.0001 1.0001 1.0001 1.0001
//0.9871 0.9871 0.9871 0.9871
// ];
I am a postgraduate student at National Technical University of Athens (N.T.U.A) and I use CUDA for my study.
I need some helpful informations about MAGMA and CUDA. Any guidance you can give me on CUDA (installation and the compiling) will be valuable.
The data of the machine x64 and CUDA in my project are the following.
----------------------------------
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
----------------------------------
VGA compatible controller [0300]: NVIDIA Corporation GF108M [GeForce GT 635M]
NVIDIA CUDA 6.5
----------------------------------
The challenging issues on my project are :
0) to which directory I must installed magma files?
1) which version of fortran I should download?
2) which version of MAGMA 1.6 is the best for CUDA 6.5?
3)what is the difference between make.inc.acml – make.inc.atlas – make.inc.goto - ...
4) which paths I should modify?
5) which the compile command?
How to compile this example?
I would greatly appreciate it if you provide me with any information on the above. I look forward to hearing of you. Τhank you in advance for your time.
Best regards.
Example:
# include < stdio.h >
# include < cuda.h >
# include " magma.h "
# include " magma_lapack.h "
int main ( int argc , char ** argv ){
magma_init ();
magma_timestr_t start , end ;
float gpu_time ;
magma_int_t * piv , info ; // piv - array of indices of inter -
magma_int_t m = 8192 , n =8192; // changed rows ; a - m * n matrix
magma_int_t nrhs = 100;
// b - n * nrhs , c - m * nrhs matrices
magma_int_t mn = m * n ;
// size of a
magma_int_t nnrhs = n * nrhs ;
// size of b
magma_int_t mnrhs = m * nrhs ;
// size of c
float * a ;
// a - m * n matrix on the host
float * b ;
// b - n * nrhs matrix on the host
float * c ;
// c - m * nrhs matrix on the host
float * d_a ;
// d_a - m * n matrix a on the device
float * d_c ;
// d_c - m * nrhs matrix c on the device
magma_int_t ione = 1;
magma_int_t ISEED [4] = {0 ,0 ,0 ,1};
// seed
magma_err_t err ;
const float alpha = 1.0;
// alpha =1
const float beta = 0.0;
// beta =0
// allocate matrices
err = m agma_s malloc _cpu ( &a , mn );
// host memory for a
err = m agma_s malloc _cpu ( &b , nnrhs ); // host memory for b
err = m agma_s malloc _cpu ( &c , mnrhs ); // host memory for c
err = magma_smalloc ( & d_a , mn );
// device memory for a
err = magma_smalloc ( &d_c , mnrhs ); // device memory for c
piv =( magma_int_t *) malloc ( m * sizeof ( magma_int_t )); // host mem .
// generate matrices
// for piv
lapackf77_slarnv (&ione , ISEED ,&mn , a );
// random a
lapackf77_slaset ( MagmaUpperLowerStr ,&n ,&nrhs ,&alpha ,&alpha ,
b ,&n ); // b - n * nrhs matrix of ones
printf ( " upper left corner of the expected solution :\ n " );
magma_sprint ( 4 , 4 , b , m ); // part of the expected solution
// right hand side c = a * b
blasf77_sgemm ( " N " ," N " ,&m ,&nrhs ,&n ,&alpha ,a ,&m ,b ,&m ,&beta ,c ,&m );
magma_ssetmatrix ( m , n , a , m , d_a , m );
// copy a -> d_a
magma_ssetmatrix ( m , nrhs , c , m , d_c , m ); // copy c -> d_c
// MAGMA
// solve the linear system d_a * x = d_c , d_a -m * n matrix ,
// d_c -m * nrhs matrix , d_c is overwritten by the solution ;
// LU decomposition with partial pivoting and row interchanges
// is used , row i is interchanged with row piv ( i )
start = get_current_time ();
magma sgetrf gpu( m, n, d a, m, piv, &info);
magma sgetrs gpu(MagmaNoTrans,m,nrhs,d a,m,piv,d c,m,&info);
end = get_current_time ();
gpu_time = GetTimerValue ( start , end )/1e3 ;
printf ( " magma_sgetrf_gpu + magma_sgetrs_gpu time : %7.5 f sec .\ n " ,
gpu_time ); // Magma time
magma_sgetmatrix ( m , nrhs , d_c , m , c , m );
printf ( " upper left corner of the Magma solution :\ n " );
magma_sprint ( 4 , 4 , c , m );
// part of the Magma solution
free ( a );
free ( b );
free ( c );
free ( piv );
magma_free ( d_a );
magma_free ( d_c );
magma_finalize ();
return 0;
}
// upper left corner of the expected solution :
// [
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
//1.0000 1.0000 1.0000 1.0000
// 1.0000 1.0000 1.0000 1.0000
// ];
// magma_sgetrf_gpu + magma_sgetrs_gpu time : 1.98868 sec .
//
// upper left corner of the Magma solution :
// [
//0.9999 0.9999 0.9999 0.9999
//1.0223 1.0223 1.0223 1.0223
// 1.0001 1.0001 1.0001 1.0001
//0.9871 0.9871 0.9871 0.9871
// ];