我正在尝试使用GPU优化一些分子模拟代码(完全用fortran编写)。我开发了一个小子程序,使用cuBLAS fortran绑定库(Linux上的非thunking - /usr/local/cuda/src/fortran.c)执行矩阵向量乘法。
当我在其余代码之外测试子程序时(即没有任何其他外部子程序调用)一切正常。编译时,我使用了这些标记-names uppercase -assume nounderscore
。没有它们,我会收到未定义的引用错误。
当将其移植到分子动力学代码的主函数中时,-assume nounderscore -names uppercase
标签会破坏主程序中的所有其他函数调用。
有什么想法解决这个问题吗?请参阅我之前提出-assume nounderscore -names uppercase
{{1}}的问题{/ 3}}
提前致谢!
答案 0 :(得分:2)
我会尝试Fortran-C互操作。有点像
interface
function cublas_alloc(argument list) bind(C, name="the_binding_name")
defs of arguments
end function
end interface
绑定名称可以是大写或小写,无论您需要什么,例如bind(C,name="CUBLAS_ALLOC")
。不会附加下划线。
iso_c_binding
模块也可能有用。