mirror of
https://github.com/clang-retro/llvm.git
synced 2026-11-28 21:29:24 -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>
38 lines
1.1 KiB
C
38 lines
1.1 KiB
C
// RUN: %libomptarget-compile-generic -DCLAUSE=to
|
|
// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
|
|
// RUN: %libomptarget-compile-generic -DCLAUSE=from
|
|
// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
|
|
// UNSUPPORTED: apu
|
|
|
|
// A data-motion clause treats an array section as its elements, so a
|
|
// zero-length one has nothing to update and nothing to check for presence.
|
|
// Unlike map(present: arr[0:0]) (zero_length_array_section.c), this is not an
|
|
// error even if arr is not mapped.
|
|
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
int arr[5] = {-1, -1, -1, -1, -1};
|
|
|
|
// CHECK-NOT: omptarget
|
|
#pragma omp target update CLAUSE(present : arr[0 : 0])
|
|
|
|
// Empty updates also preserve both the host and device values of a mapping.
|
|
#pragma omp target data map(to : arr)
|
|
{
|
|
for (int i = 0; i < 5; ++i)
|
|
arr[i] = 7;
|
|
#pragma omp target update CLAUSE(present : arr[0 : 0])
|
|
for (int i = 0; i < 5; ++i)
|
|
assert(arr[i] == 7);
|
|
#pragma omp target update from(arr)
|
|
for (int i = 0; i < 5; ++i)
|
|
assert(arr[i] == -1);
|
|
}
|
|
|
|
// CHECK: done
|
|
fprintf(stderr, "done\n");
|
|
return 0;
|
|
}
|