Home | History | Annotate | Line # | Download | only in libgomp
libgomp.h revision 1.1
      1  1.1  mrg /* Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
      2  1.1  mrg    Contributed by Richard Henderson <rth (at) redhat.com>.
      3  1.1  mrg 
      4  1.1  mrg    This file is part of the GNU OpenMP Library (libgomp).
      5  1.1  mrg 
      6  1.1  mrg    Libgomp is free software; you can redistribute it and/or modify it
      7  1.1  mrg    under the terms of the GNU General Public License as published by
      8  1.1  mrg    the Free Software Foundation; either version 3, or (at your option)
      9  1.1  mrg    any later version.
     10  1.1  mrg 
     11  1.1  mrg    Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
     12  1.1  mrg    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     13  1.1  mrg    FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
     14  1.1  mrg    more details.
     15  1.1  mrg 
     16  1.1  mrg    Under Section 7 of GPL version 3, you are granted additional
     17  1.1  mrg    permissions described in the GCC Runtime Library Exception, version
     18  1.1  mrg    3.1, as published by the Free Software Foundation.
     19  1.1  mrg 
     20  1.1  mrg    You should have received a copy of the GNU General Public License and
     21  1.1  mrg    a copy of the GCC Runtime Library Exception along with this program;
     22  1.1  mrg    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     23  1.1  mrg    <http://www.gnu.org/licenses/>.  */
     24  1.1  mrg 
     25  1.1  mrg /* This file contains data types and function declarations that are not
     26  1.1  mrg    part of the official OpenMP user interface.  There are declarations
     27  1.1  mrg    in here that are part of the GNU OpenMP ABI, in that the compiler is
     28  1.1  mrg    required to know about them and use them.
     29  1.1  mrg 
     30  1.1  mrg    The convention is that the all caps prefix "GOMP" is used group items
     31  1.1  mrg    that are part of the external ABI, and the lower case prefix "gomp"
     32  1.1  mrg    is used group items that are completely private to the library.  */
     33  1.1  mrg 
     34  1.1  mrg #ifndef LIBGOMP_H
     35  1.1  mrg #define LIBGOMP_H 1
     36  1.1  mrg 
     37  1.1  mrg #include "config.h"
     38  1.1  mrg #include "gstdint.h"
     39  1.1  mrg 
     40  1.1  mrg #include <pthread.h>
     41  1.1  mrg #include <stdbool.h>
     42  1.1  mrg 
     43  1.1  mrg #ifdef HAVE_ATTRIBUTE_VISIBILITY
     44  1.1  mrg # pragma GCC visibility push(hidden)
     45  1.1  mrg #endif
     46  1.1  mrg 
     47  1.1  mrg #include "sem.h"
     48  1.1  mrg #include "mutex.h"
     49  1.1  mrg #include "bar.h"
     50  1.1  mrg #include "ptrlock.h"
     51  1.1  mrg 
     52  1.1  mrg 
     53  1.1  mrg /* This structure contains the data to control one work-sharing construct,
     54  1.1  mrg    either a LOOP (FOR/DO) or a SECTIONS.  */
     55  1.1  mrg 
     56  1.1  mrg enum gomp_schedule_type
     57  1.1  mrg {
     58  1.1  mrg   GFS_RUNTIME,
     59  1.1  mrg   GFS_STATIC,
     60  1.1  mrg   GFS_DYNAMIC,
     61  1.1  mrg   GFS_GUIDED,
     62  1.1  mrg   GFS_AUTO
     63  1.1  mrg };
     64  1.1  mrg 
     65  1.1  mrg struct gomp_work_share
     66  1.1  mrg {
     67  1.1  mrg   /* This member records the SCHEDULE clause to be used for this construct.
     68  1.1  mrg      The user specification of "runtime" will already have been resolved.
     69  1.1  mrg      If this is a SECTIONS construct, this value will always be DYNAMIC.  */
     70  1.1  mrg   enum gomp_schedule_type sched;
     71  1.1  mrg 
     72  1.1  mrg   int mode;
     73  1.1  mrg 
     74  1.1  mrg   union {
     75  1.1  mrg     struct {
     76  1.1  mrg       /* This is the chunk_size argument to the SCHEDULE clause.  */
     77  1.1  mrg       long chunk_size;
     78  1.1  mrg 
     79  1.1  mrg       /* This is the iteration end point.  If this is a SECTIONS construct,
     80  1.1  mrg 	 this is the number of contained sections.  */
     81  1.1  mrg       long end;
     82  1.1  mrg 
     83  1.1  mrg       /* This is the iteration step.  If this is a SECTIONS construct, this
     84  1.1  mrg 	 is always 1.  */
     85  1.1  mrg       long incr;
     86  1.1  mrg     };
     87  1.1  mrg 
     88  1.1  mrg     struct {
     89  1.1  mrg       /* The same as above, but for the unsigned long long loop variants.  */
     90  1.1  mrg       unsigned long long chunk_size_ull;
     91  1.1  mrg       unsigned long long end_ull;
     92  1.1  mrg       unsigned long long incr_ull;
     93  1.1  mrg     };
     94  1.1  mrg   };
     95  1.1  mrg 
     96  1.1  mrg   /* This is a circular queue that details which threads will be allowed
     97  1.1  mrg      into the ordered region and in which order.  When a thread allocates
     98  1.1  mrg      iterations on which it is going to work, it also registers itself at
     99  1.1  mrg      the end of the array.  When a thread reaches the ordered region, it
    100  1.1  mrg      checks to see if it is the one at the head of the queue.  If not, it
    101  1.1  mrg      blocks on its RELEASE semaphore.  */
    102  1.1  mrg   unsigned *ordered_team_ids;
    103  1.1  mrg 
    104  1.1  mrg   /* This is the number of threads that have registered themselves in
    105  1.1  mrg      the circular queue ordered_team_ids.  */
    106  1.1  mrg   unsigned ordered_num_used;
    107  1.1  mrg 
    108  1.1  mrg   /* This is the team_id of the currently acknowledged owner of the ordered
    109  1.1  mrg      section, or -1u if the ordered section has not been acknowledged by
    110  1.1  mrg      any thread.  This is distinguished from the thread that is *allowed*
    111  1.1  mrg      to take the section next.  */
    112  1.1  mrg   unsigned ordered_owner;
    113  1.1  mrg 
    114  1.1  mrg   /* This is the index into the circular queue ordered_team_ids of the
    115  1.1  mrg      current thread that's allowed into the ordered reason.  */
    116  1.1  mrg   unsigned ordered_cur;
    117  1.1  mrg 
    118  1.1  mrg   /* This is a chain of allocated gomp_work_share blocks, valid only
    119  1.1  mrg      in the first gomp_work_share struct in the block.  */
    120  1.1  mrg   struct gomp_work_share *next_alloc;
    121  1.1  mrg 
    122  1.1  mrg   /* The above fields are written once during workshare initialization,
    123  1.1  mrg      or related to ordered worksharing.  Make sure the following fields
    124  1.1  mrg      are in a different cache line.  */
    125  1.1  mrg 
    126  1.1  mrg   /* This lock protects the update of the following members.  */
    127  1.1  mrg   gomp_mutex_t lock __attribute__((aligned (64)));
    128  1.1  mrg 
    129  1.1  mrg   /* This is the count of the number of threads that have exited the work
    130  1.1  mrg      share construct.  If the construct was marked nowait, they have moved on
    131  1.1  mrg      to other work; otherwise they're blocked on a barrier.  The last member
    132  1.1  mrg      of the team to exit the work share construct must deallocate it.  */
    133  1.1  mrg   unsigned threads_completed;
    134  1.1  mrg 
    135  1.1  mrg   union {
    136  1.1  mrg     /* This is the next iteration value to be allocated.  In the case of
    137  1.1  mrg        GFS_STATIC loops, this the iteration start point and never changes.  */
    138  1.1  mrg     long next;
    139  1.1  mrg 
    140  1.1  mrg     /* The same, but with unsigned long long type.  */
    141  1.1  mrg     unsigned long long next_ull;
    142  1.1  mrg 
    143  1.1  mrg     /* This is the returned data structure for SINGLE COPYPRIVATE.  */
    144  1.1  mrg     void *copyprivate;
    145  1.1  mrg   };
    146  1.1  mrg 
    147  1.1  mrg   union {
    148  1.1  mrg     /* Link to gomp_work_share struct for next work sharing construct
    149  1.1  mrg        encountered after this one.  */
    150  1.1  mrg     gomp_ptrlock_t next_ws;
    151  1.1  mrg 
    152  1.1  mrg     /* gomp_work_share structs are chained in the free work share cache
    153  1.1  mrg        through this.  */
    154  1.1  mrg     struct gomp_work_share *next_free;
    155  1.1  mrg   };
    156  1.1  mrg 
    157  1.1  mrg   /* If only few threads are in the team, ordered_team_ids can point
    158  1.1  mrg      to this array which fills the padding at the end of this struct.  */
    159  1.1  mrg   unsigned inline_ordered_team_ids[0];
    160  1.1  mrg };
    161  1.1  mrg 
    162  1.1  mrg /* This structure contains all of the thread-local data associated with
    163  1.1  mrg    a thread team.  This is the data that must be saved when a thread
    164  1.1  mrg    encounters a nested PARALLEL construct.  */
    165  1.1  mrg 
    166  1.1  mrg struct gomp_team_state
    167  1.1  mrg {
    168  1.1  mrg   /* This is the team of which the thread is currently a member.  */
    169  1.1  mrg   struct gomp_team *team;
    170  1.1  mrg 
    171  1.1  mrg   /* This is the work share construct which this thread is currently
    172  1.1  mrg      processing.  Recall that with NOWAIT, not all threads may be
    173  1.1  mrg      processing the same construct.  */
    174  1.1  mrg   struct gomp_work_share *work_share;
    175  1.1  mrg 
    176  1.1  mrg   /* This is the previous work share construct or NULL if there wasn't any.
    177  1.1  mrg      When all threads are done with the current work sharing construct,
    178  1.1  mrg      the previous one can be freed.  The current one can't, as its
    179  1.1  mrg      next_ws field is used.  */
    180  1.1  mrg   struct gomp_work_share *last_work_share;
    181  1.1  mrg 
    182  1.1  mrg   /* This is the ID of this thread within the team.  This value is
    183  1.1  mrg      guaranteed to be between 0 and N-1, where N is the number of
    184  1.1  mrg      threads in the team.  */
    185  1.1  mrg   unsigned team_id;
    186  1.1  mrg 
    187  1.1  mrg   /* Nesting level.  */
    188  1.1  mrg   unsigned level;
    189  1.1  mrg 
    190  1.1  mrg   /* Active nesting level.  Only active parallel regions are counted.  */
    191  1.1  mrg   unsigned active_level;
    192  1.1  mrg 
    193  1.1  mrg #ifdef HAVE_SYNC_BUILTINS
    194  1.1  mrg   /* Number of single stmts encountered.  */
    195  1.1  mrg   unsigned long single_count;
    196  1.1  mrg #endif
    197  1.1  mrg 
    198  1.1  mrg   /* For GFS_RUNTIME loops that resolved to GFS_STATIC, this is the
    199  1.1  mrg      trip number through the loop.  So first time a particular loop
    200  1.1  mrg      is encountered this number is 0, the second time through the loop
    201  1.1  mrg      is 1, etc.  This is unused when the compiler knows in advance that
    202  1.1  mrg      the loop is statically scheduled.  */
    203  1.1  mrg   unsigned long static_trip;
    204  1.1  mrg };
    205  1.1  mrg 
    206  1.1  mrg /* These are the OpenMP 3.0 Internal Control Variables described in
    207  1.1  mrg    section 2.3.1.  Those described as having one copy per task are
    208  1.1  mrg    stored within the structure; those described as having one copy
    209  1.1  mrg    for the whole program are (naturally) global variables.  */
    210  1.1  mrg 
    211  1.1  mrg struct gomp_task_icv
    212  1.1  mrg {
    213  1.1  mrg   unsigned long nthreads_var;
    214  1.1  mrg   enum gomp_schedule_type run_sched_var;
    215  1.1  mrg   int run_sched_modifier;
    216  1.1  mrg   bool dyn_var;
    217  1.1  mrg   bool nest_var;
    218  1.1  mrg };
    219  1.1  mrg 
    220  1.1  mrg extern struct gomp_task_icv gomp_global_icv;
    221  1.1  mrg extern unsigned long gomp_thread_limit_var;
    222  1.1  mrg extern unsigned long gomp_remaining_threads_count;
    223  1.1  mrg #ifndef HAVE_SYNC_BUILTINS
    224  1.1  mrg extern gomp_mutex_t gomp_remaining_threads_lock;
    225  1.1  mrg #endif
    226  1.1  mrg extern unsigned long gomp_max_active_levels_var;
    227  1.1  mrg extern unsigned long long gomp_spin_count_var, gomp_throttled_spin_count_var;
    228  1.1  mrg extern unsigned long gomp_available_cpus, gomp_managed_threads;
    229  1.1  mrg 
    230  1.1  mrg enum gomp_task_kind
    231  1.1  mrg {
    232  1.1  mrg   GOMP_TASK_IMPLICIT,
    233  1.1  mrg   GOMP_TASK_IFFALSE,
    234  1.1  mrg   GOMP_TASK_WAITING,
    235  1.1  mrg   GOMP_TASK_TIED
    236  1.1  mrg };
    237  1.1  mrg 
    238  1.1  mrg /* This structure describes a "task" to be run by a thread.  */
    239  1.1  mrg 
    240  1.1  mrg struct gomp_task
    241  1.1  mrg {
    242  1.1  mrg   struct gomp_task *parent;
    243  1.1  mrg   struct gomp_task *children;
    244  1.1  mrg   struct gomp_task *next_child;
    245  1.1  mrg   struct gomp_task *prev_child;
    246  1.1  mrg   struct gomp_task *next_queue;
    247  1.1  mrg   struct gomp_task *prev_queue;
    248  1.1  mrg   struct gomp_task_icv icv;
    249  1.1  mrg   void (*fn) (void *);
    250  1.1  mrg   void *fn_data;
    251  1.1  mrg   enum gomp_task_kind kind;
    252  1.1  mrg   bool in_taskwait;
    253  1.1  mrg   bool in_tied_task;
    254  1.1  mrg   gomp_sem_t taskwait_sem;
    255  1.1  mrg };
    256  1.1  mrg 
    257  1.1  mrg /* This structure describes a "team" of threads.  These are the threads
    258  1.1  mrg    that are spawned by a PARALLEL constructs, as well as the work sharing
    259  1.1  mrg    constructs that the team encounters.  */
    260  1.1  mrg 
    261  1.1  mrg struct gomp_team
    262  1.1  mrg {
    263  1.1  mrg   /* This is the number of threads in the current team.  */
    264  1.1  mrg   unsigned nthreads;
    265  1.1  mrg 
    266  1.1  mrg   /* This is number of gomp_work_share structs that have been allocated
    267  1.1  mrg      as a block last time.  */
    268  1.1  mrg   unsigned work_share_chunk;
    269  1.1  mrg 
    270  1.1  mrg   /* This is the saved team state that applied to a master thread before
    271  1.1  mrg      the current thread was created.  */
    272  1.1  mrg   struct gomp_team_state prev_ts;
    273  1.1  mrg 
    274  1.1  mrg   /* This semaphore should be used by the master thread instead of its
    275  1.1  mrg      "native" semaphore in the thread structure.  Required for nested
    276  1.1  mrg      parallels, as the master is a member of two teams.  */
    277  1.1  mrg   gomp_sem_t master_release;
    278  1.1  mrg 
    279  1.1  mrg   /* This points to an array with pointers to the release semaphore
    280  1.1  mrg      of the threads in the team.  */
    281  1.1  mrg   gomp_sem_t **ordered_release;
    282  1.1  mrg 
    283  1.1  mrg   /* List of gomp_work_share structs chained through next_free fields.
    284  1.1  mrg      This is populated and taken off only by the first thread in the
    285  1.1  mrg      team encountering a new work sharing construct, in a critical
    286  1.1  mrg      section.  */
    287  1.1  mrg   struct gomp_work_share *work_share_list_alloc;
    288  1.1  mrg 
    289  1.1  mrg   /* List of gomp_work_share structs freed by free_work_share.  New
    290  1.1  mrg      entries are atomically added to the start of the list, and
    291  1.1  mrg      alloc_work_share can safely only move all but the first entry
    292  1.1  mrg      to work_share_list alloc, as free_work_share can happen concurrently
    293  1.1  mrg      with alloc_work_share.  */
    294  1.1  mrg   struct gomp_work_share *work_share_list_free;
    295  1.1  mrg 
    296  1.1  mrg #ifdef HAVE_SYNC_BUILTINS
    297  1.1  mrg   /* Number of simple single regions encountered by threads in this
    298  1.1  mrg      team.  */
    299  1.1  mrg   unsigned long single_count;
    300  1.1  mrg #else
    301  1.1  mrg   /* Mutex protecting addition of workshares to work_share_list_free.  */
    302  1.1  mrg   gomp_mutex_t work_share_list_free_lock;
    303  1.1  mrg #endif
    304  1.1  mrg 
    305  1.1  mrg   /* This barrier is used for most synchronization of the team.  */
    306  1.1  mrg   gomp_barrier_t barrier;
    307  1.1  mrg 
    308  1.1  mrg   /* Initial work shares, to avoid allocating any gomp_work_share
    309  1.1  mrg      structs in the common case.  */
    310  1.1  mrg   struct gomp_work_share work_shares[8];
    311  1.1  mrg 
    312  1.1  mrg   gomp_mutex_t task_lock;
    313  1.1  mrg   struct gomp_task *task_queue;
    314  1.1  mrg   int task_count;
    315  1.1  mrg   int task_running_count;
    316  1.1  mrg 
    317  1.1  mrg   /* This array contains structures for implicit tasks.  */
    318  1.1  mrg   struct gomp_task implicit_task[];
    319  1.1  mrg };
    320  1.1  mrg 
    321  1.1  mrg /* This structure contains all data that is private to libgomp and is
    322  1.1  mrg    allocated per thread.  */
    323  1.1  mrg 
    324  1.1  mrg struct gomp_thread
    325  1.1  mrg {
    326  1.1  mrg   /* This is the function that the thread should run upon launch.  */
    327  1.1  mrg   void (*fn) (void *data);
    328  1.1  mrg   void *data;
    329  1.1  mrg 
    330  1.1  mrg   /* This is the current team state for this thread.  The ts.team member
    331  1.1  mrg      is NULL only if the thread is idle.  */
    332  1.1  mrg   struct gomp_team_state ts;
    333  1.1  mrg 
    334  1.1  mrg   /* This is the task that the thread is currently executing.  */
    335  1.1  mrg   struct gomp_task *task;
    336  1.1  mrg 
    337  1.1  mrg   /* This semaphore is used for ordered loops.  */
    338  1.1  mrg   gomp_sem_t release;
    339  1.1  mrg 
    340  1.1  mrg   /* user pthread thread pool */
    341  1.1  mrg   struct gomp_thread_pool *thread_pool;
    342  1.1  mrg };
    343  1.1  mrg 
    344  1.1  mrg 
    345  1.1  mrg struct gomp_thread_pool
    346  1.1  mrg {
    347  1.1  mrg   /* This array manages threads spawned from the top level, which will
    348  1.1  mrg      return to the idle loop once the current PARALLEL construct ends.  */
    349  1.1  mrg   struct gomp_thread **threads;
    350  1.1  mrg   unsigned threads_size;
    351  1.1  mrg   unsigned threads_used;
    352  1.1  mrg   struct gomp_team *last_team;
    353  1.1  mrg 
    354  1.1  mrg   /* This barrier holds and releases threads waiting in threads.  */
    355  1.1  mrg   gomp_barrier_t threads_dock;
    356  1.1  mrg };
    357  1.1  mrg 
    358  1.1  mrg /* ... and here is that TLS data.  */
    359  1.1  mrg 
    360  1.1  mrg #ifdef HAVE_TLS
    361  1.1  mrg extern __thread struct gomp_thread gomp_tls_data;
    362  1.1  mrg static inline struct gomp_thread *gomp_thread (void)
    363  1.1  mrg {
    364  1.1  mrg   return &gomp_tls_data;
    365  1.1  mrg }
    366  1.1  mrg #else
    367  1.1  mrg extern pthread_key_t gomp_tls_key;
    368  1.1  mrg static inline struct gomp_thread *gomp_thread (void)
    369  1.1  mrg {
    370  1.1  mrg   return pthread_getspecific (gomp_tls_key);
    371  1.1  mrg }
    372  1.1  mrg #endif
    373  1.1  mrg 
    374  1.1  mrg extern struct gomp_task_icv *gomp_new_icv (void);
    375  1.1  mrg 
    376  1.1  mrg /* Here's how to access the current copy of the ICVs.  */
    377  1.1  mrg 
    378  1.1  mrg static inline struct gomp_task_icv *gomp_icv (bool write)
    379  1.1  mrg {
    380  1.1  mrg   struct gomp_task *task = gomp_thread ()->task;
    381  1.1  mrg   if (task)
    382  1.1  mrg     return &task->icv;
    383  1.1  mrg   else if (write)
    384  1.1  mrg     return gomp_new_icv ();
    385  1.1  mrg   else
    386  1.1  mrg     return &gomp_global_icv;
    387  1.1  mrg }
    388  1.1  mrg 
    389  1.1  mrg /* The attributes to be used during thread creation.  */
    390  1.1  mrg extern pthread_attr_t gomp_thread_attr;
    391  1.1  mrg 
    392  1.1  mrg /* Other variables.  */
    393  1.1  mrg 
    394  1.1  mrg extern unsigned short *gomp_cpu_affinity;
    395  1.1  mrg extern size_t gomp_cpu_affinity_len;
    396  1.1  mrg 
    397  1.1  mrg /* Function prototypes.  */
    398  1.1  mrg 
    399  1.1  mrg /* affinity.c */
    400  1.1  mrg 
    401  1.1  mrg extern void gomp_init_affinity (void);
    402  1.1  mrg extern void gomp_init_thread_affinity (pthread_attr_t *);
    403  1.1  mrg 
    404  1.1  mrg /* alloc.c */
    405  1.1  mrg 
    406  1.1  mrg extern void *gomp_malloc (size_t) __attribute__((malloc));
    407  1.1  mrg extern void *gomp_malloc_cleared (size_t) __attribute__((malloc));
    408  1.1  mrg extern void *gomp_realloc (void *, size_t);
    409  1.1  mrg 
    410  1.1  mrg /* Avoid conflicting prototypes of alloca() in system headers by using
    411  1.1  mrg    GCC's builtin alloca().  */
    412  1.1  mrg #define gomp_alloca(x)  __builtin_alloca(x)
    413  1.1  mrg 
    414  1.1  mrg /* error.c */
    415  1.1  mrg 
    416  1.1  mrg extern void gomp_error (const char *, ...)
    417  1.1  mrg 	__attribute__((format (printf, 1, 2)));
    418  1.1  mrg extern void gomp_fatal (const char *, ...)
    419  1.1  mrg 	__attribute__((noreturn, format (printf, 1, 2)));
    420  1.1  mrg 
    421  1.1  mrg /* iter.c */
    422  1.1  mrg 
    423  1.1  mrg extern int gomp_iter_static_next (long *, long *);
    424  1.1  mrg extern bool gomp_iter_dynamic_next_locked (long *, long *);
    425  1.1  mrg extern bool gomp_iter_guided_next_locked (long *, long *);
    426  1.1  mrg 
    427  1.1  mrg #ifdef HAVE_SYNC_BUILTINS
    428  1.1  mrg extern bool gomp_iter_dynamic_next (long *, long *);
    429  1.1  mrg extern bool gomp_iter_guided_next (long *, long *);
    430  1.1  mrg #endif
    431  1.1  mrg 
    432  1.1  mrg /* iter_ull.c */
    433  1.1  mrg 
    434  1.1  mrg extern int gomp_iter_ull_static_next (unsigned long long *,
    435  1.1  mrg 				      unsigned long long *);
    436  1.1  mrg extern bool gomp_iter_ull_dynamic_next_locked (unsigned long long *,
    437  1.1  mrg 					       unsigned long long *);
    438  1.1  mrg extern bool gomp_iter_ull_guided_next_locked (unsigned long long *,
    439  1.1  mrg 					      unsigned long long *);
    440  1.1  mrg 
    441  1.1  mrg #if defined HAVE_SYNC_BUILTINS && defined __LP64__
    442  1.1  mrg extern bool gomp_iter_ull_dynamic_next (unsigned long long *,
    443  1.1  mrg 					unsigned long long *);
    444  1.1  mrg extern bool gomp_iter_ull_guided_next (unsigned long long *,
    445  1.1  mrg 				       unsigned long long *);
    446  1.1  mrg #endif
    447  1.1  mrg 
    448  1.1  mrg /* ordered.c */
    449  1.1  mrg 
    450  1.1  mrg extern void gomp_ordered_first (void);
    451  1.1  mrg extern void gomp_ordered_last (void);
    452  1.1  mrg extern void gomp_ordered_next (void);
    453  1.1  mrg extern void gomp_ordered_static_init (void);
    454  1.1  mrg extern void gomp_ordered_static_next (void);
    455  1.1  mrg extern void gomp_ordered_sync (void);
    456  1.1  mrg 
    457  1.1  mrg /* parallel.c */
    458  1.1  mrg 
    459  1.1  mrg extern unsigned gomp_resolve_num_threads (unsigned, unsigned);
    460  1.1  mrg 
    461  1.1  mrg /* proc.c (in config/) */
    462  1.1  mrg 
    463  1.1  mrg extern void gomp_init_num_threads (void);
    464  1.1  mrg extern unsigned gomp_dynamic_max_threads (void);
    465  1.1  mrg 
    466  1.1  mrg /* task.c */
    467  1.1  mrg 
    468  1.1  mrg extern void gomp_init_task (struct gomp_task *, struct gomp_task *,
    469  1.1  mrg 			    struct gomp_task_icv *);
    470  1.1  mrg extern void gomp_end_task (void);
    471  1.1  mrg extern void gomp_barrier_handle_tasks (gomp_barrier_state_t);
    472  1.1  mrg 
    473  1.1  mrg static void inline
    474  1.1  mrg gomp_finish_task (struct gomp_task *task)
    475  1.1  mrg {
    476  1.1  mrg   gomp_sem_destroy (&task->taskwait_sem);
    477  1.1  mrg }
    478  1.1  mrg 
    479  1.1  mrg /* team.c */
    480  1.1  mrg 
    481  1.1  mrg extern struct gomp_team *gomp_new_team (unsigned);
    482  1.1  mrg extern void gomp_team_start (void (*) (void *), void *, unsigned,
    483  1.1  mrg 			     struct gomp_team *);
    484  1.1  mrg extern void gomp_team_end (void);
    485  1.1  mrg 
    486  1.1  mrg /* work.c */
    487  1.1  mrg 
    488  1.1  mrg extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned);
    489  1.1  mrg extern void gomp_fini_work_share (struct gomp_work_share *);
    490  1.1  mrg extern bool gomp_work_share_start (bool);
    491  1.1  mrg extern void gomp_work_share_end (void);
    492  1.1  mrg extern void gomp_work_share_end_nowait (void);
    493  1.1  mrg 
    494  1.1  mrg static inline void
    495  1.1  mrg gomp_work_share_init_done (void)
    496  1.1  mrg {
    497  1.1  mrg   struct gomp_thread *thr = gomp_thread ();
    498  1.1  mrg   if (__builtin_expect (thr->ts.last_work_share != NULL, 1))
    499  1.1  mrg     gomp_ptrlock_set (&thr->ts.last_work_share->next_ws, thr->ts.work_share);
    500  1.1  mrg }
    501  1.1  mrg 
    502  1.1  mrg #ifdef HAVE_ATTRIBUTE_VISIBILITY
    503  1.1  mrg # pragma GCC visibility pop
    504  1.1  mrg #endif
    505  1.1  mrg 
    506  1.1  mrg /* Now that we're back to default visibility, include the globals.  */
    507  1.1  mrg #include "libgomp_g.h"
    508  1.1  mrg 
    509  1.1  mrg /* Include omp.h by parts.  */
    510  1.1  mrg #include "omp-lock.h"
    511  1.1  mrg #define _LIBGOMP_OMP_LOCK_DEFINED 1
    512  1.1  mrg #include "omp.h.in"
    513  1.1  mrg 
    514  1.1  mrg #if !defined (HAVE_ATTRIBUTE_VISIBILITY) \
    515  1.1  mrg     || !defined (HAVE_ATTRIBUTE_ALIAS) \
    516  1.1  mrg     || !defined (HAVE_AS_SYMVER_DIRECTIVE) \
    517  1.1  mrg     || !defined (PIC)
    518  1.1  mrg # undef LIBGOMP_GNU_SYMBOL_VERSIONING
    519  1.1  mrg #endif
    520  1.1  mrg 
    521  1.1  mrg #ifdef LIBGOMP_GNU_SYMBOL_VERSIONING
    522  1.1  mrg extern void gomp_init_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
    523  1.1  mrg extern void gomp_destroy_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
    524  1.1  mrg extern void gomp_set_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
    525  1.1  mrg extern void gomp_unset_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
    526  1.1  mrg extern int gomp_test_lock_30 (omp_lock_t *) __GOMP_NOTHROW;
    527  1.1  mrg extern void gomp_init_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
    528  1.1  mrg extern void gomp_destroy_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
    529  1.1  mrg extern void gomp_set_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
    530  1.1  mrg extern void gomp_unset_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
    531  1.1  mrg extern int gomp_test_nest_lock_30 (omp_nest_lock_t *) __GOMP_NOTHROW;
    532  1.1  mrg 
    533  1.1  mrg extern void gomp_init_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
    534  1.1  mrg extern void gomp_destroy_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
    535  1.1  mrg extern void gomp_set_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
    536  1.1  mrg extern void gomp_unset_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
    537  1.1  mrg extern int gomp_test_lock_25 (omp_lock_25_t *) __GOMP_NOTHROW;
    538  1.1  mrg extern void gomp_init_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
    539  1.1  mrg extern void gomp_destroy_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
    540  1.1  mrg extern void gomp_set_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
    541  1.1  mrg extern void gomp_unset_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
    542  1.1  mrg extern int gomp_test_nest_lock_25 (omp_nest_lock_25_t *) __GOMP_NOTHROW;
    543  1.1  mrg 
    544  1.1  mrg # define strong_alias(fn, al) \
    545  1.1  mrg   extern __typeof (fn) al __attribute__ ((alias (#fn)));
    546  1.1  mrg # define omp_lock_symver(fn) \
    547  1.1  mrg   __asm (".symver g" #fn "_30, " #fn "@@OMP_3.0"); \
    548  1.1  mrg   __asm (".symver g" #fn "_25, " #fn "@OMP_1.0");
    549  1.1  mrg #else
    550  1.1  mrg # define gomp_init_lock_30 omp_init_lock
    551  1.1  mrg # define gomp_destroy_lock_30 omp_destroy_lock
    552  1.1  mrg # define gomp_set_lock_30 omp_set_lock
    553  1.1  mrg # define gomp_unset_lock_30 omp_unset_lock
    554  1.1  mrg # define gomp_test_lock_30 omp_test_lock
    555  1.1  mrg # define gomp_init_nest_lock_30 omp_init_nest_lock
    556  1.1  mrg # define gomp_destroy_nest_lock_30 omp_destroy_nest_lock
    557  1.1  mrg # define gomp_set_nest_lock_30 omp_set_nest_lock
    558  1.1  mrg # define gomp_unset_nest_lock_30 omp_unset_nest_lock
    559  1.1  mrg # define gomp_test_nest_lock_30 omp_test_nest_lock
    560  1.1  mrg #endif
    561  1.1  mrg 
    562  1.1  mrg #ifdef HAVE_ATTRIBUTE_VISIBILITY
    563  1.1  mrg # define attribute_hidden __attribute__ ((visibility ("hidden")))
    564  1.1  mrg #else
    565  1.1  mrg # define attribute_hidden
    566  1.1  mrg #endif
    567  1.1  mrg 
    568  1.1  mrg #ifdef HAVE_ATTRIBUTE_ALIAS
    569  1.1  mrg # define ialias(fn) \
    570  1.1  mrg   extern __typeof (fn) gomp_ialias_##fn \
    571  1.1  mrg     __attribute__ ((alias (#fn))) attribute_hidden;
    572  1.1  mrg #else
    573  1.1  mrg # define ialias(fn)
    574  1.1  mrg #endif
    575  1.1  mrg 
    576  1.1  mrg #endif /* LIBGOMP_H */
    577