blob: df669e2c11e6ebe8ef60aeb16cde738f451fcefc [file] [log] [blame]
Jim Cownie18d84732014-05-10 17:02:09 +00001<ompts:test>
Alp Tokerc2d5e612014-06-01 18:28:36 +00002<ompts:testdescription>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.</ompts:testdescription>
Jim Cownie18d84732014-05-10 17:02:09 +00003<ompts:ompversion>2.0</ompts:ompversion>
4<ompts:directive>omp barrier</ompts:directive>
5<ompts:testcode>
6#include <stdio.h>
7#include <unistd.h>
8
9#include "omp_testsuite.h"
10#include "omp_my_sleep.h"
11
12int <ompts:testcode:functionname>omp_barrier</ompts:testcode:functionname> (FILE * logFile)
13{
14 <ompts:orphan:vars>
15 int result1;
16 int result2;
17 </ompts:orphan:vars>
18
19 result1 = 0;
20 result2 = 0;
21
22#pragma omp parallel
23 {
24 <ompts:orphan>
25 int rank;
26 rank = omp_get_thread_num ();
27 if (rank ==1) {
28 my_sleep(SLEEPTIME_LONG);
29 result2 = 3;
30 }
31<ompts:check>#pragma omp barrier</ompts:check>
32 if (rank == 2) {
33 result1 = result2;
34 }
35 </ompts:orphan>
36 }
37 printf("result1=%d\n",result1);
38 return (result1 == 3);
39}
40</ompts:testcode>
41</ompts:test>