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

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

Emec71LOp
Nuovo utente
1.794Visualizzazioni

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 Kudos
1 Soluzione
Emec71LOp
Nuovo utente
1.762Visualizzazioni

This did the trick. Thank you v much.

==

Visualizza soluzione nel messaggio originale

5 Risposte
Mark_Lewy
Collaboratore stimato I
1.780Visualizzazioni

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).

Emec71LOp
Nuovo utente
1.774Visualizzazioni

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.

Mark_Lewy
Collaboratore stimato I
1.767Visualizzazioni

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] );
   }
}
Emec71LOp
Nuovo utente
1.761Visualizzazioni

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

Emec71LOp
Nuovo utente
1.763Visualizzazioni

This did the trick. Thank you v much.

==

Rispondere