diff options
Diffstat (limited to 'openmp/testsuite/c/omp_parallel_if.c')
| -rw-r--r-- | openmp/testsuite/c/omp_parallel_if.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/openmp/testsuite/c/omp_parallel_if.c b/openmp/testsuite/c/omp_parallel_if.c new file mode 100644 index 00000000000..d3f45b101bd --- /dev/null +++ b/openmp/testsuite/c/omp_parallel_if.c @@ -0,0 +1,40 @@ +<ompts:test> +<ompts:testdescription>Test which checks the if option of the parallel construct.</ompts:testdescription> +<ompts:ompversion>3.0</ompts:ompversion> +<ompts:directive>omp parallel if</ompts:directive> +<ompts:testcode> +#include <stdio.h> +#include <unistd.h> + +#include "omp_testsuite.h" + +int <ompts:testcode:functionname>omp_parallel_if</ompts:testcode:functionname> (FILE * logFile) +{ +<ompts:orphan:vars> + int i; + int sum; + int known_sum; + int mysum; + int control=1; +</ompts:orphan:vars> + sum =0; + known_sum = (LOOPCOUNT * (LOOPCOUNT + 1)) / 2 ; +#pragma omp parallel private(i) <ompts:check>if(control==0)</ompts:check> + { + <ompts:orphan> + mysum = 0; + for (i = 1; i <= LOOPCOUNT; i++) + { + mysum = mysum + i; + } +#pragma omp critical + { + sum = sum + mysum; + } /* end of critical */ + </ompts:orphan> + } /* end of parallel */ + + return (known_sum == sum); +} +</ompts:testcode> +</ompts:test> |

