blob: cb3f26433005a74832ecf4fd121f4c4f27239775 [file] [log] [blame]
<ompts:testdescription>Test which checks the omp critical directive by counting up a variable in a parallelized loop within a critical section.</ompts:testdescription>
<ompts:directive>omp critical</ompts:directive>
#include <stdio.h>
#include <unistd.h>
#include "omp_testsuite.h"
#include "omp_my_sleep.h"
int <ompts:testcode:functionname>omp_critical</ompts:testcode:functionname> (FILE * logFile)
int sum;
int known_sum;
#pragma omp parallel
int mysum=0;
int i;
#pragma omp for
for (i = 0; i < 1000; i++)
mysum = mysum + i;
<ompts:check>#pragma omp critical</ompts:check>
sum = mysum +sum;
} /* end of parallel */
known_sum = 999 * 1000 / 2;
return (known_sum == sum);