OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [testsuite/] [libgomp.c/] [barrier-1.c] - Blame information for rev 791

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 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.