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:
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:
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.
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.