PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

issue about using magma with PGI fortran

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
bsb3166



Joined: 27 Jun 2011
Posts: 10

PostPosted: Wed Aug 31, 2011 3:16 pm    Post subject: issue about using magma with PGI fortran Reply with quote

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:
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:
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:
     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.
Back to top
View user's profile
bsb3166



Joined: 27 Jun 2011
Posts: 10

PostPosted: Tue Sep 06, 2011 8:40 am    Post subject: Reply with quote

Mat, did you have any advice about my issue?

Thank you very much.
Back to top
View user's profile
brentl



Joined: 20 Jul 2004
Posts: 132

PostPosted: Tue Sep 06, 2011 10:27 am    Post subject: Reply with quote

The way you have the complex arrays declared looks okay. Maybe it is something else. Is info an input or output? If it is output, it should not be passed by value.

You can always use the ignore_tkr directive to loosen the interface acceptance matching.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group