OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libgomp/] [testsuite/] [libgomp.c/] [barrier-1.c] - Blame information for rev 273

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 273 jeremybenn
/* Trivial test of barrier.  */
2
 
3
#include <omp.h>
4
#include <sys/time.h>
5
#include <unistd.h>
6
#include <assert.h>
7
#include "libgomp_g.h"
8
 
9
 
10
struct timeval stamps[3][3];
11
 
12
static void function(void *dummy)
13
{
14
  int iam = omp_get_thread_num ();
15
 
16
  gettimeofday (&stamps[iam][0], NULL);
17
  if (iam == 0)
18
    usleep (10);
19
 
20
  GOMP_barrier ();
21
 
22
  if (iam == 0)
23
    {
24
      gettimeofday (&stamps[0][1], NULL);
25
      usleep (10);
26
    }
27
 
28
  GOMP_barrier ();
29
 
30
  gettimeofday (&stamps[iam][2], NULL);
31
}
32
 
33
int main()
34
{
35
  omp_set_dynamic (0);
36
 
37
  GOMP_parallel_start (function, NULL, 3);
38
  function (NULL);
39
  GOMP_parallel_end ();
40
 
41
  assert (!timercmp (&stamps[0][0], &stamps[0][1], >));
42
  assert (!timercmp (&stamps[1][0], &stamps[0][1], >));
43
  assert (!timercmp (&stamps[2][0], &stamps[0][1], >));
44
 
45
  assert (!timercmp (&stamps[0][1], &stamps[0][2], >));
46
  assert (!timercmp (&stamps[0][1], &stamps[1][2], >));
47
  assert (!timercmp (&stamps[0][1], &stamps[2][2], >));
48
 
49
  return 0;
50
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.