OpenMP_VV
OpenMP_VV copied to clipboard
tests/5.0/target_update/test_target_update_mapper_from_discontiguous should use map clause for target region
The problem I'm seeing is a seg fault on the AMDGPU. I think it is happening because the target region is referencing a pointer (as if it's an array) without providing any mapping information.
Here's a small snippet from the test case to illustrate the issue:
#define N 32 typedef struct{ size_t len; double *data; } T;
int main() { T s; s.len = N; s.data = (double *)calloc(N,sizeof(double));
#pragma omp target for (int i = 0; i < s.len; i++) s.data[i] = i; <<<<< seg fault occurs here }
The reference to "s.data", a pointer, according to the latest spec (OpenMP spec TR12, pg. 6, L16-18) is supposed to be implicitly mapped like this:
"A variable that is of type pointer, but is neither a pointer to a function nor (for C++) a pointer to a member function, is treated as if it is the base expression of a zero-offset assumed-size array that appears in a map clause with the alloc map-type."
However, since there is no “size” to assume for this “array” (because it’s a pointer), an explicit "map(alloc:s.data[0:N])" is required on the target directive. When this is added, the target region executes without error and assigns the correct results to s.data.