![]() |
![]() |
OpenMP Runtime
|
00001 /* 00002 * Copyright (c) 2013, Texas Instruments Incorporated - http://www.ti.com/ 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of Texas Instruments Incorporated nor the 00013 * names of its contributors may be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00020 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00021 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00022 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00023 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00024 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00025 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00026 * POSSIBILITY OF SUCH DAMAGE. 00027 */ 00035 #ifndef TOMP_PARALLEL_H_ 00036 #define TOMP_PARALLEL_H_ 00037 00038 #include "tomp_defs.h" 00039 #include "tomp_init.h" 00040 #include "tomp_util.h" 00041 #include "tomp_qmss.h" 00042 #include "gomp_libgomp.h" 00043 #include "ulm_wrapper.h" 00044 00046 typedef void (*tomp_OutlinedFunc) (void*); 00047 00054 typedef struct _tomp_Team 00055 { 00057 unsigned int nthreads; 00058 00060 tomp_Barrier barrier; 00061 00063 volatile unsigned int task_count; 00064 00066 volatile unsigned int curr_task_id; 00067 00071 struct gomp_work_share dummy_ws; 00072 00074 volatile unsigned char ordered_release[TOMP_DEVICE_NUM_CORES]; 00075 00076 unsigned int DP; 00077 00079 tomp_event_t event; 00080 00082 // parent team. 00083 struct _tomp_TeamState *prev_ts; 00084 00085 } tomp_Team; 00086 00090 typedef struct _tomp_TeamState 00091 { 00093 tomp_Team *team; 00094 00097 int team_id; 00098 00100 struct gomp_work_share *work_share; 00101 00103 struct gomp_work_share *last_work_share; 00104 00106 unsigned long static_trip; 00107 00109 tomp_event_t event; 00110 00112 int level; 00113 00114 } tomp_TeamState; 00115 00116 00118 typedef enum { tomp_TaskStealing_DISABLED = 0, 00119 tomp_TaskSteaking_ENABLED 00120 } tomp_TaskStealing_e; 00121 00122 00129 typedef struct _tomp_Thread 00130 { 00132 tomp_TeamState *ts; 00133 00135 struct _tomp_Task *current_task; 00136 00138 tomp_TaskStealing_e task_stealing; 00139 } tomp_Thread; 00140 00141 00143 typedef enum { tomp_TaskKind_IMPLICIT = 0, 00144 tomp_TaskKind_DEFERRED, 00145 tomp_TaskKind_INCLUDED 00146 } tomp_TaskKind_e; 00147 00148 00154 typedef struct _tomp_Task 00155 { 00157 tomp_OutlinedFunc entry_func; 00158 00160 void* arg_buffer; 00161 00163 tomp_Team *team; 00164 00166 int teamMember; 00167 00169 struct _tomp_Task *parent; 00170 00172 volatile int children_count; 00173 00175 unsigned short id; 00176 00178 volatile unsigned char completed_execution; 00179 00181 unsigned char arg_buffer_in_task; 00182 00184 unsigned char kind; 00185 00187 void *tls_block; 00188 00190 tomp_event_t event; 00191 00193 struct gomp_task_icv icv; 00194 } tomp_Task; 00195 00196 00197 extern tomp_Thread tomp_thread; 00198 extern void* __TI_tls_currentTP; 00199 extern uint32_t tomp_threadNum; 00200 00201 extern tomp_event_t tomp_eventHdlTbl[TOMP_DEVICE_NUM_CORES - 1]; 00202 extern tomp_Task* tomp_taskPtrTbl[TOMP_DEVICE_NUM_CORES - 1]; 00203 00204 extern tomp_Task* tomp_initialTaskForMaster; 00205 extern tomp_Task* tomp_implicitTaskForMaster; 00206 00207 extern void tomp_eoStartLoopX(tomp_event_t event); 00208 extern void tomp_eoStartTaskX(tomp_event_t event); 00209 00210 tomp_Team* tomp_initialize_team(unsigned int num_threads); 00211 void tomp_start_team(tomp_Team *ts, void (*fn) (void *), unsigned char *data); 00212 00213 tomp_TeamState* tomp_alloc_TeamState(); 00214 00222 static inline void tomp_clear_TeamState(tomp_TeamState *ts) 00223 { 00224 ts->team = NULL; 00225 ts->work_share = NULL; 00226 ts->last_work_share = NULL; 00227 ts->static_trip = 0; 00228 } 00229 00230 00234 static inline void tomp_taskInit(tomp_Task *task, tomp_TaskKind_e kind, 00235 tomp_Task *parent, tomp_Team *team) 00236 { 00237 task->id = 0; 00238 task->kind = kind; 00239 task->entry_func = NULL; 00240 task->arg_buffer = NULL; 00241 task->arg_buffer_in_task = false; 00242 task->team = team; 00243 task->teamMember = (kind == tomp_TaskKind_IMPLICIT) ? 0 : -1; 00244 task->parent = parent; 00245 task->children_count = 0; 00246 task->completed_execution = false; 00247 task->icv = parent->icv; 00248 } 00249 00250 extern void tomp_completePendingTasks(); 00251 00252 /* Here's how to access the current copy of the ICVs. */ 00253 00254 static inline struct gomp_task_icv *gomp_icv (void) 00255 { 00256 return &tomp_thread.current_task->icv; 00257 } 00258 #endif /* TOMP_PARALLEL_H_ */