Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

control on math lib to be used under linux

gael__couturier
Beginner
410 Views

Dear Intel Experts,

I describe here an issue relative to control on math lib to be used by an application under Linux.

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 configuration 1, it is cos() of lib libimf.so ​that is called.

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

How to keep control on Library to be used in configuration 2? I make you note that there is neither #include <cmath> nor #include <mathimf>  in the C++ code.

Thanks for your help

Best regards,

Gael Couturier

ESI-Group

0 Kudos
3 Replies
TimP
Honored Contributor III
410 Views

If you prevent icc from linking its own library or force linking Linux math library before Intel libraries I suppose this may happen. One way to make this happen might be a premature superfluous -lm in the link command. Did you try verbose  options such as icc -# or gcc -v to see the final library search order?

0 Kudos
ESI_Group
Partner
410 Views

 

Dear Tim,

thanks for your pinpoints, it help. Yes, -lm is there in Makefile generated by CMake under linux probably because of a #include <cmath> in the C++ code.....  this might (?) affect the linking order for fortran code as that code is a plugin of C++ code (so linked against it). One workaround: we enforced C++ code to link against intel math lib.

BR

Gael.

 

0 Kudos
TimP
Honored Contributor III
410 Views

No, #include has no influence on link order, nor does it add -lm in your link step. Glad you corrected your problem.

0 Kudos
Reply