-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Description
Test case from aomp smoke (teams_nest.c) reproduced inline,
#include <stdio.h>
#include <omp.h>
int main(void) {
int fail = 0;
//
// Test: num_teams and omp_get_team_num()
#pragma omp target
{
printf("Num_teams=%d\n", omp_get_num_teams());
}
#pragma omp target
{
#pragma omp teams
{
if (omp_get_team_num() == 0)
printf("Num_teams=%d\n", omp_get_num_teams());
#pragma omp distribute
for (int i=0; i< 10; i++)
printf("team %d thread %d\n", omp_get_team_num(), omp_get_thread_num());
}
}
return fail;
}
Compile with
clang -O2 -fopenmp --offload-arch=gfx1010 teams_nest.c -o teams_nest -mllvm -openmp-opt-disable=true
Fails with
LLVM ERROR: Absolute address LDS variable inconsistent with variable alignment
Save temps suggests LDS variables have had addresses allocated before codegen. I guess that's related to the thin-lto work, though I thought that was only in rocm and this is reproducing in trunk.
The LDS lowering makes a very definite "allocating whole code object at a time" assumption which means it's not safe to run repeatedly. The thinlto work was supposed to run it on pieces and then recombine them without running the pass a second time, but it looks like the pass is running a second time and decides to increase the alignment of some already allocated variables, i.e. miscompile them.
This specific error can probably be fixed by not over-aligning any already allocated variables, but it seems the writing is on the wall for the closed world assumption LDS lowering currently relies on.