<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60345>60345</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[OpenMP] [Offload] [AMDGPU] Initialization Error with Shared Memory
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZwFink
</td>
</tr>
</table>
<pre>
Compilation targeting amdgcn for the below program fails with the following error:
```
clang-linker-wrapper: error: <unknown>:0: local_a: unsupported initializer for address space
clang-linker-wrapper: error: Errors encountered inside the LTO pipeline.
```
```c++
#include <iostream>
#include <omp.h>
#include <stdlib.h>
int main()
{
int N =1<<30;
int *a = new int[N];
#pragma omp target data map(tofrom:a[:N])
{
#pragma omp target teams distribute parallel for
for(int i = 0; i < N; i++)
{
int local_a[10];
#pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
for(int j = 0; j < 10; j++)
local_a[j] = a[(i+j)%N];
a[i] = local_a[0];
}
}
std::cout << a[0] << "\n";
```
ROCM 5.4.2 is used, and the above program was built on Clang/LLVM commit 054931dbf11687cb95576690d8f74ffd9b0da007 with:
```
clang++ -fopenmp -fopenmp-targets=amdgcn -Xopenmp-target -march=gfx90a ./program.cpp
```
Clang/LLVM was configured via the following:
```
cmake \
-DCMAKE_INSTALL_PREFIX=$prefix \
-DLLVM_CCACHE_BUILD='Off'\
-DCMAKE_EXPORT_COMPILE_COMMANDS='On'\
-DCMAKE_BUILD_TYPE='RelWithDebInfo' \
-DLLVM_FORCE_ENABLE_STATS='On' \
-DLLVM_ENABLE_PROJECTS='clang' \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_ENABLE_RUNTIMES='openmp' \
-DLLVM_OPTIMIZED_TABLEGEN='On' \
-DCLANG_BUILD_EXAMPLES='On' \
-DBUILD_SHARED_LIBS='On' \
-DLLVM_ENABLE_ASSERTIONS='On' \
../llvm
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVl-T4i4W_TT4QmlFMEYffIhJnHHXf2U7u73zkiIJUboJpICMM_vpfwWJ_6btqUmlDHDvgXMulytEa3YUlM6APwd-3CONOUk1-35eMPHey2TxaxbJqmacGCYFNEQdqWHiCElVHHMBS6mgOVGYUS7PsFbyqEgFS8K4hmdmTs5YSs7l2aKoUlIBHEIIvBh4IRh73eu6OSfi2OdMvFPVPytS19R5X2EAR414F_IsAE4ADj07yGVOeEpssxG6qWupDC0gE8wwwtn_qXI0SVEoqjXUNclpt_zfrZrYhoZU5LIRhio3uWYFdepWhy2sWU05E3TwVNZvgzlAc_u2owgzkfOmoFYck9ooSiqr7olZVvXg9IlNm4Kz7N5898uEgRVhAqAJQNPOElwoeFNr30CA4yHAEcAR9gB-tAIUEusABT1DJgzw5xvgxzc3hGtFjhWBsqq7PIEFMQRWpAZoYmSpZAVwSGym4dCBr1S86ZUNvD1P5zSUVBoWTBvFssZQWBNFOKfcbvKHKdwgmlgFzNG3wlwzghvX7DbjQuUeex8hq_maaf586N2Lh4_PI2_CLcxQgCYXPJpeRh07WdVpbXWlFa1SZ7kPzUcpbzcpb07KsG3_psWGtYXfiL8BP3Zotw9oYvW_WQTyH_fztq71ZBfYbabHCIAgvtvLrq1NAXAIcJjLxsA2teAFe-kDhIAfCfu5Lv7s_Oy30Rr6g9EAQaZho2kBUASJKNwpJJn8Qa8F6Ew0zBrGDZQCRvZ8A7RYrf6zhrmsKmag54-meFhk5XA4ngR5NvX9YDyeesWkDEZlWUwzryCeF7giZjV8Wq7amMN-KWsqqvra6Lf5qgGOu1rZf32wwH5FVH4COD6WP6cegQOAFp2AQV7XfwjFgyKrNZeiZMfGVqYfjDwW3c_YQ5hX5J1C4Ee3LO7H0Tr8d5IuNy-HcLVKd_tksXwFOAZoVCtasp93_v3YEkijKIy-Jun823IVO89gW5YABfeO7azJ6267P6TRdr1brhL7XYeb-KUD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