<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hello, Evarist, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098333#M23685</link>
    <description>&lt;P style="font-size: 13.008px;"&gt;Hello, Evarist,&lt;/P&gt;

&lt;P style="font-size: 13.008px;"&gt;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&lt;/P&gt;</description>
    <pubDate>Tue, 29 Nov 2016 09:22:02 GMT</pubDate>
    <dc:creator>Grigorii_F_</dc:creator>
    <dc:date>2016-11-29T09:22:02Z</dc:date>
    <item>
      <title>How to create shared .so library which use MKL?</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098331#M23683</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;When I run test example C program (not shared library) MKL works fine,&lt;/P&gt;

&lt;P&gt;But if I pack my functions to the .so file and call&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;it from C# (mono) through P/Invoke, then I got "DllNotFound" exeption. Without MKL my .so library works also fine.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;I supposed that I have to build shared MKL library with -fPIC flag.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;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"&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;then copied the libmkldft.so to /opt/intel/mkl/lib/intel64/ directory and build my test library by&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;ld -shared -soname libfftt.so -o libfftt.so -L /opt/intel/mkl/lib/intel64/ -lmkldft Fft.o&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;And finally I have "System.DllNotFoundExeption" at (wrapper managed-to-native)&amp;nbsp;&lt;/P&gt;

&lt;P&gt;If I comment MKL FFT functions in the libfftt.so then I don't have exeptions and all works fine&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;How to make my shared MKL library work?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 08:21:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098331#M23683</guid>
      <dc:creator>Grigorii_F_</dc:creator>
      <dc:date>2016-11-28T08:21:53Z</dc:date>
    </item>
    <item>
      <title>Hi Grigorii,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098332#M23684</link>
      <description>&lt;P&gt;Hi Grigorii,&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;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:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ LD_DEBUG=libs ./a.out # or LD_DEBUG=all for more verbose output&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;// caution: a lot of output possible.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2016 17:22:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098332#M23684</guid>
      <dc:creator>Evarist_F_Intel</dc:creator>
      <dc:date>2016-11-28T17:22:00Z</dc:date>
    </item>
    <item>
      <title>Hello, Evarist,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098333#M23685</link>
      <description>&lt;P style="font-size: 13.008px;"&gt;Hello, Evarist,&lt;/P&gt;

&lt;P style="font-size: 13.008px;"&gt;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&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 09:22:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098333#M23685</guid>
      <dc:creator>Grigorii_F_</dc:creator>
      <dc:date>2016-11-29T09:22:02Z</dc:date>
    </item>
    <item>
      <title>By the way, I found that in</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098334#M23686</link>
      <description>&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;To compare I created 2 test programs:&lt;/P&gt;

&lt;P&gt;The first calls once from c# the following native function:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;for(int i=0;i&amp;lt;100;i++)
{
&amp;nbsp;   omp_set_num_threads(nThread);
&amp;nbsp;   fft_handle=init_FFT2D_descriptor();
    DftiComputeForward(fft_handle,x);
    DftiFreeDescriptor(&amp;amp;fft_handle);
}&lt;/PRE&gt;

&lt;P&gt;The second&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;calls 100 times from c# the following native function:&lt;/SPAN&gt;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px;"&gt;    omp_set_num_threads(nThread);
    fft_handle=init_FFT2D_descriptor();
    DftiComputeForward(fft_handle,x);
    DftiFreeDescriptor(&amp;amp;fft_handle);&lt;/PRE&gt;

&lt;P&gt;In the first case the global program execution time depends on nThread&lt;/P&gt;

&lt;P&gt;In the second case doesn't depend.&lt;/P&gt;

&lt;P&gt;Am I right, that the reason is in Mono call time of native functions?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 09:36:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/How-to-create-shared-so-library-which-use-MKL/m-p/1098334#M23686</guid>
      <dc:creator>Grigorii_F_</dc:creator>
      <dc:date>2016-11-29T09:36:14Z</dc:date>
    </item>
  </channel>
</rss>

