[rtsan] Add fork/execve interceptors (#117198)
[llvm-project.git] / openmp / runtime / test / ompt / cancel / cancel_worksharing.c
blob8576f96580b09ae9206ccc40763927cd4324445f
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
6 #include "callback.h"
7 #include <unistd.h>
9 int main()
11 int condition=0;
12 #pragma omp parallel num_threads(2)
14 int x = 0;
15 int i;
16 #pragma omp for
17 for(i = 0; i < 2; i++)
19 if(i == 0)
21 x++;
22 OMPT_SIGNAL(condition);
23 #pragma omp cancel for
25 else
27 x++;
28 OMPT_WAIT(condition,1);
29 delay(10000);
30 #pragma omp cancellation point for
34 #pragma omp parallel num_threads(2)
36 #pragma omp sections
38 #pragma omp section
40 OMPT_SIGNAL(condition);
41 #pragma omp cancel sections
43 #pragma omp section
45 OMPT_WAIT(condition,2);
46 delay(10000);
47 #pragma omp cancellation point sections
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'
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
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]*}}
66 return 0;