1 | // RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run | %sort-threads | FileCheck %s |
2 | // REQUIRES: ompt |
3 | // Current GOMP interface implementation does not support cancellation; icc 16 does not distinguish between sections and loops |
4 | // XFAIL: icc-16 |
5 | |
6 | #include "callback.h" |
7 | #include <unistd.h> |
8 | |
9 | int main() |
10 | { |
11 | int condition=0; |
12 | #pragma omp parallel num_threads(2) |
13 | { |
14 | int x = 0; |
15 | int i; |
16 | #pragma omp for |
17 | for(i = 0; i < 2; i++) |
18 | { |
19 | if(i == 0) |
20 | { |
21 | x++; |
22 | OMPT_SIGNAL(condition); |
23 | #pragma omp cancel for |
24 | } |
25 | else |
26 | { |
27 | x++; |
28 | OMPT_WAIT(condition,1); |
29 | delay(10000); |
30 | #pragma omp cancellation point for |
31 | } |
32 | } |
33 | } |
34 | #pragma omp parallel num_threads(2) |
35 | { |
36 | #pragma omp sections |
37 | { |
38 | #pragma omp section |
39 | { |
40 | OMPT_SIGNAL(condition); |
41 | #pragma omp cancel sections |
42 | } |
43 | #pragma omp section |
44 | { |
45 | OMPT_WAIT(condition,2); |
46 | delay(10000); |
47 | #pragma omp cancellation point sections |
48 | } |
49 | } |
50 | } |
51 | |
52 | |
53 | // Check if libomp supports the callbacks for this test. |
54 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task' |
55 | // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel' |
56 | |
57 | // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]] |
58 | // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_initial_task_begin: parallel_id={{[0-9]+}}, task_id={{[0-9]+}}, actual_parallelism=1, index=1, flags=1 |
59 | |
60 | // cancel for and sections |
61 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_activated=20, codeptr_ra={{0x[0-f]*}} |
62 | // CHECK: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{0x[0-f]*}} |
63 | // CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_loop|ompt_cancel_detected=36, codeptr_ra={{0x[0-f]*}} |
64 | // CHECK: {{^}}[[OTHER_THREAD_ID:[0-9]+]]: ompt_event_cancel: task_data=[[TASK_ID:[0-9]+]], flags=ompt_cancel_sections|ompt_cancel_{{activated=18|detected=34}}, codeptr_ra={{0x[0-f]*}} |
65 | |
66 | return 0; |
67 | } |
68 | |