<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 - target amdgcn-amd-amdhsa: accessing struct member array >64bytes yields [GPU Memory Error]"
href="https://bugs.llvm.org/show_bug.cgi?id=50968">50968</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>target amdgcn-amd-amdhsa: accessing struct member array >64bytes yields [GPU Memory Error]
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</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>OpenMP
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gcc.j.kelling@hzdr.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Compiling the following code:
```c++
#include <iostream>
template<int N>
struct A
{
char arr[N];
int b = 0;
A()
{
arr[0] = 0;
}
};
template<int N>
void f()
{
int b = 0;
#pragma omp target map(tofrom: b)
{
#pragma omp teams distribute
for(int i = 0; i < 1; ++i)
{
A<N> a;
b = a.arr[0]; // (1) only this fails
b = a.b += sizeof(a); // (2)
}
}
std::cout << b << std::endl;
}
int main()
{
//OK:
f<64>();
//[GPU Memory Error] Addr: 0x0 Reason: Page not present or supervisor
privilege.:
f<65>();
}
```
with
clang++ -fopenmp -fopenmp=libomp -fopenmp-targets=amdgcn-amd-amdhsa
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx900 memberArray.cpp
and running on Vega 10, yields:
```
[GPU Memory Error] Addr: 0x0 Reason: Page not present or supervisor privilege.
Memory access fault by GPU node-6 (Agent handle: 0xbd2010) on address (nil).
Reason: Page not present or supervisor privilege.
Aborted (core dumped)
```
Note, that this happens only when the array access in line (1) is present, the
access to the other member in line (2) does not cause a memory error and the
value returned by `sizeof(a)` is as expected. Also, this happens if the member
array is larger than 64 bytes (any type, e.g. int[16] works, int[17] does not).
Expected behavior: No size restriction on (fixed-size) member arrays.
Rationale: We require a small-object allocator in block
shared(NVIDIA)/local(AMD) memory on GPU, for which we require a type with a
member array filling up most of the available shared memory (>~30kB).</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>