issue about using magma with PGI fortran

Open discussion for MAGMA

issue about using magma with PGI fortran

Postby bsb3166 » Wed Aug 31, 2011 6:16 pm

http://www.pgroup.com/lit/articles/insider/v3n1a5.htm

This thread talks about how to use magma with PGI fortran to use those PGI cuda fortran features. But it only gives any example about making use of the MAGMA SGEMM routine in fortran (binding C).

They build interface of sgemm like this:
Code: Select all
interface sgemm
  subroutine sgemmDev(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, l
dc) bind(c,name='magmablas_sgemm')
   use iso_c_binding
   integer(c_int), value :: m, n, k, lda, ldb, ldc
   real(c_float), device, dimension(m,n) :: a, b, c
   real(c_float), value :: alpha, beta
   character(kind=c_char), value :: transa, transb
  end subroutine sgemmDev
end interface


However when I want to use complex version device routine "magma_cgesv_gpu", I found no way to use the same method to write the interface so that I can call the magma routine in fortran code.
I wrote my interface like this:
Code: Select all
module cgesv_gpu_magma
   
use cudafor

interface ! cgesvDev
  subroutine McgesvDev(n, nrhs, a, lda, ipiv, b, ldb, info) bind(c,name='magma_cgesv_gpu')
   use iso_c_binding
   integer(c_int), value :: n, nrhs, lda, ldb, info
   complex(C_FLOAT_COMPLEX), device, dimension(n,n) :: a
   complex(C_FLOAT_COMPLEX), device, dimension(n,nrhs) :: b
   integer(c_int), device, dimension(n) :: ipiv
  end subroutine McgesvDev
end interface

end module cgesv_gpu_magma


However, in fact, the type of complex variable the magma use is not normal complex type in C, it's "cuFloatComplex". I can not find the corresponding constant from ISO_C_BINDING(http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/fortran/lin/compiler_f/bldaps_for/common/bldaps_interopc.htm). The C_FLOAT_COMPLEX is the corresponding constant from ISO_C_BINDING to normal complex in C. Using C_FLOAT_COMPLEX results in error when I run my code([n53:88718] Signal: Segmentation fault (11); [n53:88718] Signal code: Address not mapped (1)).

Does any one know how to solve this problem or have example about using magam complex version device routine in fortran?

The reason I don't use the fortran interface "magmaf_cgesv_gpu" that magma provide is the complex variable's type is a pointer, but I want to use the cuda fortran features to declare complex variable as "complex(b4), device, allocatable :: dA(:,:), dB(:,:)". So If I use the fortran interface that magma provide, I would get the error info that the arguments 3 and 6 are invalid.

Code: Select all
     subroutine magmaf_cgesv_gpu(  n, nrhs, dA, ldda, ipiv, dB, lddb, info)
       integer       :: n
       integer       :: nrhs
       magma_devptr_t:: dA
       integer       :: ldda
       integer       :: ipiv(*)
       magma_devptr_t:: dB
       integer       :: lddb
       integer       :: info
     end subroutine magmaf_cgesv_gpu


Please help, I really need to get this work. Thank you in advance.
bsb3166
 
Posts: 8
Joined: Mon Jul 25, 2011 12:28 pm

Re: issue about using magma with PGI fortran

Postby mateo70 » Fri Sep 02, 2011 11:17 am

Hi,

I'm sorry but I have no idea how to do that. The only thing I know is that if you use PGI, you shouldn't use the MAGMA Fortran interface because PGI compiler can handle the pointer on GPU as any other arrays. So, I think the idea is more to look at what we started for PGI interface but that we didn't finished.

Regards,
Mathieu
mateo70
 
Posts: 41
Joined: Tue Mar 08, 2011 12:38 pm

Re: issue about using magma with PGI fortran

Postby bsb3166 » Tue Sep 06, 2011 11:37 am

mateo70 wrote:Hi,

I'm sorry but I have no idea how to do that. The only thing I know is that if you use PGI, you shouldn't use the MAGMA Fortran interface because PGI compiler can handle the pointer on GPU as any other arrays. So, I think the idea is more to look at what we started for PGI interface but that we didn't finished.

Regards,
Mathieu


Yes, MAGMA Fortran interface is not gonna work here. But, the problem is how to handle those complex. Does any other MAGMA developer has advise in this issue that using complex version MAGMA routine in fortran (writing C binding)??

Thank you for your reply. Waiting for solution =(
bsb3166
 
Posts: 8
Joined: Mon Jul 25, 2011 12:28 pm


Return to User discussion

Who is online

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