[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / tasking / omp_taskyield.c
blob7f85413a1288fe35dface2b050e6b720175553a1
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_taskyield()
9 int i;
10 int count = 0;
11 int start_tid[NUM_TASKS];
12 int current_tid[NUM_TASKS];
14 for (i=0; i< NUM_TASKS; i++) {
15 start_tid[i]=0;
16 current_tid[i]=0;
19 #pragma omp parallel
21 #pragma omp single
23 for (i = 0; i < NUM_TASKS; i++) {
24 int myi = i;
25 #pragma omp task untied
27 my_sleep(SLEEPTIME);
28 start_tid[myi] = omp_get_thread_num();
29 #pragma omp taskyield
30 if((start_tid[myi] %2) ==0){
31 my_sleep(SLEEPTIME);
32 current_tid[myi] = omp_get_thread_num();
33 } /*end of if*/
34 } /* end of omp task */
35 } /* end of for */
36 } /* end of single */
37 } /* end of parallel */
38 for (i=0;i<NUM_TASKS; i++) {
39 //printf("start_tid[%d]=%d, current_tid[%d]=%d\n",
40 //i, start_tid[i], i , current_tid[i]);
41 if (current_tid[i] == start_tid[i])
42 count++;
44 return (count<NUM_TASKS);
47 int main()
49 int i;
50 int num_failed=0;
52 if (omp_get_max_threads() < 2)
53 omp_set_num_threads(8);
55 for(i = 0; i < REPETITIONS; i++) {
56 if(!test_omp_taskyield()) {
57 num_failed++;
60 return num_failed;