[Instrumentation] Fix a warning
[llvm-project.git] / openmp / runtime / test / tasking / omp_task_imp_firstprivate.c
blob905ab9ac766fb433fddd691f539e936bb4415f26
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <math.h>
4 #include "omp_testsuite.h"
6 /* Utility function do spend some time in a loop */
7 int test_omp_task_imp_firstprivate()
9 int i=5;
10 int k = 0;
11 int result = 0;
12 int task_result = 1;
13 #pragma omp parallel firstprivate(i)
15 #pragma omp single
17 for (k = 0; k < NUM_TASKS; k++) {
18 #pragma omp task shared(result , task_result)
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
29 #pragma omp taskwait
30 result = (task_result && i==5);
33 return result;
36 int main()
38 int i;
39 int num_failed=0;
41 for(i = 0; i < REPETITIONS; i++) {
42 if(!test_omp_task_imp_firstprivate()) {
43 num_failed++;
46 return num_failed;