<?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 Nice answer. This got the in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096210#M67022</link>
    <description>&lt;P&gt;Nice answer. This got the example code and my code working. You're the best!&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2016 18:46:20 GMT</pubDate>
    <dc:creator>Christopher_R_3</dc:creator>
    <dc:date>2016-03-03T18:46:20Z</dc:date>
    <item>
      <title>Compiling a Shared Library with Offload Pragmas</title>
      <link>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096208#M67020</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;

&lt;P&gt;&amp;nbsp; I am having difficulties trying to compile simple programs with offload pragmas. I am testing out the tutorial found here&amp;nbsp;http://www.drdobbs.com/parallel/programming-intels-xeon-phi-a-jumpstart/240144160?pgno=3 and if I change the compilation command for matrix.off to have -openmp (somehow he forgot it), -shared, and -fPIC I get segmentation faults. Note that if those are not in the compilation command (other than adding -openmp) everything works as it should. I cannot find any examples of people using offload pragmas in shared libraries to find out what else I need to try. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 05:58:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096208#M67020</guid>
      <dc:creator>Christopher_R_3</dc:creator>
      <dc:date>2016-03-03T05:58:40Z</dc:date>
    </item>
    <item>
      <title>There is some information in</title>
      <link>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096209#M67021</link>
      <description>&lt;P&gt;There is some information in the C++ User’s Guide under &lt;A href="https://software.intel.com/en-us/node/522512" target="_blank"&gt;&lt;STRONG&gt;Using Libraries With Offloaded Code&lt;/STRONG&gt;&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;The &lt;STRONG&gt;-offload-build&lt;/STRONG&gt; option is obsolete. The compiler will auto-detect offload language extensions and perform the necessary host and target compilations to enable offload. You can use the replacement (16.0 compiler) option, &lt;STRONG&gt;-qoffload&lt;/STRONG&gt;, if you wish but that is the default. Only the shared library needs to be compiled for offload also.&lt;/P&gt;

&lt;P&gt;For this example, split the source into two source files (e.g. matrix.c and main.c). This enables building matrix.c into a shared library with offload enabled. Then compile the files as shown below. I updated the compiler options to use for our latest 16.0 release. (&lt;STRONG&gt;-vec-report3&lt;/STRONG&gt; is deprecated so replace with: &lt;STRONG&gt;-qopt-report -qopt-report-phase=vec&lt;/STRONG&gt;). I&amp;nbsp;used the default&amp;nbsp;(&lt;STRONG&gt;-qoffload&lt;/STRONG&gt;) for matrix.c. The &lt;STRONG&gt;-diag-disable 10397&lt;/STRONG&gt; silences some remarks.&lt;/P&gt;

&lt;P&gt;icc -mkl -O3 -openmp -fpic -diag-disable 10397 -Wno-unknown-pragmas -std=c99 -qopt-report -qopt-report-phase=vec -shared matrix.c -o libmatrix.so&lt;BR /&gt;
	icc -mkl -O3 -openmp -diag-disable 10397 -Wno-unknown-pragmas -std=c99 -qopt-report -qopt-report-phase=vec main.c -o matrix.shr -L. -lmatrix&lt;/P&gt;

&lt;P&gt;When you run, make certain the appropriate path to the matrix shared library is present in both your &lt;STRONG&gt;LD_LIBRARY_PATH &lt;/STRONG&gt;and &lt;STRONG&gt;MIC_LD_LIBRARY_PATH &lt;/STRONG&gt;variables.&amp;nbsp;In my case, I used the current directory (e.g. export MIC_LD_LIBRARY_PATH=$MIC_LD_LIBRARY_PATH:.).&lt;/P&gt;

&lt;P&gt;The code should run. Here's an example.&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;$ icc -V
Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.1.150 Build 20151021

$ icc -mkl -O3 -openmp -fpic -diag-disable 10397 -Wno-unknown-pragmas -std=c99 -qopt-report -qopt-report-phase=vec -shared matrix.c -o libmatrix.so

$ icc -mkl -O3 -openmp -diag-disable 10397 -Wno-unknown-pragmas -std=c99 -qopt-report -qopt-report-phase=vec main.c -o matrix.shr -L. -lmatrix

$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
$ export MIC_LD_LIBRARY_PATH=$MIC_LD_LIBRARY_PATH:.

$ ./matrix.shr 100 24 2
./matrix.shr nThreads 24 matrix 100 100 runtime 0.0102108 GFlop/s 0.195871 mklGflop 61.9979 NRMSD_error -nan
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 09:41:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096209#M67021</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2016-03-03T09:41:36Z</dc:date>
    </item>
    <item>
      <title>Nice answer. This got the</title>
      <link>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096210#M67022</link>
      <description>&lt;P&gt;Nice answer. This got the example code and my code working. You're the best!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2016 18:46:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096210#M67022</guid>
      <dc:creator>Christopher_R_3</dc:creator>
      <dc:date>2016-03-03T18:46:20Z</dc:date>
    </item>
    <item>
      <title>Thank you for the kind words.</title>
      <link>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096211#M67023</link>
      <description>&lt;P&gt;Thank you for the kind words. Glad to hear that helped.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2016 10:08:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Compiling-a-Shared-Library-with-Offload-Pragmas/m-p/1096211#M67023</guid>
      <dc:creator>Kevin_D_Intel</dc:creator>
      <dc:date>2016-03-04T10:08:58Z</dc:date>
    </item>
  </channel>
</rss>

