Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.h @ 50:8f7141a9272e
Added VMS__malloc and probes, and major re-factoring to separate mallocs
| author | Me |
|---|---|
| date | Sat, 30 Oct 2010 20:54:36 -0700 |
| parents | 5388f1c2da6f |
| children | f59cfa31a579 |
line diff
1.1 --- a/VMS.h Thu Oct 14 17:07:23 2010 -0700 1.2 +++ b/VMS.h Sat Oct 30 20:54:36 2010 -0700 1.3 @@ -13,17 +13,31 @@ 1.4 #include "VMS_primitive_data_types.h" 1.5 #include "Queue_impl/BlockingQueue.h" 1.6 #include "Histogram/Histogram.h" 1.7 +#include "DynArray/DynArray.h" 1.8 +#include "Hash_impl/PrivateHash.h" 1.9 +#include "vmalloc.h" 1.10 + 1.11 #include <pthread.h> 1.12 +#include <sys/time.h> 1.13 1.14 + 1.15 +//=============================== Debug =================================== 1.16 //When SEQUENTIAL is defined, VMS does sequential exe in the main thread 1.17 // It still does co-routines and all the mechanisms are the same, it just 1.18 // has only a single thread and animates VPs one at a time 1.19 //#define SEQUENTIAL 1.20 1.21 -#define PRINT_DEBUG(msg) //printf(msg); fflush(stdin); 1.22 +#define PRINT_DEBUG(msg)// printf(msg); fflush(stdin); 1.23 #define PRINT1_DEBUG(msg, param) //printf(msg, param); fflush(stdin); 1.24 #define PRINT2_DEBUG(msg, p1, p2) //printf(msg, p1, p2); fflush(stdin); 1.25 1.26 +#define PRINT_ERROR(msg) printf(msg); fflush(stdin); 1.27 +#define PRINT1_ERROR(msg, param) printf(msg, param); fflush(stdin); 1.28 +#define PRINT2_ERROR(msg, p1, p2) printf(msg, p1, p2); fflush(stdin); 1.29 + 1.30 + 1.31 +//=========================== STATS ======================= 1.32 + 1.33 //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and 1.34 // compiled-in that saves the low part of the time stamp count just before 1.35 // suspending a processor and just after resuming that processor. It is 1.36 @@ -35,6 +49,8 @@ 1.37 1.38 #define NUM_TSC_ROUND_TRIPS 10 1.39 1.40 + 1.41 +//========================= Hardware related Constants ===================== 1.42 //This value is the number of hardware threads in the shared memory 1.43 // machine 1.44 #define NUM_CORES 4 1.45 @@ -47,39 +63,75 @@ 1.46 #define READYTOANIMATE_RETRIES 10000 1.47 1.48 // stack 1.49 -#define VIRT_PROCR_STACK_SIZE 0x10000 1.50 +#define VIRT_PROCR_STACK_SIZE 0x4000 1.51 1.52 - //256M of total memory for VMS__malloc 1.53 -#define MASSIVE_MALLOC_SIZE 0x10000000 1.54 + // memory for VMS__malloc -- 256M 1.55 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 1.56 1.57 -#define NUM_PREPEND_BYTES sizeof(FreeListElem) + sizeof(ownerElem); 1.58 + 1.59 +//============================== 1.60 1.61 #define SUCCESS 0 1.62 1.63 -#define writeVMSQ writeCASQ 1.64 -#define readVMSQ readCASQ 1.65 -#define makeVMSQ makeCASQ 1.66 -#define VMSQueueStruc CASQueueStruc 1.67 +#define writeVMSQ writeSRSWQ 1.68 +#define readVMSQ readSRSWQ 1.69 +#define makeVMSQ makeSRSWQ 1.70 +#define VMSQueueStruc SRSWQueueStruc 1.71 1.72 -//#define thdAttrs NULL //For PThreads 1.73 1.74 -typedef struct _SchedSlot SchedSlot; 1.75 -typedef struct _VMSReqst VMSReqst; 1.76 -typedef struct _VirtProcr VirtProcr; 1.77 + 1.78 +//=========================================================================== 1.79 +typedef unsigned long long TSCount; 1.80 + 1.81 +typedef struct _SchedSlot SchedSlot; 1.82 +typedef struct _VMSReqst VMSReqst; 1.83 +typedef struct _VirtProcr VirtProcr; 1.84 +typedef struct _IntervalProbe IntervalProbe; 1.85 1.86 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx 1.87 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv 1.88 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr 1.89 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr 1.90 +typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); 1.91 + 1.92 + 1.93 +//============= Requests =========== 1.94 +// 1.95 + 1.96 +enum VMSReqstType //avoid starting enums at 0, for debug reasons 1.97 + { 1.98 + semantic = 1, 1.99 + createReq, 1.100 + dissipate, 1.101 + VMSSemantic //goes with VMSSemReqst below 1.102 + }; 1.103 + 1.104 +struct _VMSReqst 1.105 + { 1.106 + enum VMSReqstType reqType;//used for dissipate and in future for IO requests 1.107 + void *semReqData; 1.108 + 1.109 + VMSReqst *nextReqst; 1.110 + }; 1.111 +//VMSReqst 1.112 + 1.113 +enum VMSSemReqstType //These are equivalent to semantic requests, but for 1.114 + { // VMS's services available directly to app, like OS 1.115 + createProbe = 1, // and probe services -- like a VMS-wide built-in lang 1.116 + openFile, 1.117 + otherIO 1.118 + }; 1.119 1.120 typedef struct 1.121 - { 1.122 - void *endThdPt; 1.123 - unsigned int coreNum; 1.124 + { enum VMSSemReqstType reqType; 1.125 + VirtProcr *requestingPr; 1.126 + char *nameStr; //for create probe 1.127 } 1.128 -ThdParams; 1.129 + VMSSemReq; 1.130 1.131 1.132 +//==================== Core data structures =================== 1.133 + 1.134 struct _SchedSlot 1.135 { 1.136 int workIsDone; 1.137 @@ -87,24 +139,6 @@ 1.138 VirtProcr *procrAssignedToSlot; 1.139 }; 1.140 //SchedSlot 1.141 - 1.142 -enum ReqstType 1.143 - { 1.144 - semantic = 1, 1.145 - dissipate, 1.146 - regCreated, 1.147 - IO 1.148 - }; 1.149 - 1.150 -struct _VMSReqst 1.151 - { 1.152 -// VirtProcr *virtProcrFrom; 1.153 - enum ReqstType reqType;//used for dissipate and in future for IO requests 1.154 - void *semReqData; 1.155 - 1.156 - VMSReqst *nextReqst; 1.157 - }; 1.158 -//VMSReqst 1.159 1.160 struct _VirtProcr 1.161 { int procrID; //for debugging -- count up each time create 1.162 @@ -123,9 +157,10 @@ 1.163 SchedSlot *schedSlot; 1.164 VMSReqst *requests; 1.165 1.166 - void *semanticData; 1.167 + void *semanticData; //this lives here for the life of VP 1.168 + void *dataReturnedFromReq;//values returned from plugin to VP go here 1.169 1.170 - //============================= MEASUREMENT STUFF ======================== 1.171 + //=========== MEASUREMENT STUFF ========== 1.172 #ifdef MEAS__TIME_STAMP_SUSP 1.173 unsigned int preSuspTSCLow; 1.174 unsigned int postSuspTSCLow; 1.175 @@ -134,12 +169,12 @@ 1.176 unsigned int startMasterTSCLow; 1.177 unsigned int endMasterTSCLow; 1.178 #endif 1.179 - //======================================================================== 1.180 + 1.181 + float64 createPtInSecs; //have space but don't use on some configs 1.182 }; 1.183 //VirtProcr 1.184 1.185 1.186 - 1.187 typedef struct 1.188 { 1.189 SlaveScheduler slaveScheduler; 1.190 @@ -151,35 +186,61 @@ 1.191 1.192 void *semanticEnv; 1.193 void *OSEventStruc; //for future, when add I/O to BLIS 1.194 + MallocProlog *freeListHead; 1.195 + int32 amtOfOutstandingMem; //total currently allocated 1.196 1.197 void *coreLoopStartPt;//addr to jump to to re-enter coreLoop 1.198 void *coreLoopEndPt; //addr to jump to to shut down a coreLoop 1.199 1.200 - int setupComplete; 1.201 - int masterLock; 1.202 + int32 setupComplete; 1.203 + int32 masterLock; 1.204 1.205 + int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 1.206 + int32 numProcrsCreated; //gives ordering to processor creation 1.207 + 1.208 + //=========== MEASUREMENT STUFF ============= 1.209 + IntervalProbe **intervalProbes; 1.210 + DynArrayInfo *dynIntervalProbesInfo; 1.211 + HashTable *probeNameHashTbl; 1.212 + int32 masterCreateProbeID; 1.213 + float64 createPtInSecs; 1.214 } 1.215 MasterEnv; 1.216 1.217 1.218 -//========================================================== 1.219 + 1.220 + 1.221 +//======================= OS Thread related =============================== 1.222 1.223 void * coreLoop( void *paramsIn ); //standard PThreads fn prototype 1.224 void * coreLoop_Seq( void *paramsIn ); //standard PThreads fn prototype 1.225 void masterLoop( void *initData, VirtProcr *masterPr ); 1.226 1.227 1.228 -//===================== Global Vars =================== 1.229 - 1.230 +typedef struct 1.231 + { 1.232 + void *endThdPt; 1.233 + unsigned int coreNum; 1.234 + } 1.235 +ThdParams; 1.236 1.237 pthread_t coreLoopThdHandles[ NUM_CORES ]; //pthread's virt-procr state 1.238 ThdParams *coreLoopThdParams [ NUM_CORES ]; 1.239 pthread_mutex_t suspendLock; 1.240 pthread_cond_t suspend_cond; 1.241 1.242 + 1.243 + 1.244 +//===================== Global Vars =================== 1.245 + 1.246 volatile MasterEnv *_VMSMasterEnv; 1.247 1.248 -//========================== 1.249 + 1.250 + 1.251 + 1.252 +//=========================== Function Prototypes ========================= 1.253 + 1.254 +//============== Setup and shutdown ============= 1.255 void 1.256 VMS__init(); 1.257 1.258 @@ -195,16 +256,28 @@ 1.259 VirtProcr * 1.260 VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 1.261 1.262 + //Use this to create processor inside entry point & other places outside 1.263 + // the VMS system boundary (IE, not run in slave nor Master) 1.264 +VirtProcr * 1.265 +VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData ); 1.266 + 1.267 VirtProcr * 1.268 VMS__create_the_shutdown_procr(); 1.269 1.270 -//========================== 1.271 +void 1.272 +VMS__cleanup_after_shutdown(); 1.273 + 1.274 + 1.275 +//============== Request Related =============== 1.276 + 1.277 +void 1.278 +VMS__suspend_procr( VirtProcr *callingPr ); 1.279 + 1.280 inline void 1.281 VMS__add_sem_request( void *semReqData, VirtProcr *callingPr ); 1.282 1.283 void 1.284 -VMS__send_req_to_register_new_procr( VirtProcr *newPrToRegister, 1.285 - VirtProcr *reqstingPr ); 1.286 +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); 1.287 1.288 void 1.289 VMS__free_request( VMSReqst *req ); 1.290 @@ -216,7 +289,7 @@ 1.291 VMS__take_top_request_from( VirtProcr *reqstingPr ); 1.292 1.293 VMSReqst * 1.294 -VMS__free_top_and_give_next_request_from( VirtProcr *procrWithReq ); 1.295 +VMS__take_next_request_out_of( VirtProcr *procrWithReq ); 1.296 1.297 inline void * 1.298 VMS__take_sem_reqst_from( VMSReqst *req ); 1.299 @@ -232,25 +305,15 @@ 1.300 1.301 //========================== 1.302 1.303 -void 1.304 -VMS__suspend_procr( VirtProcr *callingPr ); 1.305 - 1.306 -void 1.307 +void inline 1.308 VMS__dissipate_procr( VirtProcr *prToDissipate ); 1.309 1.310 void 1.311 VMS__handle_dissipate_reqst( VirtProcr *procrToDissipate ); 1.312 1.313 -void 1.314 -VMS__cleanup_after_shutdown(); 1.315 1.316 -//============================= Statistics ================================== 1.317 1.318 -typedef unsigned long long TSCount; 1.319 - 1.320 - //Frequency of TS counts 1.321 - //TODO: change freq for each machine 1.322 -#define TSCOUNT_FREQ 3180000000 1.323 +//===================== RDTSC wrapper ================== 1.324 1.325 #define saveTimeStampCountInto(low, high) \ 1.326 asm volatile("RDTSC; \ 1.327 @@ -269,11 +332,9 @@ 1.328 /* clobber */ : "%eax", "%edx" \ 1.329 ); 1.330 1.331 -inline TSCount getTSCount(); 1.332 +//======================== STATS ====================== 1.333 1.334 -//===================== Debug ========================== 1.335 -int numProcrsCreated; 1.336 - 1.337 +#include "probes.h" 1.338 1.339 #endif /* _VMS_H */ 1.340
