1// RUN: %libomp-compile && env OMP_THREAD_LIMIT=2 %libomp-run | FileCheck %s
2// RUN: %libomp-compile && env OMP_THREAD_LIMIT=2 %libomp-run | %sort-threads \
3// RUN: | FileCheck --check-prefix=THREADS %s
4
5// REQUIRES: ompt
6
7#include "callback.h"
8
9int main() {
10#pragma omp parallel num_threads(4)
11 {
12 print_ids(0);
13 print_ids(1);
14 }
15 print_fuzzy_address(1);
16
17 // Check if libomp supports the callbacks for this test.
18 // CHECK-NOT: {{^}}0: Could not register callback
19
20 // Make sure initial data pointers are null.
21 // CHECK-NOT: 0: parallel_data initially not null
22 // CHECK-NOT: 0: task_data initially not null
23 // CHECK-NOT: 0: thread_data initially not null
24
25 // Only check callback names, arguments are verified in THREADS below.
26 // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin
27
28 // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin
29 // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
30
31 // Note that we cannot ensure that the worker threads have already called
32 // barrier_end and implicit_task_end before parallel_end!
33
34 // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
35 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
36
37 // CHECK: {{^}}[[MASTER_ID]]: ompt_event_parallel_end
38
39 // THREADS: 0: NULL_POINTER=[[NULL:.*$]]
40 // THREADS: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_thread_begin
41 // THREADS-SAME: thread_type=ompt_thread_initial=1, thread_id=[[MASTER_ID]]
42 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_begin
43 // THREADS-SAME: parent_task_id=[[PARENT_TASK_ID:[0-9]+]]
44 // THREADS-SAME: parent_task_frame.exit=[[NULL]]
45 // THREADS-SAME: parent_task_frame.reenter={{0x[0-f]+}}
46 // THREADS-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], requested_team_size=4
47 // THREADS-SAME: codeptr_ra=[[RETURN_ADDRESS:0x[0-f]+]]{{[0-f][0-f]}}
48
49 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_begin
50 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
51 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
52 // THREADS: {{^}}[[MASTER_ID]]: task level 0
53 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
54 // THREADS: {{^}}[[MASTER_ID]]: task level 1
55 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID:[0-9]+]]
56 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
57
58 // THREADS-NOT: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
59 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_begin
60 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
61 // parallel_id is 0 because the region ended in the barrier!
62 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_barrier_end
63 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
64 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_implicit_task_end
65 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
66 // THREADS: {{^}}[[MASTER_ID]]: ompt_event_parallel_end
67 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[PARENT_TASK_ID]]
68 // THREADS: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
69
70 // THREADS: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin
71 // THREADS-SAME: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]]
72 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_begin
73 // THREADS-SAME: parallel_id=[[PARALLEL_ID]]
74 // THREADS-SAME: task_id=[[IMPLICIT_TASK_ID:[0-9]+]]
75 // THREADS: {{^}}[[THREAD_ID]]: task level 0
76 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
77 // THREADS: {{^}}[[THREAD_ID]]: task level 1
78 // THREADS-SAME: parallel_id=[[IMPLICIT_PARALLEL_ID]]
79 // THREADS-SAME: task_id=[[PARENT_TASK_ID]]
80 // THREADS-NOT: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
81 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_begin
82 // THREADS-SAME: parallel_id=[[PARALLEL_ID]], task_id=[[IMPLICIT_TASK_ID]]
83 // parallel_id is 0 because the region ended in the barrier!
84 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_barrier_end
85 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
86 // THREADS: {{^}}[[THREAD_ID]]: ompt_event_implicit_task_end
87 // THREADS-SAME: parallel_id=0, task_id=[[IMPLICIT_TASK_ID]]
88
89 return 0;
90}
91

source code of openmp/runtime/test/ompt/parallel/not_enough_threads.c