Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29250 讨论

Using ifort to link .o files compiled with ifort & nvcc

Emec71LOp
新手
1,753 次查看

Hello,

I have a big(ish) fluids simulation code written in fortran which is compiled with ifort to run on 2 Xeon v4s. I am also trying gpu acceleration using C  interface routines (with iso C bindings) and of late I am trying to use a couple nvidia teslas for acceleration.

When compiling the C part of the code with gcc, ifort will link with the object files and nvidia libraries (cufft, cublas).  But having to write my own kernels it is necessary to be able compiling with nvcc. When doing so,  ifort cannot find any of the C routines.

A search for similar queries  produced no recent posts on the subject and the older suggestions seem not to work. It seems odd that this issue may be  unresolved given the dominance intel processors. A similar question on the nvidia site produced a wave of apathy.

 

Any suggestions?

Thanks.

--

0 项奖励
1 解答
Emec71LOp
新手
1,721 次查看

This did the trick. Thank you v much.

==

在原帖中查看解决方案

0 项奖励
5 回复数
Mark_Lewy
重要分销商 I
1,739 次查看

Without seeing an example of your code (perhaps a small reproducer?), it is difficult to say what might be going wrong.  We have CFD code that uses Fortran and CUDA (and hence nvcc) that builds fine on Windows and Linux, but we don't use ISO C binding (because the code predated Fortran 2003 support).

0 项奖励
Emec71LOp
新手
1,733 次查看

Thanks for the quick answer. Files anything.c  and anything.cu are identical. No specific cuda routines are invoked. Just simple C code. The last screenshot shows what happens.

0 项奖励
Mark_Lewy
重要分销商 I
1,726 次查看

CUDA code behaves like C++ by default, so you need to declare your functions with extern "C", i.e.

#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime_api.h>

extern "C" void anything_( double A[], int *Nin )
{
int i;

   for( i=1; i<*Nin; i++ ) {
    printf("\n  i, A(i) = %d  %f ", i, A[i] );
   }
}
0 项奖励
Emec71LOp
新手
1,720 次查看

Thanks again. Flagged my post as solution instead of yours. Dimnation.

0 项奖励
Emec71LOp
新手
1,722 次查看

This did the trick. Thank you v much.

==

0 项奖励
回复