[llvm-bugs] [Bug 50508] New: 'Incomplete type' error when mapping a global extern std::array

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 27 08:38:06 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50508

            Bug ID: 50508
           Summary: 'Incomplete type' error when mapping a global extern
                    std::array
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Runtime Library
          Assignee: unassignedbugs at nondot.org
          Reporter: jtramm at anl.gov
                CC: llvm-bugs at lists.llvm.org

An error occurs when compiling the following file (transfer.cpp) that attempts
to map a global scope std::array object declared as extern:

#include<array>
#pragma omp declare target
extern std::array<double, 4> arr;
#pragma omp end declare target
void copy_host_to_device()
{
  #pragma omp target update to(arr)
}
void copy_device_to_host()
{
  #pragma omp target update from(arr)
}

Compiled with clang++ (version 13.0.0 (https://github.com/llvm/llvm-project.git
59d938e649e62db0cef4903d495e838fbc6a6eb8) for a V100 target as:

clang++ -Wall -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target
-march=sm_70 -c transfer.cpp -o transfer.o

The error given is:

transfer.cpp:9:32: error: incomplete type 'std::array<double, 4>' where a
complete type is required
  #pragma omp target update to(arr)
                               ^~~
transfer.cpp:9:3: error: expected at least one 'to' clause or 'from' clause
specified to '#pragma omp target update'
  #pragma omp target update to(arr)
  ^
transfer.cpp:14:34: error: incomplete type 'std::array<double, 4>' where a
complete type is required
  #pragma omp target update from(arr)
                                 ^~~
transfer.cpp:14:3: error: expected at least one 'to' clause or 'from' clause
specified to '#pragma omp target update'
  #pragma omp target update from(arr)
  ^
4 errors generated.

As a workaround (found by Johannes Doerfert), it works if the array is
instantiated in the first function as:

void copy_host_to_device()
{
  arr[0];
  #pragma omp target update to(arr)
}

The code for this reproducer is available at:

https://github.com/jtramm/omp_target_issues/blob/master/array_simple/transfer.cpp

and a larger version with a main can be found at:

https://github.com/jtramm/omp_target_issues/tree/master/array

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210527/cb5a35fb/attachment.html>


More information about the llvm-bugs mailing list