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