Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

C or Fortran?

hcgeorg
Beginner
324 Views
So, I intend to write a scientific program based on MKL.
The main question I have is: do I use C or Fortran?
I'm mainly concerned with performance, but I would like to hear general pros and cons from the experienced.

Thanks in advance,
Herbert
0 Kudos
1 Reply
TimP
Honored Contributor III
324 Views
If most of the time is spent in MKL functions, performance would be the same with either calling language, if direct low level function calls are used. With care, and use of extensions, Intel C++ can give full performance in its own code as well as in MKL.
MKL is more widely used with Intel Fortran than C. Intel has recognized this in the new Fortran Professional offerings which provide both in one package.
Current MKL with non-Intel compilers has the disadvantage that OpenMP can't be used in both the compiler and in MKL, because of the different OpenMP libraries. MKL serial libraries avoid this problem, but require any threading to be performed by the calling application.
BLAS calling conventions are more awkward in C than in Fortran. MKL provides the Fortran95 wrappers to clean it up, possibly with performance penalty. As far as I know, only gfortran provides options to compile MATMUL as ?GEMM calls. gfortran is supported with MKL only on linux (and Mac?).
For C, MKL provides fft wrappers to ease implementation, apparently with a performance penalty.

0 Kudos
Reply