<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 4.5: Target construct in methods of class fail to map an array tofrom"
   href="https://bugs.llvm.org/show_bug.cgi?id=34013">34013</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>OpenMP 4.5: Target construct in methods of class fail to map an array tofrom
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </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>sergiop@udel.edu
          </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=18884" name="attach_18884" title="reproducible of issue">attachment 18884</a> <a href="attachment.cgi?id=18884&action=edit" title="reproducible of issue">[details]</a></span>
reproducible of issue

Dear LLVM OpenMP 4.5 support.

I'm trying to use a target construct inside the methods of a class to compute
something in an array. But, it seems that once the target construct finishes
the data of the array is not copied back from to device to the host. 

Basically, what I expect after calling the modify method on an object of A is
that the h_array will be full of 1s, but it is not working.


class A {
...
  void modify(int* isHost) {                                                    
#pragma omp target map(tofrom:this->h_array) map(this->size) map(tofrom:
isHost)                                    
    {                                                                           
      *isHost = omp_is_initial_device();                                        
      for (int i = 0; i < size; ++i)                                            
        h_array[i] = 1;                                                         
    }                                                                           
  }
};

I'm attaching a reproducible for the error.

# Compile
To compile: clang++ -fopenmp -fopenmp-targets=nvptx64-nvida-cuda repro1.cpp

# MACHINE
I tested this in a 64 bit system. 
- clang version 3.8.0 (ibmgithub:/CORAL-LLVM-Compilers/clang.git
6dec6f47d3868e3c8bf6e9e19a217cb2b459d3d8)
(ibmgithub:/CORAL-LLVM-Compilers/llvm.git
b1d578319dbe65eb1e654c6b4e3d05dfcaa087a6)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
- Red Hat Enterprise Linux Server 7.3 - CentOS release 7
- POWER8NVL ppc64le
- NVIDIA Tesla P100 GPU</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>