1// RUN: %libomp-c99-compile-and-run | %sort-threads | FileCheck %s
2// REQUIRES: ompt
3// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7
4#include "callback.h"
5#include <omp.h>
6
7int main() {
8 int a[10][10];
9#pragma omp parallel num_threads(2)
10#pragma omp for ordered(2)
11 for (int i = 0; i < 2; i++)
12 for (int j = 0; j < 2; j++) {
13 a[i][j] = i + j + 1;
14 printf("%d, %d\n", i, j);
15#pragma omp ordered depend(sink : i - 1, j) depend(sink : i, j - 1)
16 if (i > 0 && j > 0)
17 a[i][j] = a[i - 1][j] + a[i][j - 1] + 1;
18 printf("%d, %d\n", i, j);
19#pragma omp ordered depend(source)
20 }
21
22 return 0;
23}
24// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
25
26// CHECK: {{^}}[[MASTER:[0-9]+]]: ompt_event_loop_begin:
27// CHECK-SAME: parallel_id={{[0-9]+}}, parent_task_id=[[ITASK:[0-9]+]],
28
29// CHECK: {{^}}[[MASTER]]: ompt_event_dependences: task_id=[[ITASK]],
30// CHECK-SAME: deps=[(0, ompt_dependence_type_source), (0,
31// CHECK-SAME: ompt_dependence_type_source)], ndeps=2
32
33// CHECK: {{^}}[[MASTER]]: ompt_event_dependences: task_id=[[ITASK]],
34// CHECK-SAME: deps=[(0, ompt_dependence_type_sink), (0,
35// CHECK-SAME: ompt_dependence_type_sink)], ndeps=2
36
37// CHECK: {{^}}[[MASTER]]: ompt_event_dependences: task_id=[[ITASK]],
38// CHECK-SAME: deps=[(0, ompt_dependence_type_source), (1,
39// CHECK-SAME: ompt_dependence_type_source)], ndeps=2
40
41// CHECK: {{^}}[[WORKER:[0-9]+]]: ompt_event_loop_begin:
42// CHECK-SAME: parallel_id={{[0-9]+}}, parent_task_id=[[ITASK:[0-9]+]],
43
44// CHECK: {{^}}[[WORKER]]: ompt_event_dependences: task_id=[[ITASK]],
45// CHECK-SAME: deps=[(0, ompt_dependence_type_sink), (0,
46// CHECK-SAME: ompt_dependence_type_sink)], ndeps=2
47
48// CHECK: {{^}}[[WORKER]]: ompt_event_dependences: task_id=[[ITASK]],
49// CHECK-SAME: deps=[(1, ompt_dependence_type_source), (0,
50// CHECK-SAME: ompt_dependence_type_source)], ndeps=2
51
52// either can be first for last iteration
53
54// CHECK-DAG: [[ITASK]]{{.*}}deps=[(0{{.*}}sink), (1,{{.*}}sink)]
55
56// CHECK-DAG: [[ITASK]]{{.*}}deps=[(1{{.*}}sink), (0,{{.*}}sink)]
57
58// CHECK: {{^}}[[WORKER]]: ompt_event_dependences: task_id=[[ITASK]],
59// CHECK-SAME: deps=[(1, ompt_dependence_type_source), (1,
60// CHECK-SAME: ompt_dependence_type_source)], ndeps=2
61

source code of openmp/runtime/test/ompt/synchronization/ordered_dependences.c