LLVM OpenMP
20.0.0git
runtime
test
tasking
omp_task_imp_firstprivate.c
Go to the documentation of this file.
1
// RUN: %libomp-compile-and-run
2
#include <stdio.h>
3
#include <math.h>
4
#include "
omp_testsuite.h
"
5
6
/* Utility function do spend some time in a loop */
7
int
test_omp_task_imp_firstprivate
()
8
{
9
int
i
=5;
10
int
k = 0;
11
int
result
= 0;
12
int
task_result = 1;
13
#pragma omp parallel firstprivate(i)
14
{
15
#pragma omp single
16
{
17
for
(k = 0; k <
NUM_TASKS
; k++) {
18
#pragma omp task shared(result , task_result)
19
{
20
int
j
;
21
//check if i is private
22
if
(
i
!= 5)
23
task_result = 0;
24
for
(
j
= 0;
j
<
NUM_TASKS
;
j
++)
25
i
++;
26
//this should be firstprivate implicitly
27
}
28
}
29
#pragma omp taskwait
30
result
= (task_result &&
i
==5);
31
}
32
}
33
return
result
;
34
}
35
36
int
main
()
37
{
38
int
i
;
39
int
num_failed=0;
40
41
for
(
i
= 0;
i
<
REPETITIONS
;
i
++) {
42
if
(!
test_omp_task_imp_firstprivate
()) {
43
num_failed++;
44
}
45
}
46
return
num_failed;
47
}
result
int result[2]
Definition:
cancellation_for_sections.c:13
i
#define i
Definition:
kmp_stub.cpp:87
j
int j
Definition:
omp_single_copyprivate.c:6
test_omp_task_imp_firstprivate
int test_omp_task_imp_firstprivate()
Definition:
omp_task_imp_firstprivate.c:7
main
int main()
Definition:
omp_task_imp_firstprivate.c:36
omp_testsuite.h
NUM_TASKS
#define NUM_TASKS
Definition:
omp_testsuite.h:20
REPETITIONS
#define REPETITIONS
Definition:
omp_testsuite.h:13
Generated on Wed Jan 29 2025 20:58:02 for LLVM OpenMP by
1.9.6