Debian Codegraph @

openmp/runtime/test/ompt/tasks/dependences_mutexinoutset.c

raw
1 // clang-format off
2 // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
3 // REQUIRES: ompt
4
5 // GCC 9 introduced codegen for mutexinoutset
6 // UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8
7
8 // icc does not yet support mutexinoutset
9 // XFAIL: icc
10
11 // clang 9 introduced codegen for mutexinoutset
12 // UNSUPPORTED: clang-4, clang-5, clang-6, clang-7, clang-8
13 // clang-format on
14
15 #include "callback.h"
16 #include <omp.h>
17 #include <math.h>
18 #include <unistd.h>
19
20 int main() {
21 int x = 0;
22 #pragma omp parallel num_threads(2)
23 {
24 #pragma omp master
25 {
26 print_ids(0);
27 printf("%" PRIu64 ": address of x: %p\n", ompt_get_thread_data()->value,
28 &x);
29 #pragma omp task depend(out : x)
30 {
31 x++;
32 delay(100);
33 }
34 print_fuzzy_address(1);
35 print_ids(0);
36
37 #pragma omp task depend(mutexinoutset : x)
38 {
39 x++;
40 delay(100);
41 }
42 print_fuzzy_address(2);
43 print_ids(0);
44
45 #pragma omp task depend(in : x)
46 { x = -1; }
47 print_ids(0);
48 }
49 }
50
51 x++;
52
53 return 0;
54 }
55
56 // clang-format off
57 // Check if libomp supports the callbacks for this test.
58 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
59 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_dependences'
60 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_depende
61
62 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
63
64 // make sure initial data pointers are null
65 // CHECK-NOT: 0: new_task_data initially not null
66
67 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_implicit_task_begin:
68 // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-f]+]],
69 // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID:[0-f]+]]
70
71 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
72 // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT:(0x)?[0-f]+]],
73 // CHECK-SAME: reenter_frame=[[NULL]]
74
75 // CHECK: {{^}}[[MASTER_ID]]: address of x: [[ADDRX:(0x)?[0-f]+]]
76 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
77 // CHECK-SAME: parent_task_id={{[0-f]+}}, parent_task_frame.exit=[[EXIT]],
78 // CHECK-SAME: parent_task_frame.reenter={{(0x)?[0-f]+}},
79 // CHECK-SAME: new_task_id=[[FIRST_TASK:[0-f]+]],
80 // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}},
81 // CHECK-SAME: task_type=ompt_task_explicit=4, has_dependences=yes
82
83 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_dependences:
84 // CHECK-SAME: task_id=[[FIRST_TASK]], deps=[([[ADDRX]],
85 // CHECK-SAME: ompt_dependence_type_inout)], ndeps=1
86
87 // CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
88 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
89 // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
90 // CHECK-SAME: reenter_frame=[[NULL]]
91
92 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
93 // CHECK-SAME: parent_task_id={{[0-f]+}}, parent_task_frame.exit=[[EXIT]],
94 // CHECK-SAME: parent_task_frame.reenter={{(0x)?[0-f]+}},
95 // CHECK-SAME: new_task_id=[[SECOND_TASK:[0-f]+]],
96 // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}},
97 // CHECK-SAME: task_type=ompt_task_explicit=4, has_dependences=yes
98
99 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_dependences:
100 // CHECK-SAME: task_id=[[SECOND_TASK]], deps=[([[ADDRX]],
101 // CHECK-SAME: ompt_dependence_type_mutexinoutset)], ndeps=1
102
103 // CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
104 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
105 // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
106 // CHECK-SAME: reenter_frame=[[NULL]]
107
108 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
109 // CHECK-SAME: parent_task_id={{[0-f]+}}, parent_task_frame.exit=[[EXIT]],
110 // CHECK-SAME: parent_task_frame.reenter={{(0x)?[0-f]+}},
111 // CHECK-SAME: new_task_id=[[THIRD_TASK:[0-f]+]], codeptr_ra={{(0x)?[0-f]+}},
112 // CHECK-SAME: task_type=ompt_task_explicit=4, has_dependences=yes
113
114 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_dependences:
115 // CHECK-SAME: task_id=[[THIRD_TASK]], deps=[([[ADDRX]],
116 // CHECK-SAME: ompt_dependence_type_in)], ndeps=1
117
118 // CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
119 // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT]],
120 // CHECK-SAME: reenter_frame=[[NULL]]
121 // clang-format on