1// RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
2// REQUIRES: ompt
3// UNSUPPORTED: intel-15.0, intel-16.0, intel-17.0, intel-18.0
4// GCC generates code that does not distinguish between sections and loops
5// UNSUPPORTED: gcc
6
7#include "callback.h"
8#include <omp.h>
9
10int main()
11{
12 #pragma omp parallel sections num_threads(2)
13 {
14 #pragma omp section
15 {
16 printf("%lu: section 1\n", ompt_get_thread_data()->value);
17 }
18 #pragma omp section
19 {
20 printf("%lu: section 2\n", ompt_get_thread_data()->value);
21 }
22 }
23
24 // Check if libomp supports the callbacks for this test.
25 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_work'
26 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_dispatch'
27
28 // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
29
30 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_sections_begin:
31 // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]],
32 // CHECK-SAME: parent_task_id=[[TASK_ID:[0-9]+]],
33 // CHECK-SAME: codeptr_ra=[[SECT_BEGIN:0x[0-f]+]], count=2
34 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_section_begin:
35 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]]
36 // CHECK-SAME: codeptr_ra=[[SECT_BEGIN]]
37 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_sections_end:
38 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}},
39 // CHECK-SAME: codeptr_ra=[[SECT_END:0x[0-f]+]]
40
41 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_sections_begin:
42 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], parent_task_id=[[TASK_ID:[0-9]+]],
43 // CHECK-SAME: codeptr_ra=[[SECT_BEGIN]], count=2
44 // CHECK: {{^}}[[THREAD_ID]]: ompt_event_section_begin:
45 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[TASK_ID]]
46 // CHECK-SAME: codeptr_ra=[[SECT_BEGIN]]
47 // CHECK: {{^}}[[THREAD_ID]]: ompt_event_sections_end:
48 // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id={{[0-9]+}},
49 // CHECK-SAME: codeptr_ra=[[SECT_END]]
50
51 return 0;
52}
53

source code of openmp/runtime/test/ompt/worksharing/sections_dispatch.c