title: Nested Directives in OpenACC
body: <p>I'm trying to use nested feature of OpenACC to active dynamic parallelism of my gpu card. I've Tesla 40c and my OpenACC compiler is PGI version 15.7.</p>
  
  <p>My code is so simple. When I try to compile following code compiler returns me  these messages </p>
  
  <pre><code>PGCC-S-0155-Illegal context for pragma: acc  parallel loop (test.cpp: 158)
  PGCC/x86 Linux 15.7-0: compilation completed with severe errors
  </code></pre>
  
  <p>My code structure:</p>
  
  <pre><code>#pragma acc parallel loop
  for( i = 0; i &lt; N; i++ )
  {
    // &lt;&lt; computation &gt;&gt;
  
    int ss = A[tid].start;
    int ee = A[tid].end;
  
    #pragma acc parallel loop
    for(j = ss; j&lt; ( ee + ss); j++)
    {
      // &lt;&lt; computation &gt;&gt;
    }
  </code></pre>
  
  <p>I've also tried to change my code to use routine directives. But I couldn't compile again</p>
  
  <pre><code>#pragma acc routine workers
  foo(...)
  {
  
    #pragma acc parallel loop
    for(j = ss; j&lt; ( ee + ss); j++)
    {
      // &lt;&lt; computation &gt;&gt;
    }
  }
  
  #pragma acc parallel loop
  for( i = 0; i &lt; N; i++ )
  {
    // &lt;&lt; computation &gt;&gt;
  
    int ss = A[tid].start;
    int ee = A[tid].end;
  
    foo(...);
  
  }
  </code></pre>
  
  <p>I've tried of course only with <strong>routine (seq,worker,gang)</strong> without inner <strong>parallel loop</strong> directive. It has been compiler but dynamic parallelism hasn't been activated.</p>
  
  <pre><code>    37, Generating acc routine worker
           Generating Tesla code
           42, #pragma acc loop vector, worker /* threadIdx.x threadIdx.y */
           Loop is parallelizable
  </code></pre>
  
  <p>How am I supposed to use dynamic parallelism in OpenACC?</p>