<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 target: Mapping of partial arrays fails"
   href="https://bugs.llvm.org/show_bug.cgi?id=43330">43330</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP target: Mapping of partial arrays fails
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>Runtime Library
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Cramer@itc.rwth-aachen.de
          </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=22511" name="attach_22511" title="Reproducer of the bug">attachment 22511</a> <a href="attachment.cgi?id=22511&action=edit" title="Reproducer of the bug">[details]</a></span>
Reproducer of the bug

According to the OMP Specs (Chapter 2.1.5) an array section can have the
following format (beside others):

[ lower-bound : length : stride] or
[ lower-bound : ]

In the latter case the length and the stride are determined as follows (see
specs):

"When the stride is absent it defaults to 1.
When the length is absent it defaults to (size - lower-bound)/stride, where
size is the size of the array dimension."

Given a declaration "int a[N];" the following code should be semantically the
same:

(1) #pragma omp target data map(from: a[1:N-1])
(2) #pragma omp target data map(from: a[1:])

However, if I test this with "-fopenmp-targets=x86_64-unknown-linux-gnu" I get
the following debug output from libomptarget (LIBOMPTARGEG_DEBUG=1) for both
cases (and N=1000):

(1) Libomptarget --> Moving 3996 bytes (tgt:0x0000000000623dc0) ->
(hst:0x00007ffe65c4d474)
(2) Libomptarget --> Moving 4000 bytes (tgt:0x0000000000623dc0) ->
(hst:0x00007fff2d5a45f4)

Thus, in case (2) there are too many bytes transfered. This has bad side
effects, because some stack variables on the host may be overwritten (which
actually happens to me).

I attached a reproducer. Can you confirm this bug (or even better fix it ;-)).
I am not sure if this is an issue of the compiler or the runtime.</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>