1 | // RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s |
2 | // REQUIRES: ompt |
3 | // UNSUPPORTED: clang-3, clang-4.0.0 |
4 | // Current GOMP interface implementation does not support cancellation; icc 16 has a bug |
5 | // XFAIL: gcc, icc-16 |
6 | |
7 | #include "callback.h" |
8 | #include <unistd.h> |
9 | #include <stdio.h> |
10 | |
11 | int main() |
12 | { |
13 | int condition=0; |
14 | #pragma omp parallel num_threads(2) |
15 | {} |
16 | |
17 | print_frame(0); |
18 | #pragma omp parallel num_threads(2) |
19 | { |
20 | #pragma omp master |
21 | { |
22 | #pragma omp taskgroup |
23 | { |
24 | #pragma omp task shared(condition) |
25 | { |
26 | printf(format: "start execute task 1\n" ); |
27 | OMPT_SIGNAL(condition); |
28 | OMPT_WAIT(condition,2); |
29 | #pragma omp cancellation point taskgroup |
30 | printf(format: "end execute task 1\n" ); |
31 | } |
32 | #pragma omp task shared(condition) |
33 | { |
34 | printf(format: "start execute task 2\n" ); |
35 | OMPT_SIGNAL(condition); |
36 | OMPT_WAIT(condition,2); |
37 | #pragma omp cancellation point taskgroup |
38 | printf(format: "end execute task 2\n" ); |
39 | } |
40 | #pragma omp task shared(condition) |
41 | { |
42 | printf(format: "start execute task 3\n" ); |
43 | OMPT_SIGNAL(condition); |
44 | OMPT_WAIT(condition,2); |
45 | #pragma omp cancellation point taskgroup |
46 | printf(format: "end execute task 3\n" ); |
47 | } |
48 | #pragma omp task if(0) shared(condition) |
49 | { |
50 | printf(format: "start execute task 4\n" ); |
51 | OMPT_WAIT(condition,1); |
52 | #pragma omp cancel taskgroup |
53 | printf(format: "end execute task 4\n" ); |
54 | } |
55 | OMPT_SIGNAL(condition); |
56 | } |
57 | } |
58 | #pragma omp barrier |
59 | } |
60 | |
61 | // Check if libomp supports the callbacks for this test. |
62 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_masked' |
63 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_create' |
64 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_task_schedule' |
65 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel' |
66 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_thread_begin' |
67 | |
68 | // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] |
69 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_masked_begin: |
70 | // CHECK-SAME: parallel_id=[[PARALLEL_ID:[0-9]+]], |
71 | // CHECK-SAME: task_id=[[PARENT_TASK_ID:[0-9]+]], |
72 | // CHECK-SAME: codeptr_ra={{0x[0-f]*}} |
73 | |
74 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[FIRST_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no |
75 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[SECOND_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no |
76 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[THIRD_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit=4, has_dependences=no |
77 | |
78 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_create: parent_task_id=[[PARENT_TASK_ID]], parent_task_frame.exit={{0x[0-f]*}}, parent_task_frame.reenter={{0x[0-f]*}}, new_task_id=[[CANCEL_TASK_ID:[0-9]+]], codeptr_ra={{0x[0-f]*}}, task_type=ompt_task_explicit|ompt_task_undeferred=134217732, has_dependences=no |
79 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[PARENT_TASK_ID]], second_task_id=[[CANCEL_TASK_ID]], prior_task_status=ompt_task_switch=7 |
80 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[CANCEL_TASK_ID]], flags=ompt_cancel_taskgroup|ompt_cancel_activated=24, codeptr_ra={{0x[0-f]*}} |
81 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_task_schedule: first_task_id=[[CANCEL_TASK_ID]], second_task_id=[[PARENT_TASK_ID]], prior_task_status=ompt_task_cancel=3 |
82 | |
83 | // CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]] |
84 | // CHECK-DAG: {{^}}{{[0-9]+}}: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_discarded_task=72, codeptr_ra=[[NULL]] |
85 | |
86 | // CHECK-DAG: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_thread_begin: thread_type=ompt_thread_worker=2, thread_id=[[THREAD_ID]] |
87 | // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_data={{[0-9]+}}, flags=ompt_cancel_taskgroup|ompt_cancel_detected=40, codeptr_ra={{0x[0-f]*}} |
88 | |
89 | return 0; |
90 | } |
91 | |