Skip to content

Commit cee52dd

Browse files
committed
[OpenMP] Implement TR8 present motion modifier in runtime (2/2)
This patch implements OpenMP runtime support for the OpenMP TR8 `present` motion modifier for `omp target update` directives. The previous patch in this series implements Clang front end support. Reviewed By: grokos Differential Revision: https://reviews.llvm.org/D84712
1 parent 9f2f3b9 commit cee52dd

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

openmp/libomptarget/src/omptarget.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,12 @@ int target_data_update(DeviceTy &Device, int32_t arg_num,
628628
false, IsHostPtr);
629629
if (!TgtPtrBegin) {
630630
DP("hst data:" DPxMOD " not found, becomes a noop\n", DPxPTR(HstPtrBegin));
631+
if (arg_types[i] & OMP_TGT_MAPTYPE_PRESENT) {
632+
MESSAGE("device mapping required by 'present' motion modifier does not "
633+
"exist for host address " DPxMOD " (%ld bytes)",
634+
DPxPTR(HstPtrBegin), MapSize);
635+
return OFFLOAD_FAIL;
636+
}
631637
continue;
632638
}
633639

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// --------------------------------------------------
2+
// Check 'to'
3+
// --------------------------------------------------
4+
5+
// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu \
6+
// RUN: -fopenmp-version=51 -DCLAUSE=to
7+
// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \
8+
// RUN: | %fcheck-aarch64-unknown-linux-gnu
9+
10+
// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu \
11+
// RUN: -fopenmp-version=51 -DCLAUSE=to
12+
// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \
13+
// RUN: | %fcheck-powerpc64-ibm-linux-gnu
14+
15+
// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu \
16+
// RUN: -fopenmp-version=51 -DCLAUSE=to
17+
// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \
18+
// RUN: | %fcheck-powerpc64le-ibm-linux-gnu
19+
20+
// RUN: %libomptarget-compile-x86_64-pc-linux-gnu \
21+
// RUN: -fopenmp-version=51 -DCLAUSE=to
22+
// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \
23+
// RUN: | %fcheck-x86_64-pc-linux-gnu
24+
25+
// --------------------------------------------------
26+
// Check 'from'
27+
// --------------------------------------------------
28+
29+
// RUN: %libomptarget-compile-aarch64-unknown-linux-gnu \
30+
// RUN: -fopenmp-version=51 -DCLAUSE=from
31+
// RUN: %libomptarget-run-fail-aarch64-unknown-linux-gnu 2>&1 \
32+
// RUN: | %fcheck-aarch64-unknown-linux-gnu
33+
34+
// RUN: %libomptarget-compile-powerpc64-ibm-linux-gnu \
35+
// RUN: -fopenmp-version=51 -DCLAUSE=from
36+
// RUN: %libomptarget-run-fail-powerpc64-ibm-linux-gnu 2>&1 \
37+
// RUN: | %fcheck-powerpc64-ibm-linux-gnu
38+
39+
// RUN: %libomptarget-compile-powerpc64le-ibm-linux-gnu \
40+
// RUN: -fopenmp-version=51 -DCLAUSE=from
41+
// RUN: %libomptarget-run-fail-powerpc64le-ibm-linux-gnu 2>&1 \
42+
// RUN: | %fcheck-powerpc64le-ibm-linux-gnu
43+
44+
// RUN: %libomptarget-compile-x86_64-pc-linux-gnu \
45+
// RUN: -fopenmp-version=51 -DCLAUSE=from
46+
// RUN: %libomptarget-run-fail-x86_64-pc-linux-gnu 2>&1 \
47+
// RUN: | %fcheck-x86_64-pc-linux-gnu
48+
49+
#include <stdio.h>
50+
51+
int main() {
52+
int i;
53+
54+
// CHECK: addr=0x[[#%x,HOST_ADDR:]], size=[[#%u,SIZE:]]
55+
fprintf(stderr, "addr=%p, size=%ld\n", &i, sizeof i);
56+
57+
// CHECK-NOT: Libomptarget
58+
#pragma omp target enter data map(alloc: i)
59+
#pragma omp target update CLAUSE(present: i)
60+
#pragma omp target exit data map(delete: i)
61+
62+
// CHECK: i is present
63+
fprintf(stderr, "i is present\n");
64+
65+
// CHECK: Libomptarget message: device mapping required by 'present' motion modifier does not exist for host address 0x{{0*}}[[#HOST_ADDR]] ([[#SIZE]] bytes)
66+
// CHECK: Libomptarget fatal error 1: failure of target construct while offloading is mandatory
67+
#pragma omp target update CLAUSE(present: i)
68+
69+
// CHECK-NOT: i is present
70+
fprintf(stderr, "i is present\n");
71+
72+
return 0;
73+
}

0 commit comments

Comments
 (0)