<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - OpenMP doacross loop nest with a decreasing induction variable abends"
   href="https://bugs.llvm.org/show_bug.cgi?id=45132">45132</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP doacross loop nest with a decreasing induction variable abends
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>t-kawashima@fujitsu.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23210" name="attach_23210" title="doacross.1.c in OpenMP 4.5 exmaples with reverse-order modification">attachment 23210</a> <a href="attachment.cgi?id=23210&action=edit" title="doacross.1.c in OpenMP 4.5 exmaples with reverse-order modification">[details]</a></span>
doacross.1.c in OpenMP 4.5 exmaples with reverse-order modification

[Envinronment]
OS: Linux
CPU: x86_64 and AArch64
LLVM/Clang/OpenMP: latest master branch (commit cfff4851acc)

The attached program `doacross.reverse.c` is a modified version of
`doacross.1.c` in the official 'OpenMP Examples Version 4.5.0' (page 194)
<<a href="https://github.com/OpenMP/Examples/blob/v4.5.0/sources/Example_doacross.1.c">https://github.com/OpenMP/Examples/blob/v4.5.0/sources/Example_doacross.1.c</a>>.

The modified points are:

- decrease the induction variable `i` (see the diff below)
- change `depend(sink: i+1)` to depend(sink: i-1) (see the diff below)
- implement `foo`, `bar`, `baz`, and `main`

--------------------------------
   #pragma omp for ordered(1)
-  for (i=N-1; i>1; i--)
+  for (i=1; i<N; i++)
   {
     A[i] = foo(i);

-    #pragma omp ordered depend(sink: i+1)
+    #pragma omp ordered depend(sink: i-1)
     B[i] = bar(A[i], B[i-1]);
     #pragma omp ordered depend(source)

     C[i] = baz(B[i]);
   }
--------------------------------

When this program is compiled with -fopenmp and executed, a segmentation fault
occurs.

--------------------------------
$ clang -fopenmp doacross.reverse.c
$ ./a.out
Segmentation fault
--------------------------------

The number of threads is irrelevant. I can reproduce it with OMP_NUM_THREADS=2.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>