Hello, hope you are having a good day…
I have a problem calling CUBLAS functions, as I am clueless to how they are called in fortran.
I have followed the way CULA routines were followed and read the advice from the “CUDA Library Interfaces” pdf.
However, the rest does not come intuitively with me.
I am trying to get the inverse of Matrix A (using cublasDgetriBatched and cublasDgetrfBatched) which its dimension and cell values are called from a text file.
The code is bellow and I get this error… “PGF90-S-0148-Reference to derived type required (inverse.cuf: 43)”
Could you kindly give me an example that uses a similar function… the “isamax” example in the pdf is quite easy to understand yet different.
I am grateful for any help.
! Compile with "pgfortran -Mlarge_arrays inverse.cuf -Mcudalib=cublas -lblas" PROGRAM MatrixInverse use cudafor use cublas use iso_c_binding IMPLICIT NONE CHARACTER*1000 infile,outfile type(c_devptr),ALLOCATABLE, device :: A(:,:),C(:,:) INTEGER,ALLOCATABLE, device :: ipiv(:) INTEGER istat, status type(cublasHandle) :: h INTEGER :: n INTEGER :: lda INTEGER :: ldc INTEGER, device :: info(:) INTEGER :: batchCount INTEGER DI, I, J Real time1,time2 DOUBLE PRECISION,ALLOCATABLE :: mat(:,:) ! input file names from $INV$ OPEN(5,FILE='$INV$') READ(5,'(A)') infile READ(5,'(A)') outfile close(5) ! input matrix data to be inversed OPEN(1,FILE=infile) READ(1,*) DI n=DI lda=DI ldc=DI write(*,*) 'Matrix size is : ',DI,'x',DI ALLOCATE(mat(DI,DI)) DO I=1,DI DO J=1,DI READ(1,*)mat(I,J) END DO END DO close(1) ! Allocate Allocate (A(DI,DI)) Allocate (C(DI,DI)) A = mat ! initialize cublas print *, 'Cublas starts' ! cublas SOLVES allocate(ipiv(DI)) open (99, file='Inverse_GPU_Time.txt',status='unknown') ! start call CPU_Time(time1) print *, 'Starting CUBLAS (Host interface)' status = cublasCreate(h) ! call cublas status = cublasDgetrfBatched(h, DI, A, DI, ipiv, info,batchCount) status = cublasDgetriBatched(h, DI, A, DI, ipiv, C, DI,info, batchCount) ! stop mat = A status=cudaDeviceSynchronize() call CPU_Time(time2) write(99,*) 'Time spent GPU: ', time2-time1 OPEN(4,FILE=outfile) DO 6 I=1,DI DO 7 J=1,DI write(4,*)mat(I,J) 7 END DO 6 END DO status = cublasDestroy(h) close(4) END