LLVM OpenMP
runtime
test
tasking
omp_untied_task_cancel.c
Go to the documentation of this file.
1
// RUN: %libomp-compile && env OMP_CANCELLATION=true %libomp-run
2
3
// A cancelled untied task is never invoked, but it has already been made the
4
// thread's current task by __kmp_task_start(), and it still runs
5
// __kmp_task_finish() -> __kmp_release_deps() to release its successors while
6
// it is current. So it needs td_last_tied initialized just like a task
7
// that actually executes.
8
9
#include <stdio.h>
10
#include <omp.h>
11
12
#define REPS 10
13
#define NDEPS 256
14
15
int
x
[
NDEPS
];
16
17
int
main
(
void
) {
18
if
(!omp_get_cancellation()) {
19
fprintf(stderr,
"cancellation disabled, set OMP_CANCELLATION=true\n"
);
20
return
1;
21
}
22
23
for
(
int
r
= 0;
r
<
REPS
; ++
r
) {
24
#pragma omp parallel
25
{
26
#pragma omp single
27
{
28
#pragma omp taskgroup
29
{
30
// Request cancellation up front so the tasks created below are
31
// discarded rather than executed.
32
#pragma omp task
33
{
34
#pragma omp cancel taskgroup
35
}
36
for
(
int
i
= 0;
i
<
NDEPS
; ++
i
) {
37
// An untied predecessor with a tied successor: the tied one is the
38
// candidate that makes the constraint check read td_last_tied off
39
// the predecessor while it is releasing its dependences.
40
#pragma omp task untied depend(out : x[i])
41
{
42
x
[
i
]++;
43
}
44
#pragma omp task depend(in : x[i])
45
{
46
x
[
i
]++;
47
}
48
}
49
}
50
}
51
}
52
}
53
54
// How many tasks ran is not deterministic under cancellation, so there is
55
// nothing to verify beyond completing without crashing or hanging.
56
printf(
"passed\n"
);
57
return
0;
58
}
i
#define i
Definition
kmp_stub.cpp:88
r
int r
Definition
omp_task_red_taskloop.c:15
NDEPS
#define NDEPS
Definition
omp_untied_task_cancel.c:13
REPS
#define REPS
Definition
omp_untied_task_cancel.c:12
x
int x[NDEPS]
Definition
omp_untied_task_cancel.c:15
main
int main(void)
Definition
omp_untied_task_cancel.c:17
Generated on
for LLVM OpenMP by
1.14.0