xref: /llvm-project/openmp/runtime/test/ompt/worksharing/for/base_serialized.h (revision a707d0883b5ab9de6a0a864df614ef14909a4de1)
1 #include "callback.h"
2 #include <omp.h>
3 #include <stdio.h>
4 
5 #define STRINGIFY(x) #x
6 #define STR(x) STRINGIFY(x)
7 #ifndef SCHED_OUTPUT
8 #define SCHED_OUTPUT STR(SCHEDULE)
9 #endif
10 
main()11 int main()
12 {
13   unsigned int i;
14   printf("0: Schedule: " SCHED_OUTPUT "\n");
15 
16 #pragma omp parallel for num_threads(1) schedule(SCHEDULE)
17   for (i = 0; i < 64; i++) {
18   }
19 
20   // clang-format off
21   // Check if libomp supports the callbacks for this test.
22   // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_begin'
23   // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_parallel_end'
24   // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
25   // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_work'
26 
27 
28   // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
29   // CHECK: 0: Schedule: [[SCHED:[a-z]+]]
30   // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin: parent_task_id=[[PARENT_TASK_ID:[0-9]+]], parent_task_frame.exit=[[NULL]], parent_task_frame.reenter={{0x[0-f]+}}, parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=1, codeptr_ra=0x{{[0-f]+}}, invoker={{[0-9]+}}
31 
32   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin: parallel_id=[[PARALLEL_ID:[0-9]+]], task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
33   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_[[SCHED]]_begin: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]], codeptr_ra=0x{{[0-f]+}}
34   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_loop_[[SCHED]]_end: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
35   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end: parallel_id={{[PARALLEL_ID,0]}}, task_id=[[IMPLICIT_TASK_ID]]
36   // clang-format on
37 
38   return 0;
39 }
40