annotate VMS.h @ 205:cb888346c3e0

Changed include paths, but version still does not work because of accidental merge
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 17 Feb 2012 18:28:59 +0100
parents 6db9e4898978
children
rev   line source
Me@178 1 /*
Me@178 2 * Copyright 2009 OpenSourceStewardshipFoundation.org
Me@178 3 * Licensed under GNU General Public License version 2
Me@178 4 *
Me@178 5 * Author: seanhalle@yahoo.com
Me@178 6 *
Me@178 7 */
Me@178 8
Me@178 9 #ifndef _VMS_H
Me@178 10 #define _VMS_H
Me@178 11 #define _GNU_SOURCE
Me@178 12
Me@178 13 #include "VMS_primitive_data_types.h"
msach@205 14 #include "C_Libraries/DynArray/DynArray.h"
msach@205 15 #include "C_Libraries/Hash_impl/PrivateHash.h"
msach@205 16 #include "C_Libraries/Histogram/Histogram.h"
msach@205 17 #include "C_Libraries/Queue_impl/PrivateQueue.h"
Me@178 18 #include "vmalloc.h"
Me@178 19
Me@178 20 #include <pthread.h>
Me@178 21 #include <sys/time.h>
Me@178 22
Me@200 23 //================= Defines: included from separate files =================
Me@200 24 //
Me@200 25 // Note: ALL defines are in other files, none are in here
Me@200 26 //
Me@200 27 #include "VMS_defs.h"
Me@178 28
Me@200 29
Me@200 30 //================================ Typedefs =================================
Me@178 31 //
Me@178 32 typedef unsigned long long TSCount;
Me@200 33 typedef union
Me@200 34 { uint32 lowHigh[2];
Me@200 35 uint64 longVal;
Me@200 36 }
Me@200 37 TSCountLowHigh;
Me@178 38
Me@178 39 typedef struct _SchedSlot SchedSlot;
Me@178 40 typedef struct _VMSReqst VMSReqst;
Me@200 41 typedef struct _SlaveVP SlaveVP;
Me@178 42 typedef struct _IntervalProbe IntervalProbe;
Me@178 43 typedef struct _GateStruc GateStruc;
Me@178 44
Me@178 45
Me@200 46 typedef SlaveVP * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx
Me@200 47 typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
Me@200 48 typedef void (*VirtProcrFnPtr) ( void *, SlaveVP * ); //initData, animPr
Me@200 49 typedef void VirtProcrFn ( void *, SlaveVP * ); //initData, animPr
Me@200 50 typedef void (*ResumeVPFnPtr) ( SlaveVP *, void * );
Me@178 51
msach@205 52 //============================= Statistics ==================================
msach@205 53
msach@205 54 inline TSCount getTSCount();
Me@178 55
Me@200 56 //============= Request Related ===========
Me@178 57 //
Me@178 58
Me@178 59 enum VMSReqstType //avoid starting enums at 0, for debug reasons
Me@178 60 {
Me@178 61 semantic = 1,
Me@178 62 createReq,
Me@178 63 dissipate,
Me@178 64 VMSSemantic //goes with VMSSemReqst below
Me@178 65 };
Me@178 66
Me@178 67 struct _VMSReqst
Me@178 68 {
Me@178 69 enum VMSReqstType reqType;//used for dissipate and in future for IO requests
Me@178 70 void *semReqData;
Me@178 71
Me@178 72 VMSReqst *nextReqst;
Me@178 73 };
Me@178 74 //VMSReqst
Me@178 75
Me@178 76 enum VMSSemReqstType //These are equivalent to semantic requests, but for
Me@178 77 { // VMS's services available directly to app, like OS
Me@178 78 createProbe = 1, // and probe services -- like a VMS-wide built-in lang
Me@178 79 openFile,
Me@178 80 otherIO
Me@178 81 };
Me@178 82
Me@178 83 typedef struct
Me@178 84 { enum VMSSemReqstType reqType;
Me@200 85 SlaveVP *requestingPr;
Me@178 86 char *nameStr; //for create probe
Me@178 87 }
Me@178 88 VMSSemReq;
Me@178 89
Me@178 90
Me@178 91 //==================== Core data structures ===================
Me@178 92
Me@178 93 struct _SchedSlot
Me@178 94 {
Me@178 95 int workIsDone;
Me@178 96 int needsProcrAssigned;
Me@200 97 SlaveVP *procrAssignedToSlot;
Me@178 98 };
Me@178 99 //SchedSlot
Me@178 100
Me@178 101 /*WARNING: re-arranging this data structure could cause VP switching
Me@178 102 * assembly code to fail -- hard-codes offsets of fields
Me@178 103 */
Me@200 104 struct _SlaveVP
Me@178 105 { int procrID; //for debugging -- count up each time create
Me@178 106 int coreAnimatedBy;
Me@178 107 void *startOfStack;
Me@178 108 void *stackPtr;
Me@178 109 void *framePtr;
Me@178 110 void *nextInstrPt;
Me@178 111
Me@178 112 void *coreLoopStartPt; //allows proto-runtime to be linked later
Me@178 113 void *coreLoopFramePtr; //restore before jmp back to core loop
Me@178 114 void *coreLoopStackPtr; //restore before jmp back to core loop
Me@178 115
Me@178 116 void *initialData;
Me@178 117
Me@178 118 SchedSlot *schedSlot;
Me@178 119 VMSReqst *requests;
Me@178 120
Me@178 121 void *semanticData; //this livesUSE_GNU here for the life of VP
Me@178 122 void *dataRetFromReq;//values returned from plugin to VP go here
Me@178 123
Me@178 124 //=========== MEASUREMENT STUFF ==========
Me@200 125 #ifdef MEAS__TIME_STAMP_SUSP
Me@200 126 uint32 preSuspTSCLow;
Me@200 127 uint32 postSuspTSCLow;
Me@200 128 #endif
Me@200 129 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
Me@200 130 uint32 startMasterTSCLow;USE_GNU
Me@200 131 uint32 endMasterTSCLow;
Me@200 132 #endif
Me@200 133 #ifdef MEAS__TIME_2011_SYS
Me@200 134 TSCountLowHigh startSusp;
Me@200 135 uint64 totalSuspCycles;
Me@200 136 uint32 numGoodSusp;
Me@200 137 #endif
Me@178 138 //========================================
Me@178 139
Me@178 140 float64 createPtInSecs; //have space but don't use on some configs
Me@178 141 };
Me@178 142 //VirtProcr
Me@178 143
Me@178 144
Me@178 145 /*WARNING: re-arranging this data structure could cause VP-switching
Me@178 146 * assembly code to fail -- hard-codes offsets of fields
Me@178 147 * (because -O3 messes with things otherwise)
Me@178 148 */
Me@178 149 typedef struct
Me@178 150 {
Me@200 151 union{ //adds padding to put masterLock on its own cache-line to elim
Me@200 152 // false sharing (masterLock is most-accessed var in VMS)
Me@200 153 volatile int32 masterLock;
Me@200 154 char padding[CACHELINE_SIZE];
Me@200 155 } masterLockUnion;
Me@178 156 SlaveScheduler slaveScheduler;
Me@178 157 RequestHandler requestHandler;
Me@178 158
Me@178 159 SchedSlot ***allSchedSlots;
Me@178 160 VMSQueueStruc **readyToAnimateQs;
Me@200 161 SlaveVP **masterVPs;
Me@178 162
Me@178 163 void *semanticEnv;
Me@178 164 void *OSEventStruc; //for future, when add I/O to BLIS
Me@200 165 MallocArrays *freeLists;
Me@178 166 int32 amtOfOutstandingMem; //total currently allocated
Me@178 167
Me@178 168 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
Me@178 169
Me@178 170 int32 setupComplete;
Me@200 171 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
Me@178 172 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
Me@178 173 int32 workStealingLock;
Me@178 174
Me@200 175 int32 numVPsCreated; //gives ordering to processor creation
Me@178 176
Me@178 177 //=========== MEASUREMENT STUFF =============
Me@200 178 IntervalProbe **intervalProbes;
Me@200 179 PrivDynArrayInfo *dynIntervalProbesInfo;
Me@200 180 HashTable *probeNameHashTbl;
Me@200 181 int32 masterCreateProbeID;
Me@200 182 float64 createPtInSecs;
Me@200 183 Histogram **measHists;
Me@200 184 PrivDynArrayInfo *measHistsInfo;
Me@200 185 #ifdef MEAS__TIME_PLUGIN
Me@200 186 Histogram *reqHdlrLowTimeHist;
Me@200 187 Histogram *reqHdlrHighTimeHist;
Me@200 188 #endif
Me@200 189 #ifdef MEAS__TIME_MALLOC
Me@200 190 Histogram *mallocTimeHist;
Me@200 191 Histogram *freeTimeHist;
Me@200 192 #endif
Me@200 193 #ifdef MEAS__TIME_MASTER_LOCK
Me@200 194 Histogram *masterLockLowTimeHist;
Me@200 195 Histogram *masterLockHighTimeHist;
Me@200 196 #endif
Me@200 197 #ifdef MEAS__TIME_2011_SYS
Me@200 198 TSCountLowHigh startMaster;
Me@200 199 uint64 totalMasterCycles;
Me@200 200 uint32 numMasterAnimations;
Me@200 201 TSCountLowHigh startReqHdlr;
Me@200 202 uint64 totalPluginCycles;
Me@200 203 uint32 numPluginAnimations;
Me@200 204 uint64 cyclesTillStartMasterLoop;
Me@200 205 TSCountLowHigh endMasterLoop;
Me@200 206 #endif
Me@200 207 //==========================================
Me@178 208 }
Me@178 209 MasterEnv;
Me@178 210
Me@178 211 //========================= Extra Stuff Data Strucs =======================
Me@178 212 typedef struct
Me@178 213 {
Me@178 214
Me@178 215 }
Me@178 216 VMSExcp;
Me@178 217
Me@178 218 struct _GateStruc
Me@178 219 {
Me@178 220 int32 gateClosed;
Me@178 221 int32 preGateProgress;
Me@178 222 int32 waitProgress;
Me@178 223 int32 exitProgress;
Me@178 224 };
Me@178 225 //GateStruc
Me@178 226
Me@178 227 //======================= OS Thread related ===============================
Me@178 228
Me@178 229 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
Me@178 230 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
Me@200 231 void masterLoop( void *initData, SlaveVP *masterVP );
Me@178 232
Me@178 233
Me@178 234 typedef struct
Me@178 235 {
Me@178 236 void *endThdPt;
Me@178 237 unsigned int coreNum;
Me@178 238 }
Me@178 239 ThdParams;
Me@178 240
Me@178 241 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
Me@178 242 ThdParams *coreLoopThdParams [ NUM_CORES ];
Me@178 243 pthread_mutex_t suspendLock;
Me@178 244 pthread_cond_t suspend_cond;
Me@178 245
Me@178 246
Me@178 247
Me@200 248 //============================= Global Vars ================================
Me@178 249
Me@200 250 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
Me@178 251
Me@178 252
Me@178 253
Me@178 254
Me@200 255 //========================= Function Prototypes ===========================
Me@178 256
Me@178 257
Me@178 258 //========== Setup and shutdown ==========
Me@178 259 void
Me@200 260 VMS_int__init();
Me@178 261
Me@178 262 void
Me@200 263 VMS_int__init_Seq();
Me@178 264
Me@178 265 void
Me@200 266 VMS_WL__start_the_work_then_wait_until_done();
Me@178 267
Me@178 268 void
Me@200 269 VMS_WL__start_the_work_then_wait_until_done_Seq();
Me@178 270
Me@200 271 inline SlaveVP *
Me@200 272 VMS_int__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
Me@178 273
Me@178 274 void
Me@200 275 VMS_int__dissipate_procr( SlaveVP *procrToDissipate );
Me@178 276
Me@178 277 //Use this to create processor inside entry point & other places outside
Me@178 278 // the VMS system boundary (IE, not run in slave nor Master)
Me@200 279 SlaveVP *
Me@178 280 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
Me@178 281
Me@178 282 void
Me@200 283 VMS_ext__dissipate_procr( SlaveVP *procrToDissipate );
Me@178 284
Me@178 285 void
Me@200 286 VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData );
Me@178 287
Me@178 288 void
Me@200 289 VMS_int__shutdown();
Me@178 290
Me@178 291 void
Me@200 292 VMS_int__cleanup_at_end_of_shutdown();
Me@178 293
Me@178 294 void *
Me@200 295 VMS_WL__give_sem_env_for( SlaveVP *animPr );
Me@178 296
Me@178 297
Me@178 298 //============== Request Related ===============
Me@178 299
Me@178 300 void
Me@200 301 VMS_int__suspend_procr( SlaveVP *callingPr );
Me@178 302
Me@178 303 inline void
Me@200 304 VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr );
Me@178 305
Me@178 306 inline void
Me@200 307 VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr );
Me@178 308
Me@178 309 void
Me@200 310 VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr );
Me@178 311
Me@178 312 void inline
Me@200 313 VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
Me@178 314
Me@178 315 inline void
Me@200 316 VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr );
Me@178 317
Me@178 318 VMSReqst *
Me@200 319 VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq );
Me@178 320
Me@178 321 inline void *
Me@200 322 VMS_PI__take_sem_reqst_from( VMSReqst *req );
Me@178 323
Me@178 324 void inline
Me@200 325 VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv,
Me@200 326 ResumeVPFnPtr resumePrFnPtr );
Me@178 327
Me@200 328 //======================== MEASUREMENT ======================
Me@200 329 uint64
Me@200 330 VMS_WL__give_num_plugin_cycles();
Me@200 331 uint32
Me@200 332 VMS_WL__give_num_plugin_animations();
Me@178 333
Me@178 334
Me@178 335
Me@178 336 #include "ProcrContext.h"
Me@178 337 #include "probes.h"
Me@178 338 #include "vutilities.h"
Me@178 339
Me@178 340 #endif /* _VMS_H */
Me@178 341