1// RUN: %libomptarget-compile-run-and-check-generic
2// REQUIRES: ompt
3// UNSUPPORTED: aarch64-unknown-linux-gnu
4// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
5// UNSUPPORTED: x86_64-pc-linux-gnu
6// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
7// UNSUPPORTED: s390x-ibm-linux-gnu
8// UNSUPPORTED: s390x-ibm-linux-gnu-LTO
9
10/*
11 * Example OpenMP program that registers non-EMI callbacks
12 */
13
14#include <omp.h>
15#include <stdio.h>
16
17#include "callbacks.h"
18#include "register_non_emi.h"
19
20int main() {
21 int N = 100000;
22
23 int a[N];
24 int b[N];
25
26 int i;
27
28 for (i = 0; i < N; i++)
29 a[i] = 0;
30
31 for (i = 0; i < N; i++)
32 b[i] = i;
33
34#pragma omp target parallel for
35 {
36 for (int j = 0; j < N; j++)
37 a[j] = b[j];
38 }
39
40#pragma omp target teams distribute parallel for
41 {
42 for (int j = 0; j < N; j++)
43 a[j] = b[j];
44 }
45
46 int rc = 0;
47 for (i = 0; i < N; i++)
48 if (a[i] != b[i]) {
49 rc++;
50 printf(format: "Wrong value: a[%d]=%d\n", i, a[i]);
51 }
52
53 if (!rc)
54 printf(format: "Success\n");
55
56 return rc;
57}
58
59// clang-format off
60/// CHECK: Callback Init:
61/// CHECK: Callback Load:
62/// CHECK: Callback Target: target_id=[[TARGET_ID:[0-9]+]] kind=1 endpoint=1 device_num=[[DEVICE_NUM:[0-9]+]]
63/// CHECK-NOT: code=(nil)
64/// CHECK: code=[[CODE1:.*]]
65/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=1
66/// CHECK: code=[[CODE1]]
67/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=2
68/// CHECK: code=[[CODE1]]
69/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=1
70/// CHECK: code=[[CODE1]]
71/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=2
72/// CHECK: code=[[CODE1]]
73/// CHECK: Callback Submit: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] req_num_teams=1
74/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=3
75/// CHECK: code=[[CODE1]]
76/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=3
77/// CHECK: code=[[CODE1]]
78/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=4
79/// CHECK: code=[[CODE1]]
80/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=4
81/// CHECK: code=[[CODE1]]
82/// CHECK: Callback Target: target_id=[[TARGET_ID:[0-9]+]] kind=1 endpoint=2 device_num=[[DEVICE_NUM]] code=[[CODE1]]
83
84/// CHECK: Callback Target: target_id=[[TARGET_ID:[0-9]+]] kind=1 endpoint=1
85/// device_num=[[DEVICE_NUM]]
86/// CHECK-NOT: code=(nil)
87/// CHECK: code=[[CODE2:.*]]
88/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=1
89/// CHECK: code=[[CODE2]]
90/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=2
91/// CHECK: code=[[CODE2]]
92/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=1
93/// CHECK: code=[[CODE2]]
94/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=2
95/// CHECK: code=[[CODE2]]
96/// CHECK: Callback Submit: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] req_num_teams=0
97/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=3
98/// CHECK: code=[[CODE2]]
99/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=3
100/// CHECK: code=[[CODE2]]
101/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=4
102/// CHECK: code=[[CODE2]]
103/// CHECK: Callback DataOp: target_id=[[TARGET_ID:[0-9]+]] host_op_id=[[HOST_OP_ID:[0-9]+]] optype=4
104/// CHECK: code=[[CODE2]]
105/// CHECK: Callback Target: target_id=[[TARGET_ID:[0-9]+]] kind=1 endpoint=2 device_num=[[DEVICE_NUM]] code=[[CODE2]]
106/// CHECK: Callback Fini:
107

source code of offload/test/ompt/veccopy.c