Hi,
I wanted to try this out. My test Fortran module is the following, which
I compile with: ifort -mkl -o test_mod.so test_mod.f90 -shared -fpic
,----
| module testmodule
|
| implicit none
|
| double precision, external :: ddot
| double precision, dimension(3) :: d,e
|
| integer :: i
|
| contains
|
| function dot_f()
| double precision :: dot_f
|
| do i = 1,3
| d(i) = 1.0d0*i
| e(i) = 3.5d0*i
| end do
|
| dot_f = ddot(3,d,1,e,1)
| end function dot_f
|
| END module testmodule
`----
and my test.jl
,----
| ccall((:testmodule_mp_dot_f_, "./test_mod"),Float64, ())
`----
If I try to run test.jl I get, as per the OP:
,----
| julia> include("test.jl")
| Intel MKL FATAL ERROR: Cannot load libmkl_avx.so or libmkl_def.so.
`----
"Steven G. Johnson" <[email protected]> writes:
> I got
> Intel MKL FATAL ERROR: Cannot load libmkl_avx2.so or libmkl_def.so.
>
> Possibly you need to add the directory containing these files
> (/opt/intel/composer_xe_2015.0.090/mkl/lib or similar?) to your
> LD_LIBRARY_PATH
> environment variable, so that the runtime linker knows where to find them.
In this case this is not enough.
If you try to open the library directly you get:
,----
| julia>
Libdl.dlopen("/opt/intel/2016.0.1/compilers_and_libraries_2016.1.150/linux/mkl/lib/intel64/libmkl_avx2.so")
| ERROR: could not load library
|
"/opt/intel/2016.0.1/compilers_and_libraries_2016.1.150/linux/mkl/lib/intel64/libmkl_avx2.so"
|
/opt/intel/2016.0.1/compilers_and_libraries_2016.1.150/linux/mkl/lib/intel64/libmkl_avx2.so:
| undefined symbol: mkl_dft_fft_fix_twiddle_table_32f
| in dlopen(::String, ::UInt32) at ./libdl.jl:90 (repeats 2 times)
`----
and nm confirms that those symbols are undefined:
,----
| [angelv@duna intel64]$ nm libmkl_avx2.so | grep fft_fix
| U mkl_dft_fft_fix_twiddle_table_32f
| U mkl_dft_fft_fix_twiddle_table_64f
`----
and they are acutally defined in libmkl_core.so
,----
| [angelv@duna intel64]$ nm libmkl_core.so | grep fft_fix
| 00000000018e3020 D mkl_dft_fft_fix_twiddle_table_32f
| 00000000018e2800 D mkl_dft_fft_fix_twiddle_table_64f
| [angelv@duna intel64]$
`----
So, a workaround is to open libmkl_core.so first with the flag
RTLD_GLOBAL and then run the test.jl code:
,----
| julia>
|
Libdl.dlopen("/opt/intel/2016.0.1/compilers_and_libraries_2016.1.150/linux/mkl/lib/intel64/libmkl_core.so",Libdl.RTLD_GLOBAL)
| Ptr{Void} @0x0000000003af6fa0
|
| julia> include("test.jl")
| 49.0
`----
But, to be honest, I don't fully understand if this will be enough for
all codes using MKL or perhaps other dependencies are there which forces
you to open more libraries manually with RTLD_GLOBAL. But at least it
points in the right direction.
Cheers,
--
Ángel de Vicente
http://www.iac.es/galeria/angelv/