Test which checks the omp barrier directive. The test creates several threads and sends one of them sleeping before setting a flag. After the barrier the other ones do some little work depending on the flag.
2.0
omp barrier
#include
#include
#include "omp_testsuite.h"
#include "omp_my_sleep.h"
int omp_barrier (FILE * logFile)
{
int result1;
int result2;
result1 = 0;
result2 = 0;
#pragma omp parallel
{
int rank;
rank = omp_get_thread_num ();
if (rank ==1) {
my_sleep(SLEEPTIME_LONG);
result2 = 3;
}
#pragma omp barrier
if (rank == 2) {
result1 = result2;
}
}
printf("result1=%d\n",result1);
return (result1 == 3);
}