LLVM OpenMP 22.0.0git
cancel_parallel.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
5// XFAIL: gcc
6// clang-format on
7
8#include "callback.h"
9#include "omp.h"
10
11int main() {
12#pragma omp parallel num_threads(2)
13 {
14 if (omp_get_thread_num() == 0) {
16#pragma omp cancel parallel
18 // We cannot print at this location because the parallel region is
19 // cancelled!
20 } else {
21 delay(100);
23#pragma omp cancellation point parallel
25 // We cannot print at this location because the parallel region is
26 // cancelled!
27 }
28 }
29
30 // clang-format off
31 // Check if libomp supports the callbacks for this test.
32 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_implicit_task'
33 // CHECK-NOT: {{^}}0: Could not register callback 'ompt_callback_cancel'
34
35 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
36 // 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
37 // CHECK-DAG: {{^}}[[MASTER_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_activated=17, codeptr_ra=[[RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
38 // CHECK-DAG: {{^}}[[MASTER_ID]]: fuzzy_address={{.*}}[[RETURN_ADDRESS]]
39
40 // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: ompt_event_implicit_task_begin
41 // CHECK-DAG: {{^}}[[THREAD_ID]]: ompt_event_cancel: task_id=[[TASK_ID:[0-f]+]], flags=ompt_cancel_parallel|ompt_cancel_detected=33, codeptr_ra=[[OTHER_RETURN_ADDRESS:(0x)?[0-f]+]]{{[0-f][0-f]}}
42 // CHECK-DAG: {{^}}[[THREAD_ID]]: fuzzy_address={{.*}}[[OTHER_RETURN_ADDRESS]]
43 // clang-format on
44
45 return 0;
46}
#define get_ompt_label_address(id)
Definition callback.h:251
#define print_fuzzy_address_blocks(addr)
Definition callback.h:367
#define define_ompt_label(id)
Definition callback.h:242
int main()
#define delay(t)
Definition ompt-signal.h:6