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

Use intel mkl when compiling with gfortran

nadavhalahmi
Novice
507 Views

I'm trying to make my gfortran compiled program to use intel mkl's pow implementation.

I managed to use LD_PRELOAD trick as follows (same line, gnu.out is my executable):

 

LD_PRELOAD=/software/x86_64/intel/parallel_studio_xe_2020_update4/compilers_and_libraries_2020.4.304/linux/compiler/lib/intel64_lin/libimf.so ./gnu.out

 

 But I would like to use only pow implementation - this way, I can control which functions I change implementation to.

 

So ideally, here is what I want:

 

LD_PRELOAD=/path/to/part_of_libm.so ./gnu.out

 

 when part_of_libm.so only includes the implementation of pow, and no other functions.

0 Kudos
6 Replies
OrenMustaki
Beginner
486 Views

the following example will create *.so for pow

extract object files from archive
mkdir temp
cd temp
ar x /path/to/parallel_studio_xe_.../compilers_and_libraries_.../linux/compiler/lib/intel64_lin/libimf.a
ar x /path/to/parallel_studio_xe_.../compilers_and_libraries_.../linux/compiler/lib/intel64_lin/libirc.a cpu_feature_disp.o

create shared object from object files
gcc -shared -o libpow.so pow*.o libm_feature_flag.o cpu_feature_disp.o logq_table.o scaleq_table.o const_q_table.o logl_table.o rcpq_table.o rcp_table.o expl_table.o expq_table.o

load needed library and run
LD_PRELOAD=/path/to/libpowf.so ./a.out

RahulV_intel
Moderator
451 Views

Hi,

 

As suggested by @OrenMustaki, you would need to extract the object files of the library file and create a library file out of those object files that are required.

 

Let us know if your issue is resolved.

 

Thanks,

Rahul

 

nadavhalahmi
Novice
444 Views

It worked, but how can I tell which o files do I need? Is there an automated way to do so? @RahulV_intel @OrenMustaki 

RahulV_intel
Moderator
383 Views
RahulV_intel
Moderator
365 Views

Hi,


Any updates on this? Feel free to let us know if you face any issues.


Thanks,

Rahul


RahulV_intel
Moderator
352 Views

Hi,


We are assuming that the solution provided helped and would no longer be monitoring this issue. Please raise a new thread if you have further issues.


Regards,

Rahul


Reply