<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 - declare target pointer cannot be accessed in target region"
   href="https://bugs.llvm.org/show_bug.cgi?id=46012">46012</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>declare target pointer cannot be accessed in target region
          </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>enhancement
          </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>xw111luoye@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In the following example, a pointer in declare target doesn't get the mapped
address. IBM XL works.

Clang run output:
arr omp_target_is_present 0
arr initial device address (nil)
arr host address 0x13e2f20
arr omp_target_is_present 1
arr device address inside map 0x7f9536800000
device address 0 (nil)
device address 1 (nil)
device address 2 (nil)
arr omp_target_is_present 0
arr final device address (nil)

#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

#pragma omp declare target
int * arr;

void foo(int i)
{
  printf("devuce address %d %p\n", i, arr);
}
#pragma omp end declare target

int main(void)
{
  // Allocate array and set to zero
  int len = 3;
  arr = (int *) calloc( len, sizeof(int) );

  printf("arr omp_target_is_present %d\n", omp_target_is_present(arr, 0));
  #pragma omp target data use_device_ptr(arr)
  {
    printf("arr initial device address %p\n", arr);
  }

  #pragma omp target data map(tofrom: arr[:len])
  {
    printf("arr host address %p\n", arr);
    printf("arr omp_target_is_present %d\n", omp_target_is_present(arr, 0));
    #pragma omp target data use_device_ptr(arr)
    {
      printf("arr device address inside map %p\n", arr);
    }

    #pragma omp target teams distribute parallel for
    for( int i = 0; i < len; i++)
      foo(i);
  }

  printf("arr omp_target_is_present %d\n", omp_target_is_present(arr, 0));
  #pragma omp target data use_device_ptr(arr)
  {
    printf("arr final device address %p\n", arr);
  }

  return 0;
}</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>