Question

I'm trying to optimize some molecular simulation code (written completely in fortran) by using GPUs. I've developed a small subroutine that performs matrix vector multiplication using the cuBLAS fortran binding library (non-thunking - /usr/local/cuda/src/fortran.c on Linux).

When I tested the subroutine outside of the rest of the code (i.e. without any other external subroutine calls) everything worked. When I compiled, I used these tags -names uppercase -assume nounderscore. Without them, I would receive undefined reference errors.

When porting this into the main function of the molecular dynamics code, the -assume nounderscore -names uppercase tags mess up all of my other function calls in the main program.

Any idea of a way around this? Please refer to my previous question where -assume nounderscore -names uppercase was suggested here

Thanks in advance!

Was it helpful?

Solution

I would try Fortran-C interop. With something like

interface
  function cublas_alloc(argument list) bind(C, name="the_binding_name")
    defs of arguments
  end function
end interface

the binding name can be upper case or lowercase, whatever you need, for example, bind(C,name="CUBLAS_ALLOC"). No underscores will be appended to that.

The iso_c_binding module might be also helpful.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top