blob: 8b4728efee1a30bfd94c06f3110cd993cf108405 [file] [log] [blame]
Jonathan Peyton614c7ef2015-09-21 20:41:31 +00001// RUN: %libomp-compile-and-run
2#include <stdio.h>
3#include <math.h>
4#include "omp_testsuite.h"
5#include "omp_my_sleep.h"
6
7int test_omp_task_if()
8{
9 int condition_false;
10 int count;
11 int result;
12
13 count=0;
14 condition_false = (count == 1);
Jonathan Peyton37310762016-05-17 21:08:52 +000015 #pragma omp parallel
Jonathan Peyton614c7ef2015-09-21 20:41:31 +000016 {
17 #pragma omp single
18 {
19 #pragma omp task if (condition_false) shared(count, result)
20 {
21 my_sleep (SLEEPTIME);
22 #pragma omp critical
23 result = (0 == count);
24 } /* end of omp task */
25 #pragma omp critical
26 count = 1;
27 } /* end of single */
28 } /*end of parallel */
29 return result;
30}
31
32int main()
33{
34 int i;
35 int num_failed=0;
36
37 for(i = 0; i < REPETITIONS; i++) {
38 if(!test_omp_task_if()) {
39 num_failed++;
40 }
41 }
42 return num_failed;
43}