annotate VMS.h @ 169:d1dd9e6ee72c

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