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