'Incomplete type' error when mapping a global extern std::array
| Bugzilla Link | 50508 |
| Resolution | FIXED |
| Resolved on | Aug 06, 2021 05:36 |
| Version | unspecified |
| OS | Linux |
| CC | @alexey-bataev,@jdoerfert,@jyu2-git,@jtramm,@RaviNarayanaswamy |
Extended Description
An error occurs when compiling the following file (transfer.cpp) that attempts to map a global scope std::array object declared as extern:
#include
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
This is fix in https://reviews.llvm.org/D107200