title: Task Dependency in OpenMP 4
body: <p>The following code works based on the OpenMP 4.0 specification:</p>
  
  <blockquote>
    <p>The out and <strong><em>inout</em></strong> dependence-types. The generated task will be a
    dependent task of all previously generated sibling tasks that
    reference at least one of the list items in an in, out, or inout
    dependence-type list.</p>
  </blockquote>
  
  <p>This means that task3 becomes dependent of task2. Right? but it does not make sense! Why should an input-output dependency task be a dependent of an input dependency task? </p>
  
  <p>What do I need to do in order to make them independent?
  p.s: code tested with g++ 4.9 on Linux.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;omp.h&gt;
  #include &lt;unistd.h&gt;
  int main() {
  int x,y;
  #pragma omp parallel num_threads(10)
  {
  #pragma omp single nowait
   {
  #pragma omp task depend (out:x)  //task1
    {
          x=1;
    }
  #pragma omp task depend(in:x) depend(out:y)  //task2
    {
          sleep(2); //Does task3 wait for us? Yes!
          y=x+1;
    }
  #pragma omp task depend (inout:x)  //task3
    {
          x++;
          printf("task3(x): %d\n" , x);
    }
  #pragma omp task depend (in:x,y)  //task4
   {
          printf("task4 (x+y): %d\n" , x+y);
   }
   }
  }
  return 0;
  }
  </code></pre>