3 Replies Latest reply on Dec 29, 2015 10:53 AM by dns.on.gpu

    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

        • Re: interfacing clmath libraries with Fortran

          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


          • Re: interfacing clmath libraries with Fortran

            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.