LLVM OpenMP 22.0.0git
task_types_serialized.c
Go to the documentation of this file.
1// clang-format off
2// RUN: %libomp-compile-and-run | FileCheck %s
3// REQUIRES: ompt
4// clang-format on
5
6#include "callback.h"
7#include <omp.h>
8
9__attribute__ ((noinline)) // workaround for bug in icc
10void print_task_type(int id)
11{
12#pragma omp critical
13 {
14 int task_type;
15char buffer[2048];
16ompt_get_task_info(0, &task_type, NULL, NULL, NULL, NULL);
17format_task_type(task_type, buffer);
18printf("%" PRIu64 ": id=%d task_type=%s=%d\n", ompt_get_thread_data()->value,
19 id, buffer, task_type);
20}
21}
22;
23
24int main() {
25 // initial task
26 print_task_type(0);
27
28 int x;
29// implicit task
30#pragma omp parallel num_threads(1)
31 {
32 print_task_type(1);
33 x++;
34 }
35
36#pragma omp parallel num_threads(1)
37#pragma omp master
38 {
39// explicit task
40#pragma omp task
41 {
42 print_task_type(2);
43 x++;
44 }
45
46// explicit task with undeferred
47#pragma omp task if (0)
48 {
49 print_task_type(3);
50 x++;
51 }
52
53// explicit task with untied
54#pragma omp task untied
55 {
56 print_task_type(4);
57 x++;
58 }
59
60// explicit task with final
61#pragma omp task final(1)
62 {
63 print_task_type(5);
64 x++;
65// nested explicit task with final and undeferred
66#pragma omp task
67 {
68 print_task_type(6);
69 x++;
70 }
71 }
72
73 /*
74 //TODO:not working
75 //explicit task with mergeable
76 #pragma omp task mergeable
77 {
78 print_task_type(7);
79 x++;
80 }
81 */
82
83 // TODO: merged task
84 }
85
86 // clang-format off
87 // Check if libomp supports the callbacks for this test.
88 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create'
89 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
90
91
92 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
93
94 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-f]+}}, task_id={{[0-f]+}}, actual_parallelism=1, index=1, flags=1
95 // CHECK: {{^}}[[MASTER_ID]]: id=0 task_type=ompt_task_initial=1
96 // CHECK: {{^}}[[MASTER_ID]]: id=1 task_type=ompt_task_implicit|ompt_task_undeferred=134217730
97
98 // CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
99 // CHECK: {{^[0-9]+}}: id=2 task_type=ompt_task_explicit|ompt_task_undeferred=134217732
100
101 // CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
102 // CHECK: {{^[0-9]+}}: id=3 task_type=ompt_task_explicit|ompt_task_undeferred=134217732
103
104 // CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_untied=402653188, has_dependences=no
105 // CHECK: {{^[0-9]+}}: id=4 task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_untied=402653188
106
107 // CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_final=671088644, has_dependences=no
108 // CHECK: {{^[0-9]+}}: id=5 task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_final=671088644
109
110 // CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_final=671088644, has_dependences=no
111 // CHECK: {{^[0-9]+}}: id=6 task_type=ompt_task_explicit|ompt_task_undeferred|ompt_task_final=671088644
112
113 // ___CHECK: {{^[0-9]+}}: ompt_event_task_create: parent_task_id={{[0-f]+}}, parent_task_frame.exit={{(0x)?[0-f]+}}, parent_task_frame.reenter={{(0x)?[0-f]+}}, new_task_id={{[0-f]+}}, codeptr_ra={{(0x)?[0-f]+}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no
114 // ___CHECK: {{^[0-9]+}}: id=7 task_type=ompt_task_explicit|ompt_task_undeferred=134217732
115 // clang-format on
116
117 return 0;
118}
static ompt_get_task_info_t ompt_get_task_info
Definition callback.h:156
static void format_task_type(int type, char *buffer)
Definition callback.h:129
static ompt_get_thread_data_t ompt_get_thread_data
Definition callback.h:158
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value
__attribute__((noinline))
int main()