<?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 problem with nested openmp parallel  in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910917#M4603</link>
    <description>I have an issue to have the code running using more than 2 cores when having a top level 2 parallel sections and a next level 2 parallel sections. The suedo code is provided below. I am expecting to see that the code should be finished 4 times faster on a 8 core(2 quad-core) machine. However, I got twice the speed comparing to no parallelization. There were no difference if I set the OMP_NUM_THREADS to 2 or 4 or 8. However, the number of threads showing up in the task manager did have a difference. I am using intel C++ compiler 11.0 (and 9.1 too). Could anybody suggest what I am missing?
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks.&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;void compute()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt; // heavy computations&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;void func()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt; #pragma omp parallel&lt;/DIV&gt;
&lt;DIV&gt; {&lt;/DIV&gt;
&lt;DIV&gt;  #pragma omp sections&lt;/DIV&gt;
&lt;DIV&gt;  {&lt;/DIV&gt;
&lt;DIV&gt;    #pragma omp section&lt;/DIV&gt;
&lt;DIV&gt;       compute();&lt;/DIV&gt;
&lt;DIV&gt;    #pragma omp section&lt;/DIV&gt;
&lt;DIV&gt;       compute();&lt;/DIV&gt;
&lt;DIV&gt;   }&lt;/DIV&gt;
&lt;DIV&gt; }&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;int main()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt;#pragma omp parallel &lt;BR /&gt;{&lt;BR /&gt; #pragma omp sections &lt;BR /&gt; {&lt;BR /&gt;  #pragma omp section&lt;BR /&gt;   func();&lt;BR /&gt;  #pragma omp section&lt;BR /&gt;   func();&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 30 Apr 2009 21:00:09 GMT</pubDate>
    <dc:creator>swi</dc:creator>
    <dc:date>2009-04-30T21:00:09Z</dc:date>
    <item>
      <title>problem with nested openmp parallel</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910917#M4603</link>
      <description>I have an issue to have the code running using more than 2 cores when having a top level 2 parallel sections and a next level 2 parallel sections. The suedo code is provided below. I am expecting to see that the code should be finished 4 times faster on a 8 core(2 quad-core) machine. However, I got twice the speed comparing to no parallelization. There were no difference if I set the OMP_NUM_THREADS to 2 or 4 or 8. However, the number of threads showing up in the task manager did have a difference. I am using intel C++ compiler 11.0 (and 9.1 too). Could anybody suggest what I am missing?
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Thanks.&lt;BR /&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;void compute()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt; // heavy computations&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;void func()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt; #pragma omp parallel&lt;/DIV&gt;
&lt;DIV&gt; {&lt;/DIV&gt;
&lt;DIV&gt;  #pragma omp sections&lt;/DIV&gt;
&lt;DIV&gt;  {&lt;/DIV&gt;
&lt;DIV&gt;    #pragma omp section&lt;/DIV&gt;
&lt;DIV&gt;       compute();&lt;/DIV&gt;
&lt;DIV&gt;    #pragma omp section&lt;/DIV&gt;
&lt;DIV&gt;       compute();&lt;/DIV&gt;
&lt;DIV&gt;   }&lt;/DIV&gt;
&lt;DIV&gt; }&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;int main()&lt;/DIV&gt;
&lt;DIV&gt;{&lt;/DIV&gt;
&lt;DIV&gt;#pragma omp parallel &lt;BR /&gt;{&lt;BR /&gt; #pragma omp sections &lt;BR /&gt; {&lt;BR /&gt;  #pragma omp section&lt;BR /&gt;   func();&lt;BR /&gt;  #pragma omp section&lt;BR /&gt;   func();&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;}&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 30 Apr 2009 21:00:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910917#M4603</guid>
      <dc:creator>swi</dc:creator>
      <dc:date>2009-04-30T21:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: problem with nested openmp parallel</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910918#M4604</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;
&lt;PRE&gt;[cpp]void compute()
{
    // heavy computations
}
void func()
{
   // in order for this to initiate
   // a parallel region nested must be enabled
   // SET OMP_NESTED=TRUE
   // .or.
   // omp_set_nested(1);
   //
   // when nested disabled, this runs serial
   // for each of the 2 threads calling func
   //  4 x compute() using 2 threads.
   // when nested enabled (read comments inside block)
   // 
   #pragma omp parallel 
   {
      // each of 2 threads calling func() picks up
      // additional threads here
      // 7 or less depending on options 
      #pragma omp sections 
      {
          // however you only have 2 sections
          #pragma omp section
               compute();	// 1 thread of each team
          #pragma omp section
               compute();       // different 1 thread of each team
       }
   }
}

// end result 4 x compute() using 4 threads (when nested enabled)
// 

int main()
{
  #pragma omp parallel 
  {
    // 8 threads falling through this comment
    // (assuming OMP_NUM_THREADS 8)

    #pragma omp sections 
    {
     #pragma omp section
        func();	// one of the 8 threads makes this call
     #pragma omp section
        func(); // different one the 8 threads makes this call
     }
     // the other 6 threads branch around to here
  }

}
[/cpp]&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Thu, 30 Apr 2009 21:37:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910918#M4604</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2009-04-30T21:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: problem with nested openmp parallel</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910919#M4605</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Thanks a lot! This solves the problem.&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/99850"&gt;jimdempseyatthecove&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt; &lt;BR /&gt;
&lt;/EM&gt;&lt;PRE&gt;&lt;EM&gt;[cpp]void compute()
{
    // heavy computations
}
void func()
{
   // in order for this to initiate
   // a parallel region nested must be enabled
   // SET OMP_NESTED=TRUE
   // .or.
   // omp_set_nested(1);
   //
   // when nested disabled, this runs serial
   // for each of the 2 threads calling func
   //  4 x compute() using 2 threads.
   // when nested enabled (read comments inside block)
   // 
   #pragma omp parallel 
   {
      // each of 2 threads calling func() picks up
      // additional threads here
      // 7 or less depending on options 
      #pragma omp sections 
      {
          // however you only have 2 sections
          #pragma omp section
               compute();	// 1 thread of each team
          #pragma omp section
               compute();       // different 1 thread of each team
       }
   }
}

// end result 4 x compute() using 4 threads (when nested enabled)
// 

int main()
{
  #pragma omp parallel 
  {
    // 8 threads falling through this comment
    // (assuming OMP_NUM_THREADS 8)

    #pragma omp sections 
    {
     #pragma omp section
        func();	// one of the 8 threads makes this call
     #pragma omp section
        func(); // different one the 8 threads makes this call
     }
     // the other 6 threads branch around to here
  }

}
[/cpp]&lt;/EM&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Apr 2009 22:31:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/problem-with-nested-openmp-parallel/m-p/910919#M4605</guid>
      <dc:creator>swi</dc:creator>
      <dc:date>2009-04-30T22:31:20Z</dc:date>
    </item>
  </channel>
</rss>

