![]() |
![]() |
OpenMP Runtime
|
00001 /* Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc. 00002 Contributed by Richard Henderson <rth@redhat.com>. 00003 00004 This file is part of the GNU OpenMP Library (libgomp). 00005 00006 Libgomp is free software; you can redistribute it and/or modify it 00007 under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3, or (at your option) 00009 any later version. 00010 00011 Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY 00012 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00013 FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00014 more details. 00015 00016 Under Section 7 of GPL version 3, you are granted additional 00017 permissions described in the GCC Runtime Library Exception, version 00018 3.1, as published by the Free Software Foundation. 00019 00020 You should have received a copy of the GNU General Public License and 00021 a copy of the GCC Runtime Library Exception along with this program; 00022 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 <http://www.gnu.org/licenses/>. */ 00024 00025 /* Copyright (C) 2012 00026 Texas Instruments, Inc. 00027 00028 Changes from original: 00029 - Workshare related structures from original libgomp.h 00030 */ 00031 00047 #ifndef LIBGOMP_H 00048 #define LIBGOMP_H 1 00049 00050 #include "gomp_ptrlock.h" 00051 #include <stdbool.h> /* for bool, false, true */ 00052 #include "tomp_defs.h" /* for TOMP_DEVICE_NUM_CORES */ 00053 #include "tomp_qmss.h" /* for tomp_event_t */ 00054 00055 /* This structure contains the data to control one work-sharing construct, 00056 either a LOOP (FOR/DO) or a SECTIONS. */ 00057 00058 enum gomp_schedule_type 00059 { 00060 GFS_RUNTIME, 00061 GFS_STATIC, 00062 GFS_DYNAMIC, 00063 GFS_GUIDED, 00064 GFS_AUTO 00065 }; 00066 00067 struct gomp_work_share 00068 { 00069 /* This member records the SCHEDULE clause to be used for this construct. 00070 The user specification of "runtime" will already have been resolved. 00071 If this is a SECTIONS construct, this value will always be DYNAMIC. */ 00072 enum gomp_schedule_type sched; 00073 00074 /* This is the chunk_size argument to the SCHEDULE clause. */ 00075 long chunk_size; 00076 00077 /* This is the iteration end point. If this is a SECTIONS construct, 00078 this is the number of contained sections. */ 00079 long end; 00080 00081 /* This is the iteration step. If this is a SECTIONS construct, this 00082 is always 1. */ 00083 long incr; 00084 00085 /* This is a circular queue that details which threads will be allowed 00086 into the ordered region and in which order. When a thread allocates 00087 iterations on which it is going to work, it also registers itself at 00088 the end of the array. When a thread reaches the ordered region, it 00089 checks to see if it is the one at the head of the queue. If not, it 00090 blocks on its RELEASE semaphore. */ 00091 unsigned char ordered_team_ids[TOMP_DEVICE_NUM_CORES]; 00092 00093 /* This is the number of threads that have registered themselves in 00094 the circular queue ordered_team_ids. */ 00095 unsigned ordered_num_used; 00096 00097 /* This is the team_id of the currently acknowledged owner of the ordered 00098 section, or -1u if the ordered section has not been acknowledged by 00099 any thread. This is distinguished from the thread that is *allowed* 00100 to take the section next. */ 00101 unsigned ordered_owner; 00102 00103 /* This is the index into the circular queue ordered_team_ids of the 00104 current thread that's allowed into the ordered reason. */ 00105 unsigned ordered_cur; 00106 00107 /* The above fields are written once during workshare initialization, 00108 or related to ordered worksharing. Make sure the following fields 00109 are in a different cache line. */ 00110 00111 /* This lock protects the update of the following members. */ 00112 unsigned int lock; 00113 00114 /* This is the count of the number of threads that have exited the work 00115 share construct. If the construct was marked nowait, they have moved on 00116 to other work; otherwise they're blocked on a barrier. The last member 00117 of the team to exit the work share construct must deallocate it. */ 00118 unsigned threads_completed; 00119 00120 union { 00121 /* This is the next iteration value to be allocated. In the case of 00122 GFS_STATIC loops, this the iteration start point and never changes. */ 00123 long next; 00124 00125 /* This is the returned data structure for SINGLE COPYPRIVATE. */ 00126 void *copyprivate; 00127 }; 00128 00129 /* Link to gomp_work_share struct for next work sharing construct 00130 encountered after this one. */ 00131 gomp_ptrlock_t next_ws; 00132 00133 /* Event pointer to free the work share */ 00134 tomp_event_t event; 00135 }; 00136 00137 /* These are the OpenMP 3.0 Internal Control Variables described in 00138 section 2.3.1. Those described as having one copy per task are 00139 stored within the structure; those described as having one copy 00140 for the whole program are (naturally) global variables. */ 00141 00142 struct gomp_task_icv 00143 { 00144 unsigned long nthreads_var; 00145 enum gomp_schedule_type run_sched_var; 00146 int run_sched_modifier; 00147 //Removing these 00148 #if 0 00149 bool dyn_var; 00150 bool nest_var; 00151 #endif 00152 }; 00153 00154 extern struct gomp_task_icv gomp_global_icv; 00155 extern unsigned long gomp_thread_limit_var; 00156 extern unsigned long gomp_max_active_levels_var; 00157 00158 extern void initialize_env (void); 00159 00160 /* iter.c */ 00161 00162 extern int gomp_iter_static_next (long *, long *); 00163 extern bool gomp_iter_dynamic_next_locked (long *, long *); 00164 extern bool gomp_iter_guided_next_locked (long *, long *); 00165 00166 /* ordered.c */ 00167 00168 extern void gomp_ordered_first (void); 00169 extern void gomp_ordered_last (void); 00170 extern void gomp_ordered_next (void); 00171 extern void gomp_ordered_static_init (void); 00172 extern void gomp_ordered_static_next (void); 00173 extern void gomp_ordered_sync (void); 00174 00175 /* work.c */ 00176 00177 extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned); 00178 extern void gomp_fini_work_share (struct gomp_work_share *); 00179 extern bool gomp_work_share_start (bool); 00180 extern void gomp_work_share_end (void); 00181 extern void gomp_work_share_end_nowait (void); 00182 00183 extern void gomp_work_share_init_done (void); 00184 00185 #endif /* LIBGOMP_H */