Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
292 Views

FFTW from MKL seems to conflict with icv from opencv 4.1.2

Hi All,

It seems there is a conflict between icv and MKL. 

It is very stracge to see MKL calling icv_l9_commit function from opencv

Steps to reproduce

Operating system ubuntu 18.04 (same on ubuntu 16.04)
Libraries 
 opencv 4.1.2 (on cmake configuration it recognised presence of MKL)
 MKL 2019.3  (2018.0 works, 2018.2 and up give segfault)
Compiler gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0


Source code
---------

#include <fftw3.h>

#include <iostream>

#include <opencv2/core/core.hpp>

int main(int argc, char** argv)
{
    int m_iWidth = 64;
    int m_iHeight = 64;
    int iDirection = -1;
    float fMotionValue = 0.5;

    cv::Mat  m_tmpMat;

std::cerr << "---------- try alloc1\n";
    auto m_ptInputData = fftw_alloc_complex(m_iWidth * m_iHeight);
std::cerr << "---------- try alloc2\n";
    auto m_ptOutputData = fftw_alloc_complex(m_iWidth * m_iHeight);

    // Construct the FFT plan.
std::cerr << "---------- try to plan\n";

    auto tFFTPlan = fftw_plan_dft_2d(m_iWidth, m_iHeight, m_ptInputData, m_ptOutputData, iDirection, FFTW_ESTIMATE);
std::cerr << "---------- plan ok\n";

    return 0;
}


----

Build command line

/usr/bin/c++ fftw_test3.cpp -L/opt/intel/mkl/lib/intel64 /buf/libs/opencv-4.1.2/lib/libopencv_core.so.4.1.2 -lmkl_intel_lp64 -lmkl_core  -lmkl_intel_thread  /opt/intel/compilers_and_libraries/linux/lib/intel64_lin/libiomp5.so -Wl,-rpath,/buf/libs/opencv-4.1.2/lib:/opt/intel/mkl/lib/intel64:/opt/intel/compilers_and_libraries/linux/lib/intel64_lin


Output
$ ./a.out 
---------- try alloc1
---------- try alloc2
---------- try to plan
Segmentation fault (core dumped)


GDB run

(gdb) run
Starting program: /buf/test/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
---------- try alloc1
---------- try alloc2
---------- try to plan

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff704f70f in icv_l9_commit () from /buf/libs/opencv-4.1.2/lib/libopencv_core.so.4.1
(gdb) bt
#0  0x00007ffff704f70f in icv_l9_commit () from /buf/libs/opencv-4.1.2/lib/libopencv_core.so.4.1
#1  0x00007fffeb689f1f in static_dfti_commit () from /opt/intel/mkl/lib/intel64/libmkl_avx2.so
#2  0x00007fffeb151cab in commit () from /opt/intel/mkl/lib/intel64/libmkl_avx2.so
#3  0x00007fffeb689f1f in static_dfti_commit () from /opt/intel/mkl/lib/intel64/libmkl_avx2.so
#4  0x00007ffff63f4cd0 in DftiCommitDescriptor () from /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so
#5  0x00007ffff63fc651 in fftw_plan_guru64_dft () from /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so
#6  0x00007ffff63fb945 in fftw_plan_dft () from /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so
#7  0x00007ffff63fb996 in fftw_plan_dft_2d () from /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.so
#8  0x0000555555554de1 in main ()

 
0 Kudos
11 Replies
Highlighted
Moderator
292 Views

Will you see the same segfault in the case if comment OpenCV call from this example?  //cv::Mat  m_tmpMat; 

0 Kudos
Highlighted
Beginner
292 Views

Hi Gennady,

After removing cv::Mat there will be no segfault. Because opencv library will not be linked. In this example code I put it deliberately to make sure opencv is linked. The problem boils down to the conflict between opencv and MKL.

Best regards

Alexey

 

 

0 Kudos
Highlighted
Moderator
292 Views

Alexey, this is the first time we hear about such a problem!  Do you see similar behaviour with the latest stable OpenCV v.4.2?

0 Kudos
Highlighted
Beginner
292 Views

Hi Gennady,

It is the same problem with OpenCV 4.2.0 (it uses same ippicv_2019_lnx_intel64_general_20180723 icv libraryr as 4.1.2).

However when I build opencv as static lib then it seems the problem disappear. This it turn suggests that there is clash of names in the libraries. 

Have you tried to reproduce the problem following the steps I gave at the beginning?

Best regards

Alexey

 

 
0 Kudos
Highlighted
Moderator
292 Views

hi Alexey,  no, We only check how mkl's part works isolated from OpenCV.  Once again - we never heard about such kind of problem and might be trying to investigate the case later. In the case of this is the high priority to your application, You could try to submit this case to the official support channel - Intel Online Service Center. thanks,Gennady

0 Kudos
Highlighted
Beginner
292 Views

Hi Gennady,

I have a bit more information regarding this issue.

The single dynamic library mkl_rt on linux is missing "fftw_alloc_complex" symbol (function). On windows platform the library has the symbol.

Regards

Alexey

 

 
0 Kudos
Highlighted
Moderator
292 Views

Interestingly, it might be a problem. Thanks,  Alexey, we will check.

0 Kudos
Highlighted
Moderator
292 Views

yes, I confirmed the issue on linux os, meantime these symbols exist on win64. We will fix the issue and keep this thread updated. thanks, Gennady

0 Kudos
Highlighted
Moderator
290 Views

fyi - the fix of the issue is targeting to be available the next update of Intel MKL 2020


0 Kudos
Highlighted
Moderator
234 Views

fyi - the fix of the issue available in the latest Update 2 of MKL 2020. This update available for download.


0 Kudos
Highlighted
Moderator
232 Views

the fix: the symbols were added to the mkl_rt.so

/opt/intel/compilers_and_libraries_2020.2.254/linux/mkl/lib/intel64

$ grep -i "fftw_alloc_complex" *.so
Binary file libmkl_gf_ilp64.so matches
Binary file libmkl_gf_lp64.so matches
Binary file libmkl_intel_ilp64.so matches
Binary file libmkl_intel_lp64.so matches
Binary file libmkl_rt.so matches

0 Kudos