cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lpeter
Journeyman III

interfacing clmath libraries with Fortran

Dear all,

how easy is interfacing clMath clFFT,...libraries with Fortran? i need to use in a huge Fortran application.

thanks in advance

0 Likes
3 Replies
dns_on_gpu
Adept II

It is a doddle. I have  large(ish) f90 codes that call many gpu routines written

mostly by me but I also use clFFT (see below).

U need to write a "wrapper" - a C routines that is called from fortran. Here how it is done:

f90 calling routine:

Call getp_ocl( P(1,1,I), PP(1,1,I), N1, 0, JPLEN, KPLEN, MY*NY, MZ*NZ, 0 )

Now the corresponding C routine is:

void getp_ocl_( double P[], double TMP[], int *LENX, int *IOFF, \

                int *LENY, int *LENZ, int *YDIM, int *ZDIM, int *N_GPU )

{

stuff here

}

Note the appended underscore in the c routine - this is needed

by most compilers - but not all. Test your sys for what works.

Compile the fortan part with -c option

Compile the C part (with gcc) also with -c. Do not forget the various

paths for loading the libs and include headers.

Link the *.o files with your linker.

Regarding math libs on amd gpus, you may find that you need to writre

your own stuff. I am currently using clFFT extensively but it does not

work (by design) on multiple gpu cards. So I am now writing my own

fft kernels.

good luck

--

0 Likes

Thanks but my question is about a sort of analogue (if there is) of cublas thunking and non-thunking. So, something provided from the library and not hand-made piece of software (error prone and performance critical):)

thanks again

0 Likes
dns_on_gpu
Adept II

Last time I looked - about a year ago - thunking cuffts produced modest gains sp when

the io over pcie is taken into account. And surely, writing an interface routine to access

the manufacturer's software is a relatively safe process. And if performance is so critical,

it is very likely that u will have to try your hand programming.

All the best.

--

0 Likes