Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison VMS.h @ 140:2c8f3cf6c058
Free memory calculation
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 19 Sep 2011 18:43:08 +0200 |
| parents | ca154ebe2b6c 99343ffe1918 |
| children | e7cd1945c9b6 |
comparison
equal
deleted
inserted
replaced
| 47:aa49feacd666 | 62:49606e883f0a |
|---|---|
| 3 * Licensed under GNU General Public License version 2 | 3 * Licensed under GNU General Public License version 2 |
| 4 * | 4 * |
| 5 * Author: seanhalle@yahoo.com | 5 * Author: seanhalle@yahoo.com |
| 6 * | 6 * |
| 7 */ | 7 */ |
| 8 | |
| 9 #ifndef _VMS_H | 8 #ifndef _VMS_H |
| 10 #define _VMS_H | 9 #define _VMS_H |
| 11 #define _GNU_SOURCE | 10 #define _GNU_SOURCE |
| 11 | |
| 12 #include <pthread.h> | |
| 13 #include <sys/time.h> | |
| 12 | 14 |
| 13 #include "VMS_primitive_data_types.h" | 15 #include "VMS_primitive_data_types.h" |
| 14 #include "Queue_impl/PrivateQueue.h" | 16 #include "Queue_impl/PrivateQueue.h" |
| 15 #include "Histogram/Histogram.h" | 17 #include "Histogram/Histogram.h" |
| 16 #include "DynArray/DynArray.h" | 18 #include "DynArray/DynArray.h" |
| 17 #include "Hash_impl/PrivateHash.h" | 19 #include "Hash_impl/PrivateHash.h" |
| 18 #include "vmalloc.h" | 20 #include "vmalloc.h" |
| 19 | 21 #include "inter_VMS_requests.h" |
| 20 #include <pthread.h> | |
| 21 #include <sys/time.h> | |
| 22 | |
| 23 | 22 |
| 24 //=============================== Debug =================================== | 23 //=============================== Debug =================================== |
| 25 // | 24 // |
| 26 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread | 25 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread |
| 27 // It still does co-routines and all the mechanisms are the same, it just | 26 // It still does co-routines and all the mechanisms are the same, it just |
| 48 #define DEBUG1( bool, msg, param) \ | 47 #define DEBUG1( bool, msg, param) \ |
| 49 // if(bool){printf(msg, param); fflush(stdin);} | 48 // if(bool){printf(msg, param); fflush(stdin);} |
| 50 #define DEBUG2( bool, msg, p1, p2) \ | 49 #define DEBUG2( bool, msg, p1, p2) \ |
| 51 // if(bool) {printf(msg, p1, p2); fflush(stdin);} | 50 // if(bool) {printf(msg, p1, p2); fflush(stdin);} |
| 52 | 51 |
| 53 #define ERROR(msg) printf(msg); | 52 #define ERROR(msg) printf(msg) |
| 54 #define ERROR1(msg, param) printf(msg, param); | 53 #define ERROR1(msg, param) printf(msg, param); |
| 55 #define ERROR2(msg, p1, p2) printf(msg, p1, p2); | 54 #define ERROR2(msg, p1, p2) printf(msg, p1, p2) |
| 56 | 55 |
| 57 //=========================== STATS ======================= | 56 //=========================== STATS ======================= |
| 58 | 57 |
| 59 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and | 58 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and |
| 60 // compiled-in that saves the low part of the time stamp count just before | 59 // compiled-in that saves the low part of the time stamp count just before |
| 88 | 87 |
| 89 // stack size in virtual processors created | 88 // stack size in virtual processors created |
| 90 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ | 89 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ |
| 91 | 90 |
| 92 // memory for VMS__malloc | 91 // memory for VMS__malloc |
| 93 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ | 92 #define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x4000000 /* 64M */ |
| 94 | 93 |
| 95 #define CACHE_LINE 64 | 94 #define CACHE_LINE 64 |
| 96 #define PAGE_SIZE 4096 | 95 #define PAGE_SIZE 4096 |
| 97 | 96 |
| 98 | 97 |
| 109 | 108 |
| 110 | 109 |
| 111 //=========================================================================== | 110 //=========================================================================== |
| 112 typedef unsigned long long TSCount; | 111 typedef unsigned long long TSCount; |
| 113 | 112 |
| 114 typedef struct _SchedSlot SchedSlot; | |
| 115 typedef struct _VMSReqst VMSReqst; | |
| 116 typedef struct _VirtProcr VirtProcr; | |
| 117 typedef struct _IntervalProbe IntervalProbe; | 113 typedef struct _IntervalProbe IntervalProbe; |
| 118 typedef struct _GateStruc GateStruc; | 114 typedef struct _GateStruc GateStruc; |
| 119 | 115 |
| 120 | 116 |
| 121 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx | 117 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx |
| 122 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv | 118 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv |
| 123 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr | |
| 124 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr | |
| 125 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); | 119 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); |
| 126 | |
| 127 | 120 |
| 128 //============= Requests =========== | 121 //============= Requests =========== |
| 129 // | 122 // |
| 130 | 123 |
| 131 enum VMSReqstType //avoid starting enums at 0, for debug reasons | 124 //VMS Request is the carrier for Slave to Master requests |
| 132 { | 125 // it has an embedded sub-type request that is pulled out |
| 133 semantic = 1, | 126 // inside the plugin's request handler |
| 127 enum VMSReqstType //For Slave->Master requests | |
| 128 { | |
| 129 semantic = 1, //avoid starting enums at 0, for debug reasons | |
| 134 createReq, | 130 createReq, |
| 135 dissipate, | 131 dissipate, |
| 136 VMSSemantic //goes with VMSSemReqst below | 132 VMSSemantic //goes with VMSSemReqst below |
| 137 }; | 133 }; |
| 138 | 134 |
| 143 | 139 |
| 144 VMSReqst *nextReqst; | 140 VMSReqst *nextReqst; |
| 145 }; | 141 }; |
| 146 //VMSReqst | 142 //VMSReqst |
| 147 | 143 |
| 144 //This is a sub-type of Slave->Master requests. | |
| 145 // It's for Slaves to invoke built-in VMS-core functions that have language-like | |
| 146 // behavior. | |
| 148 enum VMSSemReqstType //These are equivalent to semantic requests, but for | 147 enum VMSSemReqstType //These are equivalent to semantic requests, but for |
| 149 { // VMS's services available directly to app, like OS | 148 { // VMS's services available directly to app, like OS |
| 150 createProbe = 1, // and probe services -- like a VMS-wide built-in lang | 149 createProbe = 1, // and probe services -- like a VMS-wide built-in lang |
| 151 openFile, | 150 openFile, |
| 152 otherIO | 151 otherIO, |
| 152 interMasterReqst | |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 typedef struct | 155 typedef struct |
| 156 { enum VMSSemReqstType reqType; | 156 { enum VMSSemReqstType reqType; |
| 157 VirtProcr *requestingPr; | 157 //VirtProcr *requestingPr; |
| 158 char *nameStr; //for create probe | 158 int receiverID; //for inter master requests |
| 159 void *data; | |
| 159 } | 160 } |
| 160 VMSSemReq; | 161 VMSSemReq; |
| 161 | 162 |
| 162 | 163 |
| 163 //==================== Core data structures =================== | 164 //==================== Core data structures =================== |
| 164 | 165 |
| 165 struct _SchedSlot | 166 /*Master Env is the only global variable -- has entry points for any other |
| 166 { | 167 * data needed. |
| 167 int workIsDone; | |
| 168 int needsProcrAssigned; | |
| 169 VirtProcr *procrAssignedToSlot; | |
| 170 }; | |
| 171 //SchedSlot | |
| 172 | |
| 173 /*WARNING: re-arranging this data structure could cause VP switching | |
| 174 * assembly code to fail -- hard-codes offsets of fields | |
| 175 */ | |
| 176 struct _VirtProcr | |
| 177 { int procrID; //for debugging -- count up each time create | |
| 178 int coreAnimatedBy; | |
| 179 void *startOfStack; | |
| 180 void *stackPtr; | |
| 181 void *framePtr; | |
| 182 void *nextInstrPt; | |
| 183 | |
| 184 void *coreLoopStartPt; //allows proto-runtime to be linked later | |
| 185 void *coreLoopFramePtr; //restore before jmp back to core loop | |
| 186 void *coreLoopStackPtr; //restore before jmp back to core loop | |
| 187 | |
| 188 void *initialData; | |
| 189 | |
| 190 SchedSlot *schedSlot; | |
| 191 VMSReqst *requests; | |
| 192 | |
| 193 void *semanticData; //this livesUSE_GNU here for the life of VP | |
| 194 void *dataRetFromReq;//values returned from plugin to VP go here | |
| 195 | |
| 196 //=========== MEASUREMENT STUFF ========== | |
| 197 #ifdef MEAS__TIME_STAMP_SUSP | |
| 198 unsigned int preSuspTSCLow; | |
| 199 unsigned int postSuspTSCLow; | |
| 200 #endif | |
| 201 #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ | |
| 202 unsigned int startMasterTSCLow;USE_GNU | |
| 203 unsigned int endMasterTSCLow; | |
| 204 #endif | |
| 205 //======================================== | |
| 206 | |
| 207 float64 createPtInSecs; //have space but don't use on some configs | |
| 208 }; | |
| 209 //VirtProcr | |
| 210 | |
| 211 | |
| 212 /*WARNING: re-arranging this data structure could cause VP-switching | |
| 213 * assembly code to fail -- hard-codes offsets of fields | |
| 214 * (because -O3 messes with things otherwise) | |
| 215 */ | 168 */ |
| 216 typedef struct | 169 typedef struct |
| 217 { | 170 { |
| 218 SlaveScheduler slaveScheduler; | 171 SlaveScheduler slaveScheduler; |
| 219 RequestHandler requestHandler; | 172 RequestHandler requestHandler; |
| 220 | 173 |
| 221 SchedSlot ***allSchedSlots; | 174 SchedSlot ***allSchedSlots; |
| 222 VMSQueueStruc **readyToAnimateQs; | 175 VMSQueueStruc **readyToAnimateQs; |
| 223 VirtProcr **masterVPs; | 176 VirtProcr **masterVPs; |
| 224 | 177 |
| 225 void *semanticEnv; | 178 void *semanticEnv; |
| 226 void *OSEventStruc; //for future, when add I/O to BLIS | 179 void *OSEventStruc; //for future, when add I/O to BLIS |
| 227 MallocArrays *freeLists; | |
| 228 int32 amtOfOutstandingMem; //total currently allocated | |
| 229 | 180 |
| 230 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop | 181 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop |
| 231 | 182 |
| 232 int32 setupComplete; | 183 int32 setupComplete; |
| 233 volatile int32 masterLock; | 184 volatile int32 masterLock; |
| 185 | |
| 186 MallocArrays *freeLists[NUM_CORES]; | |
| 187 int32 amtOfOutstandingMem; //total currently allocated | |
| 234 | 188 |
| 235 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP | 189 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP |
| 236 GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal | 190 GateStruc *workStealingGates[NUM_CORES]; //concurrent work-steal |
| 237 int32 workStealingLock; | 191 int32 workStealingLock; |
| 238 | 192 |
| 239 int32 numProcrsCreated; //gives ordering to processor creation | 193 InterMasterReqst* interMasterRequestsFor[NUM_CORES]; |
| 194 InterMasterReqst* interMasterRequestsSentBy[NUM_CORES]; | |
| 195 RequestHandler interPluginReqHdlr; | |
| 196 | |
| 197 int32 numProcrsCreated; //gives ordering to processor creation | |
| 198 | |
| 199 int32 currentMasterProcrID; | |
| 240 | 200 |
| 241 //=========== MEASUREMENT STUFF ============= | 201 //=========== MEASUREMENT STUFF ============= |
| 242 IntervalProbe **intervalProbes; | 202 IntervalProbe **intervalProbes; |
| 243 PrivDynArrayInfo *dynIntervalProbesInfo; | 203 PrivDynArrayInfo *dynIntervalProbesInfo; |
| 244 HashTable *probeNameHashTbl; | 204 HashTable *probeNameHashTbl; |
| 245 int32 masterCreateProbeID; | 205 int32 masterCreateProbeID; |
| 246 float64 createPtInSecs; | 206 float64 createPtInSecs; |
| 247 Histogram **measHists; | 207 Histogram **measHists; |
| 248 PrivDynArrayInfo *measHistsInfo; | 208 PrivDynArrayInfo *measHistsInfo; |
| 249 #ifdef MEAS__TIME_PLUGIN | 209 #ifdef MEAS__TIME_PLUGIN |
| 250 Histogram *reqHdlrLowTimeHist; | 210 Histogram *reqHdlrLowTimeHist; |
| 251 Histogram *reqHdlrHighTimeHist; | 211 Histogram *reqHdlrHighTimeHist; |
| 252 #endif | 212 #endif |
| 253 #ifdef MEAS__TIME_MALLOC | 213 #ifdef MEAS__TIME_MALLOC |
| 254 Histogram *mallocTimeHist; | 214 Histogram *mallocTimeHist; |
| 255 Histogram *freeTimeHist; | 215 Histogram *freeTimeHist; |
| 256 #endif | 216 #endif |
| 257 #ifdef MEAS__TIME_MASTER_LOCK | 217 #ifdef MEAS__TIME_MASTER_LOCK |
| 258 Histogram *masterLockLowTimeHist; | 218 Histogram *masterLockLowTimeHist; |
| 259 Histogram *masterLockHighTimeHist; | 219 Histogram *masterLockHighTimeHist; |
| 260 #endif | 220 #endif |
| 261 } | 221 } |
| 262 MasterEnv; | 222 MasterEnv; |
| 263 | 223 |
| 264 //========================= Extra Stuff Data Strucs ======================= | 224 //========================= Extra Stuff Data Strucs ======================= |
| 301 //===================== Global Vars =================== | 261 //===================== Global Vars =================== |
| 302 | 262 |
| 303 volatile MasterEnv *_VMSMasterEnv; | 263 volatile MasterEnv *_VMSMasterEnv; |
| 304 | 264 |
| 305 | 265 |
| 306 | |
| 307 | |
| 308 //=========================== Function Prototypes ========================= | 266 //=========================== Function Prototypes ========================= |
| 309 | 267 |
| 310 | 268 |
| 311 //========== Setup and shutdown ========== | 269 //========== Setup and shutdown ========== |
| 312 void | 270 void |
| 365 void inline | 323 void inline |
| 366 VMS__send_dissipate_req( VirtProcr *prToDissipate ); | 324 VMS__send_dissipate_req( VirtProcr *prToDissipate ); |
| 367 | 325 |
| 368 inline void | 326 inline void |
| 369 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); | 327 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); |
| 328 | |
| 329 | |
| 330 void inline | |
| 331 VMS__send_inter_plugin_req( void *reqData, int32 targetMaster, | |
| 332 VirtProcr *requestingMaster ); | |
| 333 void inline | |
| 334 VMS__send_inter_VMSCore_req( InterVMSCoreReqst *reqData, int32 targetMaster, | |
| 335 VirtProcr *requestingMaster ); | |
| 370 | 336 |
| 371 VMSReqst * | 337 VMSReqst * |
| 372 VMS__take_next_request_out_of( VirtProcr *procrWithReq ); | 338 VMS__take_next_request_out_of( VirtProcr *procrWithReq ); |
| 373 | 339 |
| 374 inline void * | 340 inline void * |
| 569 addIntervalToHist( startStamp, endStamp, \ | 535 addIntervalToHist( startStamp, endStamp, \ |
| 570 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); | 536 _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] ); |
| 571 | 537 |
| 572 //===== | 538 //===== |
| 573 | 539 |
| 574 #include "ProcrContext.h" | |
| 575 #include "probes.h" | 540 #include "probes.h" |
| 576 #include "vutilities.h" | 541 #include "vutilities.h" |
| 577 | 542 |
| 578 #endif /* _VMS_H */ | 543 #endif /* _VMS_H */ |
| 579 | 544 |
