<?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 May I use multiple MIC to optimize one loop? in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/May-I-use-multiple-MIC-to-optimize-one-loop/m-p/1027774#M40808</link>
    <description>&lt;P&gt;I have heard an approach such as :&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#progma parallel for private(i,j)
for (int i=0;i&amp;lt;100;++i)
{
#progma offload target(mic:i)
#progma parallel for private(j)
for (int j=0;j&amp;lt;100;++j)
...
}&lt;/PRE&gt;

&lt;P&gt;but in case of one loop, I can only write out such silly code :&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#progma parallel for private(i,j)
for (int i=0;i&amp;lt;3;++i) // Well, I have 3 mic cards
{
#progma offload target(mic:i)
#progma parallel for private(j)
for (int j=(n/3)*i;j&amp;lt;(n/3)*(i+1);++j) // n is total job count.
..... // do the job from (n/3)*i to (n/3)*(i+1)-1
}&lt;/PRE&gt;

&lt;P&gt;It's not only ugly but also silly. But I can't find out the&amp;nbsp;elegant method. =...=&lt;/P&gt;</description>
    <pubDate>Thu, 21 Aug 2014 08:53:33 GMT</pubDate>
    <dc:creator>Xero_E_</dc:creator>
    <dc:date>2014-08-21T08:53:33Z</dc:date>
    <item>
      <title>May I use multiple MIC to optimize one loop?</title>
      <link>https://community.intel.com/t5/Software-Archive/May-I-use-multiple-MIC-to-optimize-one-loop/m-p/1027774#M40808</link>
      <description>&lt;P&gt;I have heard an approach such as :&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#progma parallel for private(i,j)
for (int i=0;i&amp;lt;100;++i)
{
#progma offload target(mic:i)
#progma parallel for private(j)
for (int j=0;j&amp;lt;100;++j)
...
}&lt;/PRE&gt;

&lt;P&gt;but in case of one loop, I can only write out such silly code :&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#progma parallel for private(i,j)
for (int i=0;i&amp;lt;3;++i) // Well, I have 3 mic cards
{
#progma offload target(mic:i)
#progma parallel for private(j)
for (int j=(n/3)*i;j&amp;lt;(n/3)*(i+1);++j) // n is total job count.
..... // do the job from (n/3)*i to (n/3)*(i+1)-1
}&lt;/PRE&gt;

&lt;P&gt;It's not only ugly but also silly. But I can't find out the&amp;nbsp;elegant method. =...=&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2014 08:53:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/May-I-use-multiple-MIC-to-optimize-one-loop/m-p/1027774#M40808</guid>
      <dc:creator>Xero_E_</dc:creator>
      <dc:date>2014-08-21T08:53:33Z</dc:date>
    </item>
    <item>
      <title>Hi Xero,</title>
      <link>https://community.intel.com/t5/Software-Archive/May-I-use-multiple-MIC-to-optimize-one-loop/m-p/1027775#M40809</link>
      <description>&lt;P&gt;Hi Xero,&lt;/P&gt;

&lt;P&gt;I tried something simple for offloading to three coprocessors:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;omp_set_num_threads(128); // The maximum number of host threads doing offload

#pragma omp parrallel for private (j)
for j=0; j&amp;lt;n; j++)
{
#pragma offload target(mic:j)
// do the job for each chunk j
}
&lt;/PRE&gt;

&lt;P&gt;Also, you can use MPI to divide the total work among three coprocessors, each coprocessor uses OpenMP to&amp;nbsp;run its shared workload in&amp;nbsp;parallel.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2014 22:52:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/May-I-use-multiple-MIC-to-optimize-one-loop/m-p/1027775#M40809</guid>
      <dc:creator>Loc_N_Intel</dc:creator>
      <dc:date>2014-08-22T22:52:52Z</dc:date>
    </item>
  </channel>
</rss>

