annotate VMS.h @ 206:a262abf4b8d5

brch file for new WestmereEx 4x10 HW Branch
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 17 Feb 2012 18:43:52 +0100
parents bfaebdf60df3
children
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"
msach@201 14 #include "C_Libraries/Queue_impl/PrivateQueue.h"
msach@201 15 #include "C_Libraries/Histogram/Histogram.h"
msach@201 16 #include "C_Libraries/DynArray/DynArray.h"
msach@201 17 #include "C_Libraries/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 {
msach@173 146 union{ //added padding, because this variable is written a lot by different cores
msach@173 147 //thus invalidating a lot of the stucture
msach@173 148 volatile int32 masterLock;
msach@173 149 char padding[256];
msach@173 150 } masterLockUnion;
Me@42 151 SlaveScheduler slaveScheduler;
Me@42 152 RequestHandler requestHandler;
Me@42 153
Me@42 154 SchedSlot ***allSchedSlots;
Me@55 155 VMSQueueStruc **readyToAnimateQs;
Me@42 156 VirtProcr **masterVPs;
Me@42 157
Me@42 158 void *semanticEnv;
Me@42 159 void *OSEventStruc; //for future, when add I/O to BLIS
msach@101 160 MallocArrays *freeLists;
Me@50 161 int32 amtOfOutstandingMem; //total currently allocated
Me@42 162
msach@73 163 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
Me@42 164
Me@50 165 int32 setupComplete;
msach@173 166 //int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP
Me@59 167 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal
Me@55 168 int32 workStealingLock;
Me@55 169
Me@50 170 int32 numProcrsCreated; //gives ordering to processor creation
Me@50 171
Me@50 172 //=========== MEASUREMENT STUFF =============
msach@169 173 IntervalProbe **intervalProbes;
msach@169 174 PrivDynArrayInfo *dynIntervalProbesInfo;
msach@169 175 HashTable *probeNameHashTbl;
msach@169 176 int32 masterCreateProbeID;
msach@169 177 float64 createPtInSecs;
msach@169 178 Histogram **measHists;
msach@169 179 PrivDynArrayInfo *measHistsInfo;
msach@169 180 #ifdef MEAS__TIME_PLUGIN
msach@169 181 Histogram *reqHdlrLowTimeHist;
msach@169 182 Histogram *reqHdlrHighTimeHist;
msach@169 183 #endif
msach@169 184 #ifdef MEAS__TIME_MALLOC
msach@169 185 Histogram *mallocTimeHist;
msach@169 186 Histogram *freeTimeHist;
msach@169 187 #endif
msach@169 188 #ifdef MEAS__TIME_MASTER_LOCK
msach@169 189 Histogram *masterLockLowTimeHist;
msach@169 190 Histogram *masterLockHighTimeHist;
msach@169 191 #endif
msach@169 192 #ifdef MEAS__TIME_2011_SYS
msach@169 193 TSCountLowHigh startMaster;
msach@169 194 uint64 totalMasterCycles;
msach@169 195 uint32 numMasterAnimations;
msach@169 196 TSCountLowHigh startReqHdlr;
msach@169 197 uint64 totalPluginCycles;
msach@169 198 uint32 numPluginAnimations;
msach@169 199 uint64 cyclesTillStartMasterLoop;
msach@169 200 TSCountLowHigh endMasterLoop;
msach@169 201 #endif
msach@169 202 //==========================================
Me@42 203 }
Me@42 204 MasterEnv;
Me@42 205
Me@55 206 //========================= Extra Stuff Data Strucs =======================
Me@54 207 typedef struct
Me@54 208 {
Me@42 209
Me@54 210 }
Me@54 211 VMSExcp;
Me@50 212
Me@55 213 struct _GateStruc
Me@55 214 {
Me@55 215 int32 gateClosed;
Me@55 216 int32 preGateProgress;
Me@55 217 int32 waitProgress;
Me@55 218 int32 exitProgress;
Me@55 219 };
Me@55 220 //GateStruc
Me@50 221
Me@50 222 //======================= OS Thread related ===============================
Me@42 223
Me@42 224 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype
Me@42 225 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype
msach@169 226 void masterLoop( void *initData, VirtProcr *masterVP );
Me@42 227
Me@42 228
Me@50 229 typedef struct
Me@50 230 {
Me@50 231 void *endThdPt;
Me@50 232 unsigned int coreNum;
Me@50 233 }
Me@50 234 ThdParams;
Me@42 235
Me@42 236 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state
Me@42 237 ThdParams *coreLoopThdParams [ NUM_CORES ];
Me@42 238 pthread_mutex_t suspendLock;
Me@42 239 pthread_cond_t suspend_cond;
Me@42 240
Me@50 241
Me@50 242
Me@50 243 //===================== Global Vars ===================
Me@50 244
msach@171 245 volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__;
Me@42 246
Me@50 247
Me@50 248
Me@50 249
Me@50 250 //=========================== Function Prototypes =========================
Me@50 251
Me@53 252
Me@53 253 //========== Setup and shutdown ==========
Me@42 254 void
Me@42 255 VMS__init();
Me@42 256
Me@42 257 void
Me@42 258 VMS__init_Seq();
Me@42 259
Me@42 260 void
Me@42 261 VMS__start_the_work_then_wait_until_done();
Me@42 262
Me@42 263 void
Me@42 264 VMS__start_the_work_then_wait_until_done_Seq();
Me@42 265
msach@76 266 inline VirtProcr *
Me@42 267 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
Me@42 268
Me@53 269 void
Me@53 270 VMS__dissipate_procr( VirtProcr *procrToDissipate );
Me@53 271
Me@50 272 //Use this to create processor inside entry point & other places outside
Me@50 273 // the VMS system boundary (IE, not run in slave nor Master)
Me@50 274 VirtProcr *
Me@50 275 VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
Me@50 276
Me@53 277 void
Me@53 278 VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
Me@42 279
Me@50 280 void
Me@54 281 VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
Me@54 282
Me@54 283 void
Me@53 284 VMS__shutdown();
Me@53 285
Me@53 286 void
Me@53 287 VMS__cleanup_at_end_of_shutdown();
Me@50 288
Me@64 289 void *
Me@64 290 VMS__give_sem_env_for( VirtProcr *animPr );
Me@64 291
Me@50 292
Me@50 293 //============== Request Related ===============
Me@50 294
Me@50 295 void
Me@50 296 VMS__suspend_procr( VirtProcr *callingPr );
Me@50 297
Me@42 298 inline void
Me@53 299 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
Me@53 300
Me@53 301 inline void
Me@53 302 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
Me@42 303
Me@42 304 void
Me@50 305 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
Me@42 306
Me@53 307 void inline
Me@53 308 VMS__send_dissipate_req( VirtProcr *prToDissipate );
Me@53 309
Me@52 310 inline void
Me@52 311 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
Me@52 312
Me@42 313 VMSReqst *
Me@50 314 VMS__take_next_request_out_of( VirtProcr *procrWithReq );
Me@42 315
Me@42 316 inline void *
Me@42 317 VMS__take_sem_reqst_from( VMSReqst *req );
Me@42 318
msach@78 319 void inline
msach@78 320 VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
msach@78 321 ResumePrFnPtr resumePrFnPtr );
msach@78 322
msach@169 323 //======================== MEASUREMENT ======================
msach@169 324 uint64
msach@169 325 VMS__give_num_plugin_cycles();
msach@169 326 uint32
msach@169 327 VMS__give_num_plugin_animations();
Me@42 328
Me@42 329
Me@42 330
msach@77 331 #include "ProcrContext.h"
Me@50 332 #include "probes.h"
Me@65 333 #include "vutilities.h"
msach@201 334 #include "VMS_Implementations/Vthread_impl/VMS_lang_specific_defines.h"
Me@42 335 #endif /* _VMS_H */
Me@42 336