[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / tasking / omp_task_final.c
blobb531af6573259a78b6f4fc6ba7aa2b453160229e
1 // RUN: %libomp-compile-and-run
2 #include <stdio.h>
3 #include <math.h>
4 #include "omp_testsuite.h"
5 #include "omp_my_sleep.h"
7 int test_omp_task_final()
9 int tids[NUM_TASKS];
10 int includedtids[NUM_TASKS];
11 int i;
12 int error = 0;
13 #pragma omp parallel
15 #pragma omp single
17 for (i = 0; i < NUM_TASKS; i++) {
18 /* First we have to store the value of the loop index in a new variable
19 * which will be private for each task because otherwise it will be overwritten
20 * if the execution of the task takes longer than the time which is needed to
21 * enter the next step of the loop!
23 int myi;
24 myi = i;
26 #pragma omp task final(i>=10)
28 tids[myi] = omp_get_thread_num();
29 /* we generate included tasks for final tasks */
30 if(myi >= 10) {
31 int included = myi;
32 #pragma omp task
34 my_sleep (SLEEPTIME);
35 includedtids[included] = omp_get_thread_num();
36 } /* end of omp included task of the final task */
37 my_sleep (SLEEPTIME);
38 } /* end of if it is a final task*/
39 } /* end of omp task */
40 } /* end of for */
41 } /* end of single */
42 } /*end of parallel */
44 /* Now we ckeck if more than one thread executed the final task and its included task. */
45 for (i = 10; i < NUM_TASKS; i++) {
46 if (tids[i] != includedtids[i]) {
47 error++;
50 return (error==0);
51 } /* end of check_paralel_for_private */
53 int main()
55 int i;
56 int num_failed=0;
58 for(i = 0; i < REPETITIONS; i++) {
59 if(!test_omp_task_final()) {
60 num_failed++;
63 return num_failed;