<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 - 'Incomplete type' error when mapping a global extern std::array"
href="https://bugs.llvm.org/show_bug.cgi?id=50508">50508</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>'Incomplete type' error when mapping a global extern std::array
</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>jtramm@anl.gov
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>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 (<a href="https://github.com/llvm/llvm-project.git">https://github.com/llvm/llvm-project.git</a>
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:
<a href="https://github.com/jtramm/omp_target_issues/blob/master/array_simple/transfer.cpp">https://github.com/jtramm/omp_target_issues/blob/master/array_simple/transfer.cpp</a>
and a larger version with a main can be found at:
<a href="https://github.com/jtramm/omp_target_issues/tree/master/array">https://github.com/jtramm/omp_target_issues/tree/master/array</a></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>