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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [single.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 735 jeremybenn
/* Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc.
2
   Contributed by Richard Henderson <rth@redhat.com>.
3
 
4
   This file is part of the GNU OpenMP Library (libgomp).
5
 
6
   Libgomp is free software; you can redistribute it and/or modify it
7
   under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
 
11
   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
   more details.
15
 
16
   Under Section 7 of GPL version 3, you are granted additional
17
   permissions described in the GCC Runtime Library Exception, version
18
   3.1, as published by the Free Software Foundation.
19
 
20
   You should have received a copy of the GNU General Public License and
21
   a copy of the GCC Runtime Library Exception along with this program;
22
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
   <http://www.gnu.org/licenses/>.  */
24
 
25
/* This file handles the SINGLE construct.  */
26
 
27
#include "libgomp.h"
28
 
29
 
30
/* This routine is called when first encountering a SINGLE construct that
31
   doesn't have a COPYPRIVATE clause.  Returns true if this is the thread
32
   that should execute the clause.  */
33
 
34
bool
35
GOMP_single_start (void)
36
{
37
#ifdef HAVE_SYNC_BUILTINS
38
  struct gomp_thread *thr = gomp_thread ();
39
  struct gomp_team *team = thr->ts.team;
40
  unsigned long single_count;
41
 
42
  if (__builtin_expect (team == NULL, 0))
43
    return true;
44
 
45
  single_count = thr->ts.single_count++;
46
  return __sync_bool_compare_and_swap (&team->single_count, single_count,
47
                                       single_count + 1L);
48
#else
49
  bool ret = gomp_work_share_start (false);
50
  if (ret)
51
    gomp_work_share_init_done ();
52
  gomp_work_share_end_nowait ();
53
  return ret;
54
#endif
55
}
56
 
57
/* This routine is called when first encountering a SINGLE construct that
58
   does have a COPYPRIVATE clause.  Returns NULL if this is the thread
59
   that should execute the clause; otherwise the return value is pointer
60
   given to GOMP_single_copy_end by the thread that did execute the clause.  */
61
 
62
void *
63
GOMP_single_copy_start (void)
64
{
65
  struct gomp_thread *thr = gomp_thread ();
66
 
67
  bool first;
68
  void *ret;
69
 
70
  first = gomp_work_share_start (false);
71
 
72
  if (first)
73
    {
74
      gomp_work_share_init_done ();
75
      ret = NULL;
76
    }
77
  else
78
    {
79
      gomp_team_barrier_wait (&thr->ts.team->barrier);
80
 
81
      ret = thr->ts.work_share->copyprivate;
82
      gomp_work_share_end_nowait ();
83
    }
84
 
85
  return ret;
86
}
87
 
88
/* This routine is called when the thread that entered a SINGLE construct
89
   with a COPYPRIVATE clause gets to the end of the construct.  */
90
 
91
void
92
GOMP_single_copy_end (void *data)
93
{
94
  struct gomp_thread *thr = gomp_thread ();
95
  struct gomp_team *team = thr->ts.team;
96
 
97
  if (team != NULL)
98
    {
99
      thr->ts.work_share->copyprivate = data;
100
      gomp_team_barrier_wait (&team->barrier);
101
    }
102
 
103
  gomp_work_share_end_nowait ();
104
}

powered by: WebSVN 2.1.0

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