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

Intel Math Library

Vishnu
Novice
491 Views

The Intel C++ compiler requires one to include the header file: mathimf.h  so as to use Intel provided math functions. What does the FORTRAN compiler do? Does it use Intel math functions by default? Or do I have to do something to enable that?

Thanks!

0 Kudos
1 Solution
Steven_L_Intel1
Employee
491 Views

The Intel Fortran compiler uses the Intel math library if it provides the function, the C math library if it doesn't. You don't have control over this.

View solution in original post

0 Kudos
4 Replies
TimP
Honored Contributor III
491 Views

I suppose there are several levels to this.

The documentation of mathimf is confusing, at least to me, but I don't think your characterization of it determining whether Intel C++ or C99 use Intel functions is accurate to a great extent.  You could examine your own calling .o by using nm to get more information.

ifort never calls any x87 long double functions, as gfortran real(10) would do, so that functionality of mathimf.h isn't relevant, and you can't call glibc long double functions from ifort.

There is a fairly complete set of Intel math functions, requiring at least SSE2, shared by ifort and icc, and you have no real choice about those being called by ifort in preference to those from glibc, which might be called if Intel math functions are missing, or with ifort -mia32.

Auto-vectorized math function calls are always to the Intel libsvml.   To some extent, you can over-ride default auto-vectorization choices by the fast-transcendentals option, as well as by -fp-math and no-vec settings.

There are both Intel math functions which make a choice of code path according to CPU architecture at run time, and those which don't switch at run time, invoked by -fimf-arch-consistency, 

Most of these work the same with Intel Fortran and C++.

0 Kudos
Vishnu
Novice
491 Views

I did nm my output (attached) once with mathimf.h and once with math.h . There is no difference.

I am calling a sine function inside, so there is something that uses the math library.

0 Kudos
Steven_L_Intel1
Employee
492 Views

The Intel Fortran compiler uses the Intel math library if it provides the function, the C math library if it doesn't. You don't have control over this.

0 Kudos
gael__couturier
Beginner
491 Views

Dear Intel Developers Community,

An issue relative to control on math lib to be used. Situation:

1. When a compiled fortran code is executed, the computation time is T

2. When this same fortran code is transformed as a dynamic lib of a C++ application, the execution is 5*T.

It was identified that cos() calls in the fortran code were responsible for that performance downgrade:

in situation 1, it is cos() of lib libimf.so ​that is called.

In situation 2, is is cos() of lib libm.so.6 that is called

How to keep control on Library to be used in situation 2?

BR

Gael.

 

 

 

 

0 Kudos
Reply