Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > DKU_impls > DKU__MC_shared_impl
comparison DKU.h @ 0:9f2a7bd26dd9
Initial add -- code is straight copy of VSs implementation.. to be modified
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Mon, 27 Aug 2012 02:14:35 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:35d93acb05c6 |
|---|---|
| 1 /* | |
| 2 * Copyright 2009 OpenSourceStewardshipFoundation.org | |
| 3 * Licensed under GNU General Public License version 2 | |
| 4 * | |
| 5 * Author: seanhalle@yahoo.com | |
| 6 * | |
| 7 */ | |
| 8 | |
| 9 #ifndef _VSs_H | |
| 10 #define _VSs_H | |
| 11 | |
| 12 #include "Queue_impl/PrivateQueue.h" | |
| 13 #include "Hash_impl/PrivateHash.h" | |
| 14 #include "VMS_impl/VMS.h" | |
| 15 #include "Measurement/dependency.h" | |
| 16 | |
| 17 | |
| 18 //=========================================================================== | |
| 19 #define NUM_STRUCS_IN_SEM_ENV 1000 | |
| 20 | |
| 21 //This is hardware dependent -- it's the number of cycles of scheduling | |
| 22 // overhead -- if a work unit is fewer than this, it is better being | |
| 23 // combined sequentially with other work | |
| 24 //This value depends on both VMS overhead and VSs's plugin. At some point | |
| 25 // it will be derived by perf-counter measurements during init of VSs | |
| 26 #define MIN_WORK_UNIT_CYCLES 20000 | |
| 27 | |
| 28 //=========================================================================== | |
| 29 /*This header defines everything specific to the VSs semantic plug-in | |
| 30 */ | |
| 31 typedef struct _VSsSemReq VSsSemReq; | |
| 32 typedef void (*VSsTaskFnPtr ) ( void *, SlaveVP *); | |
| 33 typedef void (*PtrToAtomicFn ) ( void * ); //executed atomically in master | |
| 34 //=========================================================================== | |
| 35 | |
| 36 #define NONCTLD 0 | |
| 37 #define IN 1 /*Trick -- READER same as IN*/ | |
| 38 #define OUT 2 /*Trick -- WRITER same as OUT and INOUT*/ | |
| 39 #define INOUT 2 /*Trick -- WRITER same as OUT and INOUT*/ | |
| 40 | |
| 41 #define READER 1 /*Trick -- READER same as IN*/ | |
| 42 #define WRITER 2 /*Trick -- WRITER same as OUT and INOUT*/ | |
| 43 | |
| 44 #define IS_A_THREAD NULL | |
| 45 #define IS_ENDED NULL | |
| 46 #define SEED_SLV NULL | |
| 47 | |
| 48 typedef struct | |
| 49 { | |
| 50 VSsTaskFnPtr fn; | |
| 51 int32 numTotalArgs;//the number of inputs to function | |
| 52 int32 numCtldArgs;//how many of args have dependencies | |
| 53 int32 *argTypes; //says reader, writer, or non-ctld | |
| 54 int32 *argSizes; //for detecting overlap | |
| 55 int32 sizeOfArgs; //for memcpy of args struct | |
| 56 } | |
| 57 VSsTaskType; | |
| 58 | |
| 59 | |
| 60 typedef struct | |
| 61 { | |
| 62 bool32 hasEnabledNonFinishedWriter; | |
| 63 int32 numEnabledNonDoneReaders; | |
| 64 PrivQueueStruc *waitersQ; | |
| 65 } | |
| 66 VSsPointerEntry; | |
| 67 | |
| 68 typedef struct | |
| 69 { | |
| 70 void **args; //ctld args must come first, as ptrs | |
| 71 VSsTaskType *taskType; | |
| 72 int32 *taskID; | |
| 73 int32 numBlockingProp; | |
| 74 SlaveVP *slaveAssignedTo; //only valid before end task (thread) | |
| 75 VSsPointerEntry **ptrEntries; | |
| 76 void* parentTaskStub; | |
| 77 int32 numLiveChildTasks; | |
| 78 int32 numLiveChildThreads; | |
| 79 bool32 isWaitingForChildTasksToEnd; | |
| 80 bool32 isWaitingForChildThreadsToEnd; | |
| 81 bool32 isEnded; | |
| 82 } | |
| 83 VSsTaskStub; | |
| 84 | |
| 85 | |
| 86 typedef struct | |
| 87 { | |
| 88 VSsTaskStub *taskStub; | |
| 89 int32 argNum; | |
| 90 int32 isReader; | |
| 91 } | |
| 92 VSsTaskStubCarrier; | |
| 93 | |
| 94 | |
| 95 /*Semantic layer-specific data sent inside a request from lib called in app | |
| 96 * to request handler called in AnimationMaster | |
| 97 */ | |
| 98 | |
| 99 typedef struct | |
| 100 { | |
| 101 SlaveVP *VPCurrentlyExecuting; | |
| 102 PrivQueueStruc *waitingVPQ; | |
| 103 } | |
| 104 VSsTrans; | |
| 105 | |
| 106 /*WARNING: assembly hard-codes position of endInstrAddr as first field | |
| 107 */ | |
| 108 typedef struct | |
| 109 { | |
| 110 void *endInstrAddr; | |
| 111 int32 hasBeenStarted; | |
| 112 int32 hasFinished; | |
| 113 PrivQueueStruc *waitQ; | |
| 114 } | |
| 115 VSsSingleton; | |
| 116 | |
| 117 enum VSsReqType | |
| 118 { | |
| 119 submit_task = 1, | |
| 120 end_task, | |
| 121 create_slave, | |
| 122 create_slave_w_aff, | |
| 123 dissipate_slave, | |
| 124 //=============================== | |
| 125 send_type_to, | |
| 126 receive_type_to, | |
| 127 send_from_to, | |
| 128 receive_from_to, | |
| 129 //=============================== | |
| 130 taskwait, | |
| 131 malloc_req, | |
| 132 free_req, | |
| 133 singleton_fn_start, | |
| 134 singleton_fn_end, | |
| 135 singleton_data_start, | |
| 136 singleton_data_end, | |
| 137 atomic, | |
| 138 trans_start, | |
| 139 trans_end | |
| 140 }; | |
| 141 | |
| 142 struct _VSsSemReq | |
| 143 { enum VSsReqType reqType; | |
| 144 SlaveVP *callingSlv; | |
| 145 VSsTaskType *taskType; | |
| 146 void *args; | |
| 147 VSsTaskStub *taskStub; | |
| 148 | |
| 149 SlaveVP *senderSlv; | |
| 150 SlaveVP *receiverSlv; | |
| 151 int32 *senderID; | |
| 152 int32 *receiverID; | |
| 153 int32 msgType; | |
| 154 void *msg; | |
| 155 VSsSemReq *nextReqInHashEntry; | |
| 156 int32 *taskID; | |
| 157 | |
| 158 TopLevelFnPtr fnPtr; | |
| 159 void *initData; | |
| 160 int32 coreToAssignOnto; | |
| 161 | |
| 162 int32 sizeToMalloc; | |
| 163 void *ptrToFree; | |
| 164 | |
| 165 int32 singletonID; | |
| 166 VSsSingleton **singletonPtrAddr; | |
| 167 | |
| 168 PtrToAtomicFn fnToExecInMaster; | |
| 169 void *dataForFn; | |
| 170 | |
| 171 int32 transID; | |
| 172 } | |
| 173 /* VSsSemReq */; | |
| 174 | |
| 175 | |
| 176 typedef struct | |
| 177 { | |
| 178 PrivQueueStruc *slavesReadyToResumeQ; //Shared (slaves not pinned) | |
| 179 PrivQueueStruc *freeExtraTaskSlvQ; //Shared | |
| 180 PrivQueueStruc *taskReadyQ; //Shared (tasks not pinned) | |
| 181 SlaveVP *slotTaskSlvs[NUM_CORES][NUM_ANIM_SLOTS]; | |
| 182 HashTable *argPtrHashTbl; | |
| 183 HashTable *commHashTbl; | |
| 184 int32 numLiveExtraTaskSlvs; | |
| 185 int32 numLiveThreadSlvs; | |
| 186 int32 nextCoreToGetNewSlv; | |
| 187 int32 primitiveStartTime; | |
| 188 | |
| 189 //fix limit on num with dynArray | |
| 190 VSsSingleton fnSingletons[NUM_STRUCS_IN_SEM_ENV]; | |
| 191 VSsTrans transactionStrucs[NUM_STRUCS_IN_SEM_ENV]; | |
| 192 | |
| 193 bool32 *coreIsDone; | |
| 194 int32 numCoresDone; | |
| 195 | |
| 196 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC | |
| 197 ListOfArrays* unitList; | |
| 198 ListOfArrays* ctlDependenciesList; | |
| 199 ListOfArrays* commDependenciesList; | |
| 200 NtoN** ntonGroups; | |
| 201 PrivDynArrayInfo* ntonGroupsInfo; | |
| 202 ListOfArrays* dynDependenciesList; | |
| 203 Unit last_in_slot[NUM_CORES * NUM_ANIM_SLOTS]; | |
| 204 ListOfArrays* hwArcs; | |
| 205 #endif | |
| 206 | |
| 207 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS | |
| 208 ListOfArrays* counterList[NUM_CORES]; | |
| 209 #endif | |
| 210 SlaveVP* idleSlv[NUM_CORES][NUM_ANIM_SLOTS]; | |
| 211 int shutdownInitiated; | |
| 212 } | |
| 213 VSsSemEnv; | |
| 214 | |
| 215 | |
| 216 typedef struct _TransListElem TransListElem; | |
| 217 struct _TransListElem | |
| 218 { | |
| 219 int32 transID; | |
| 220 TransListElem *nextTrans; | |
| 221 }; | |
| 222 //TransListElem | |
| 223 | |
| 224 enum VSsSlvType | |
| 225 { ExtraTaskSlv = 1, | |
| 226 SlotTaskSlv, | |
| 227 ThreadSlv | |
| 228 }; | |
| 229 | |
| 230 typedef struct | |
| 231 { | |
| 232 int32 highestTransEntered; | |
| 233 TransListElem *lastTransEntered; | |
| 234 bool32 needsTaskAssigned; | |
| 235 VSsTaskStub *taskStub; | |
| 236 enum VSsSlvType slaveType; | |
| 237 } | |
| 238 VSsSemData; | |
| 239 | |
| 240 //=========================================================================== | |
| 241 | |
| 242 void | |
| 243 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fn, void *initData ); | |
| 244 | |
| 245 int32 | |
| 246 VSs__giveMinWorkUnitCycles( float32 percentOverhead ); | |
| 247 | |
| 248 void | |
| 249 VSs__start_primitive(); | |
| 250 | |
| 251 int32 | |
| 252 VSs__end_primitive_and_give_cycles(); | |
| 253 | |
| 254 int32 | |
| 255 VSs__giveIdealNumWorkUnits(); | |
| 256 | |
| 257 int32 | |
| 258 VSs__give_number_of_cores_to_schedule_onto(); | |
| 259 | |
| 260 //======================= | |
| 261 | |
| 262 void | |
| 263 VSs__init(); | |
| 264 | |
| 265 void | |
| 266 VSs__cleanup_after_shutdown(); | |
| 267 | |
| 268 //======================= | |
| 269 | |
| 270 SlaveVP * | |
| 271 VSs__create_thread( TopLevelFnPtr fnPtr, void *initData, | |
| 272 SlaveVP *creatingThd ); | |
| 273 | |
| 274 void | |
| 275 VSs__end_thread( SlaveVP *thdToEnd ); | |
| 276 | |
| 277 //======================= | |
| 278 | |
| 279 #define VSs__malloc( numBytes, callingSlave ) VMS_App__malloc( numBytes, callingSlave) | |
| 280 | |
| 281 #define VSs__free(ptrToFree, callingSlave ) VMS_App__free( ptrToFree, callingSlave ) | |
| 282 | |
| 283 | |
| 284 //======================= | |
| 285 void | |
| 286 VSs__submit_task( VSsTaskType *taskType, void *args, SlaveVP *animSlv); | |
| 287 | |
| 288 inline int32 * | |
| 289 VSs__create_taskID_of_size( int32 numInts, SlaveVP *animSlv ); | |
| 290 | |
| 291 void | |
| 292 VSs__submit_task_with_ID( VSsTaskType *taskType, void *args, int32 *taskID, | |
| 293 SlaveVP *animSlv); | |
| 294 | |
| 295 void | |
| 296 VSs__end_task( SlaveVP *animSlv ); | |
| 297 | |
| 298 //========================= | |
| 299 void | |
| 300 VSs__taskwait(SlaveVP *animSlv); | |
| 301 | |
| 302 | |
| 303 inline int32 * | |
| 304 VSs__give_self_taskID( SlaveVP *animSlv ); | |
| 305 | |
| 306 void | |
| 307 VSs__send_of_type_to( void *msg, const int32 type, int32 *receiverID, | |
| 308 SlaveVP *senderSlv ); | |
| 309 | |
| 310 void | |
| 311 VSs__send_from_to( void *msg, int32 *senderID, int32 *receiverID, SlaveVP *senderSlv ); | |
| 312 | |
| 313 void * | |
| 314 VSs__receive_type_to( const int32 type, int32* receiverID, SlaveVP *receiverSlv ); | |
| 315 | |
| 316 void * | |
| 317 VSs__receive_from_to( int32 *senderID, int32 *receiverID, SlaveVP *receiverSlv ); | |
| 318 | |
| 319 //======================= Concurrency Stuff ====================== | |
| 320 void | |
| 321 VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ); | |
| 322 | |
| 323 void | |
| 324 VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ); | |
| 325 | |
| 326 void | |
| 327 VSs__start_data_singleton( VSsSingleton **singeltonAddr, SlaveVP *animSlv ); | |
| 328 | |
| 329 void | |
| 330 VSs__end_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv ); | |
| 331 | |
| 332 void | |
| 333 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, | |
| 334 void *data, SlaveVP *animSlv ); | |
| 335 | |
| 336 void | |
| 337 VSs__start_transaction( int32 transactionID, SlaveVP *animSlv ); | |
| 338 | |
| 339 void | |
| 340 VSs__end_transaction( int32 transactionID, SlaveVP *animSlv ); | |
| 341 | |
| 342 | |
| 343 //========================= Internal use only ============================= | |
| 344 void | |
| 345 VSs__Request_Handler( SlaveVP *requestingSlv, void *_semEnv ); | |
| 346 | |
| 347 SlaveVP * | |
| 348 VSs__assign_slaveVP_to_slot( void *_semEnv, AnimSlot *slot ); | |
| 349 | |
| 350 SlaveVP* | |
| 351 VSs__create_slave_helper( TopLevelFnPtr fnPtr, void *initData, | |
| 352 VSsSemEnv *semEnv, int32 coreToAssignOnto ); | |
| 353 | |
| 354 VSsTaskStub * | |
| 355 create_thread_task_stub( void *initData ); | |
| 356 | |
| 357 | |
| 358 SlaveVP * | |
| 359 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData, | |
| 360 SlaveVP *creatingSlv ); | |
| 361 | |
| 362 SlaveVP * | |
| 363 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData, | |
| 364 SlaveVP *creatingSlv, int32 coreToAssignOnto); | |
| 365 | |
| 366 void | |
| 367 idle_fn(void* data, SlaveVP *animatingSlv); | |
| 368 | |
| 369 //===================== Measurement of Lang Overheads ===================== | |
| 370 #include "Measurement/VSs_Measurement.h" | |
| 371 | |
| 372 //=========================================================================== | |
| 373 #endif /* _VSs_H */ | |
| 374 |
