1// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
2// REQUIRES: ompt
3
4// taskwait with depend clause was introduced with gcc-9
5// UNSUPPORTED: gcc-4, gcc-5, gcc-6, gcc-7, gcc-8
6
7// icc does not yet support taskwait with depend clause
8// XFAIL: icc
9
10// support for taskwait with depend clause introduced in clang-14
11// UNSUPPORTED: clang-5, clang-6, clang-6, clang-8, clang-9, clang-10, clang-11, clang-12, clang-13
12
13#include "callback.h"
14#include <omp.h>
15
16int main() {
17 int x = 0;
18#pragma omp parallel num_threads(2)
19 {
20#pragma omp master
21 {
22 print_ids(0);
23 printf("%" PRIu64 ": address of x: %p\n", ompt_get_thread_data()->value,
24 &x);
25#pragma omp task depend(out : x)
26 { x++; }
27 print_fuzzy_address(1);
28 #pragma omp taskwait depend(in: x)
29 print_fuzzy_address(2);
30 }
31 }
32
33 return 0;
34}
35
36// Check if libomp supports the callbacks for this test.
37// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
38// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_dependences'
39// CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_depende
40
41// CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
42
43// make sure initial data pointers are null
44// CHECK-NOT: 0: new_task_data initially not null
45
46// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_implicit_task_begin:
47// CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
48// CHECK-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
49
50// CHECK: {{^}}[[MASTER_ID]]: task level 0: parallel_id=[[PARALLEL_ID]],
51// CHECK-SAME: task_id=[[IMPLICIT_TASK_ID]], exit_frame=[[EXIT:0x[0-f]+]],
52// CHECK-SAME: reenter_frame=[[NULL]]
53
54// CHECK: {{^}}[[MASTER_ID]]: address of x: [[ADDRX:0x[0-f]+]]
55
56// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
57// CHECK-SAME: parent_task_id={{[0-9]+}}, parent_task_frame.exit=[[EXIT]],
58// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
59// CHECK-SAME: new_task_id=[[FIRST_TASK:[0-f]+]],
60// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}},
61// CHECK-SAME: task_type=ompt_task_explicit=4, has_dependences=yes
62
63// CHECK: {{^}}[[MASTER_ID]]: ompt_event_dependences:
64// CHECK-SAME: task_id=[[FIRST_TASK]], deps=[([[ADDRX]],
65// CHECK-SAME: ompt_dependence_type_inout)], ndeps=1
66
67// CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
68
69// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
70// CHECK-SAME: parent_task_id={{[0-9]+}}, parent_task_frame.exit=[[EXIT]],
71// CHECK-SAME: parent_task_frame.reenter={{0x[0-f]+}},
72// CHECK-SAME: new_task_id=[[SECOND_TASK:[0-f]+]],
73// CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}},
74// CHECK-SAME: task_type=ompt_task_taskwait|ompt_task_undeferred|
75// CHECK-SAME: ompt_task_mergeable=1207959568, has_dependences=yes
76
77// CHECK: {{^}}[[MASTER_ID]]: ompt_event_dependences:
78// CHECK-SAME: task_id=[[SECOND_TASK]], deps=[([[ADDRX]],
79// CHECK-SAME: ompt_dependence_type_in)], ndeps=1
80
81// CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_end: task_id=[[SECOND_TASK]]
82
83// CHECK: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
84

source code of openmp/runtime/test/ompt/tasks/taskwait-depend.c