1 // RUN: %libomp-compile-and-run | FileCheck %s
2 // RUN: %libomp-compile-and-run | FileCheck --check-prefix=TASKS %s
3 // REQUIRES: ompt
4 
5 // These compilers don't support the taskloop construct
6 // UNSUPPORTED: gcc-4, gcc-5, icc-16
7 // GCC 6 has support for taskloops, but at least 6.3.0 is crashing on this test
8 // UNSUPPORTED: gcc-6
9 
10 #include "callback.h"
11 #include <omp.h>
12 
main()13 int main() {
14   unsigned int i, x;
15 
16 #pragma omp parallel num_threads(2)
17   {
18 #pragma omp barrier
19 
20 #pragma omp master
21 #pragma omp taskloop
22     for (i = 0; i < 5; i += 3) {
23       x++;
24     }
25   }
26   // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
27 
28   // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:
29   // CHECK-SAME: parent_task_id={{[0-9]+}}
30   // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]]
31   // CHECK-SAME: requested_team_size=2
32   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin:
33   // CHECK-SAME: parallel_id=[[PARALLEL_ID]]
34   // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID1:[0-9]+]]
35   // CHECK-SAME: team_size=2, thread_num=0
36   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_taskgroup_begin:
37   // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID1]]
38   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_taskloop_begin:
39   // CHECK-SAME: parallel_id=[[PARALLEL_ID]]
40   // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID1]]
41   // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]], count=2
42   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
43   // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID1]]
44   // CHECK-SAME: new_task_id=[[TASK_ID1:[0-9]+]]
45   // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS]]
46   // CHECK-SAME: task_type=ompt_task_explicit=4
47   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create:
48   // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID1]]
49   // CHECK-SAME: new_task_id=[[TASK_ID2:[0-9]+]]
50   // CHECK-SAME: codeptr_ra=[[RETURN_ADDRESS]]
51   // CHECK-SAME: task_type=ompt_task_explicit=4
52   // CHECK-NOT: {{^}}[[MASTER_ID]]: ompt_event_task_create:
53   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_taskloop_end:
54   // CHECK-SAME: parallel_id=[[PARALLEL_ID]]
55   // CHECK-SAME: parent_task_id=[[IMPLICIT_TASK_ID1]]
56   // CHECK-SAME: count=2
57   // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_wait_taskgroup_begin:
58   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_wait_taskgroup_end:
59   // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID1]]
60   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_taskgroup_end:
61   // CHECK-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID1]]
62   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end: parallel_id=0
63   // CHECK-SAME: task_id=[[IMPLICIT_TASK_ID1]], team_size=2, thread_num=0
64   // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_end:
65   // CHECK-SAME: parallel_id=[[PARALLEL_ID]]
66 
67   // TASKS: ompt_event_initial_task_begin:{{.*}} task_id={{[0-9]+}}
68   // TASKS: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_taskloop_begin:
69   // TASKS: ompt_event_task_create:{{.*}} new_task_id=[[TASK_ID1:[0-9]+]]
70   // TASKS-SAME: task_type=ompt_task_explicit
71   // TASKS-DAG: ompt_event_task_create:{{.*}} new_task_id=[[TASK_ID2:[0-9]+]]
72   // Schedule events:
73   // TASKS-DAG: {{^.*}}first_task_id={{[0-9]+}}, second_task_id=[[TASK_ID1]]
74   // TASKS-DAG: {{^.*}}first_task_id=[[TASK_ID1]], second_task_id={{[0-9]+}}
75   // TASKS-DAG: {{^.*}}first_task_id={{[0-9]+}}, second_task_id=[[TASK_ID2]]
76   // TASKS-DAG: {{^.*}}first_task_id=[[TASK_ID2]], second_task_id={{[0-9]+}}
77   // TASKS-NOT: ompt_event_task_schedule
78 
79   return 0;
80 }
81