mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 13:19:18 -08:00
Fix compiler lowering and runtime handling of non-contiguous `target update` operations so multidimensional Fortran sections transfer only the selected elements. Preserve physical source strides and scalar-subscript shape, normalize character bounds and strides, and retain descriptor storage for deferred `nowait` updates. In libomptarget, merge only consecutive innermost contiguous dimensions, skip empty updates before presence checks and transfers, and use 64-bit traversal counts. Add Flang/MLIR and C/C++/Fortran offload regression coverage for both transfer directions, multidimensional gaps, empty and `present` updates, wide characters, and `nowait`. Includes https://github.com/llvm/llvm-project/pull/235006. Fixes: - https://amd-hub.atlassian.net/browse/LCOMPILER-2880 - https://amd-hub.atlassian.net/browse/LCOMPILER-2784 Co-authored-by: Codex <codex@openai.com>
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
// RUN: %libomptarget-compile-run-and-check-generic
|
|
// UNSUPPORTED: apu
|
|
|
|
// A zero count in any dimension makes a strided update empty. Check both
|
|
// directions on mapped and unmapped storage, including the present modifier.
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
int data[4][6];
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 6; ++j)
|
|
data[i][j] = -1;
|
|
|
|
#pragma omp target data map(to : data)
|
|
{
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 6; ++j)
|
|
data[i][j] = 7;
|
|
#pragma omp target update to(present : data[0 : 0][0 : 3 : 2])
|
|
#pragma omp target update to(present : data[0 : 2 : 2][0 : 0])
|
|
#pragma omp target update from(data)
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 6; ++j)
|
|
assert(data[i][j] == -1);
|
|
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 6; ++j)
|
|
data[i][j] = 7;
|
|
#pragma omp target update from(present : data[0 : 0][0 : 3 : 2])
|
|
#pragma omp target update from(present : data[0 : 2 : 2][0 : 0])
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int j = 0; j < 6; ++j)
|
|
assert(data[i][j] == 7);
|
|
}
|
|
|
|
#pragma omp target update to(present : data[0 : 0][0 : 3 : 2])
|
|
#pragma omp target update to(present : data[0 : 2 : 2][0 : 0])
|
|
#pragma omp target update from(present : data[0 : 0][0 : 3 : 2])
|
|
#pragma omp target update from(present : data[0 : 2 : 2][0 : 0])
|
|
|
|
puts("PASS");
|
|
// CHECK: PASS
|
|
return 0;
|
|
}
|