- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I would like to create native C dynamically loaded shared library on Linux which use MKL FFT functions. The final goal - to call it from C# (mono) through P/Invoke.
When I run test example C program (not shared library) MKL works fine,
But if I pack my functions to the .so file and call it from C# (mono) through P/Invoke, then I got "DllNotFound" exeption. Without MKL my .so library works also fine.
I supposed that I have to build shared MKL library with -fPIC flag.
So, I went to /opt/intel/mkl/tools/builder and created the libmkldft.so library with dft_example_list functions by adding -fPIC to all command lines in makefile and run "make sointel64 export=dft_example_list name=libmkldft"
then copied the libmkldft.so to /opt/intel/mkl/lib/intel64/ directory and build my test library by
ld -shared -soname libfftt.so -o libfftt.so -L /opt/intel/mkl/lib/intel64/ -lmkldft Fft.o
And finally I have "System.DllNotFoundExeption" at (wrapper managed-to-native)
If I comment MKL FFT functions in the libfftt.so then I don't have exeptions and all works fine
How to make my shared MKL library work?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Grigorii,
Do you have libmkldft.so (and libiomp5.so) in LD_LIBRARY_PATH during your C# application run? Alternatively, you may use rpath in order to let libfftt.so know where libmkldft.so is located.
If libmkldft.so and libiomp5.so are in the LD_LIBRARY_PATH, could you please try to run the application under ld debug mode so that we can figure out what goes wrong:
$ LD_DEBUG=libs ./a.out # or LD_DEBUG=all for more verbose output
// caution: a lot of output possible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, Evarist,
Thank you for LD_DEBUG advice, it is very helpful tool to analyze. Now the problem is solved. The reason was in wrong libiomp5 and lstdc++ linking
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
By the way, I found that in my test program there is no benefit from OpenMP parallelization, because the call of native function from C# takes a lot of time in Mono.
To compare I created 2 test programs:
The first calls once from c# the following native function:
for(int i=0;i<100;i++) { omp_set_num_threads(nThread); fft_handle=init_FFT2D_descriptor(); DftiComputeForward(fft_handle,x); DftiFreeDescriptor(&fft_handle); }
The second calls 100 times from c# the following native function:
omp_set_num_threads(nThread); fft_handle=init_FFT2D_descriptor(); DftiComputeForward(fft_handle,x); DftiFreeDescriptor(&fft_handle);
In the first case the global program execution time depends on nThread
In the second case doesn't depend.
Am I right, that the reason is in Mono call time of native functions?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page