Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.h @ 139:99798e4438a6
Merge of Malloc2 and inter master requests
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Mon, 19 Sep 2011 16:12:01 +0200 |
| parents | ca154ebe2b6c 99343ffe1918 |
| children | e7cd1945c9b6 |
line diff
1.1 --- a/VMS.h Wed Sep 07 19:36:46 2011 +0200 1.2 +++ b/VMS.h Mon Sep 19 16:12:01 2011 +0200 1.3 @@ -5,21 +5,20 @@ 1.4 * Author: seanhalle@yahoo.com 1.5 * 1.6 */ 1.7 - 1.8 #ifndef _VMS_H 1.9 #define _VMS_H 1.10 #define _GNU_SOURCE 1.11 1.12 +#include <pthread.h> 1.13 +#include <sys/time.h> 1.14 + 1.15 #include "VMS_primitive_data_types.h" 1.16 #include "Queue_impl/PrivateQueue.h" 1.17 #include "Histogram/Histogram.h" 1.18 #include "DynArray/DynArray.h" 1.19 #include "Hash_impl/PrivateHash.h" 1.20 #include "vmalloc.h" 1.21 - 1.22 -#include <pthread.h> 1.23 -#include <sys/time.h> 1.24 - 1.25 +#include "inter_VMS_requests.h" 1.26 1.27 //=============================== Debug =================================== 1.28 // 1.29 @@ -50,9 +49,9 @@ 1.30 #define DEBUG2( bool, msg, p1, p2) \ 1.31 // if(bool) {printf(msg, p1, p2); fflush(stdin);} 1.32 1.33 -#define ERROR(msg) printf(msg); 1.34 -#define ERROR1(msg, param) printf(msg, param); 1.35 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2); 1.36 +#define ERROR(msg) printf(msg) 1.37 +#define ERROR1(msg, param) printf(msg, param); 1.38 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2) 1.39 1.40 //=========================== STATS ======================= 1.41 1.42 @@ -90,7 +89,7 @@ 1.43 #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */ 1.44 1.45 // memory for VMS__malloc 1.46 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */ 1.47 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x4000000 /* 64M */ 1.48 1.49 #define CACHE_LINE 64 1.50 #define PAGE_SIZE 4096 1.51 @@ -111,26 +110,23 @@ 1.52 //=========================================================================== 1.53 typedef unsigned long long TSCount; 1.54 1.55 -typedef struct _SchedSlot SchedSlot; 1.56 -typedef struct _VMSReqst VMSReqst; 1.57 -typedef struct _VirtProcr VirtProcr; 1.58 typedef struct _IntervalProbe IntervalProbe; 1.59 typedef struct _GateStruc GateStruc; 1.60 1.61 1.62 typedef VirtProcr * (*SlaveScheduler) ( void *, int ); //semEnv, coreIdx 1.63 typedef void (*RequestHandler) ( VirtProcr *, void * ); //prWReqst, semEnv 1.64 -typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr 1.65 -typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr 1.66 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); 1.67 1.68 - 1.69 //============= Requests =========== 1.70 // 1.71 1.72 -enum VMSReqstType //avoid starting enums at 0, for debug reasons 1.73 - { 1.74 - semantic = 1, 1.75 +//VMS Request is the carrier for Slave to Master requests 1.76 +// it has an embedded sub-type request that is pulled out 1.77 +// inside the plugin's request handler 1.78 +enum VMSReqstType //For Slave->Master requests 1.79 + { 1.80 + semantic = 1, //avoid starting enums at 0, for debug reasons 1.81 createReq, 1.82 dissipate, 1.83 VMSSemantic //goes with VMSSemReqst below 1.84 @@ -145,73 +141,30 @@ 1.85 }; 1.86 //VMSReqst 1.87 1.88 +//This is a sub-type of Slave->Master requests. 1.89 +// It's for Slaves to invoke built-in VMS-core functions that have language-like 1.90 +// behavior. 1.91 enum VMSSemReqstType //These are equivalent to semantic requests, but for 1.92 { // VMS's services available directly to app, like OS 1.93 createProbe = 1, // and probe services -- like a VMS-wide built-in lang 1.94 openFile, 1.95 - otherIO 1.96 + otherIO, 1.97 + interMasterReqst 1.98 }; 1.99 1.100 typedef struct 1.101 { enum VMSSemReqstType reqType; 1.102 - VirtProcr *requestingPr; 1.103 - char *nameStr; //for create probe 1.104 + //VirtProcr *requestingPr; 1.105 + int receiverID; //for inter master requests 1.106 + void *data; 1.107 } 1.108 - VMSSemReq; 1.109 +VMSSemReq; 1.110 1.111 1.112 //==================== Core data structures =================== 1.113 1.114 -struct _SchedSlot 1.115 - { 1.116 - int workIsDone; 1.117 - int needsProcrAssigned; 1.118 - VirtProcr *procrAssignedToSlot; 1.119 - }; 1.120 -//SchedSlot 1.121 - 1.122 -/*WARNING: re-arranging this data structure could cause VP switching 1.123 - * assembly code to fail -- hard-codes offsets of fields 1.124 - */ 1.125 -struct _VirtProcr 1.126 - { int procrID; //for debugging -- count up each time create 1.127 - int coreAnimatedBy; 1.128 - void *startOfStack; 1.129 - void *stackPtr; 1.130 - void *framePtr; 1.131 - void *nextInstrPt; 1.132 - 1.133 - void *coreLoopStartPt; //allows proto-runtime to be linked later 1.134 - void *coreLoopFramePtr; //restore before jmp back to core loop 1.135 - void *coreLoopStackPtr; //restore before jmp back to core loop 1.136 - 1.137 - void *initialData; 1.138 - 1.139 - SchedSlot *schedSlot; 1.140 - VMSReqst *requests; 1.141 - 1.142 - void *semanticData; //this livesUSE_GNU here for the life of VP 1.143 - void *dataRetFromReq;//values returned from plugin to VP go here 1.144 - 1.145 - //=========== MEASUREMENT STUFF ========== 1.146 - #ifdef MEAS__TIME_STAMP_SUSP 1.147 - unsigned int preSuspTSCLow; 1.148 - unsigned int postSuspTSCLow; 1.149 - #endif 1.150 - #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/ 1.151 - unsigned int startMasterTSCLow;USE_GNU 1.152 - unsigned int endMasterTSCLow; 1.153 - #endif 1.154 - //======================================== 1.155 - 1.156 - float64 createPtInSecs; //have space but don't use on some configs 1.157 - }; 1.158 -//VirtProcr 1.159 - 1.160 - 1.161 -/*WARNING: re-arranging this data structure could cause VP-switching 1.162 - * assembly code to fail -- hard-codes offsets of fields 1.163 - * (because -O3 messes with things otherwise) 1.164 +/*Master Env is the only global variable -- has entry points for any other 1.165 + * data needed. 1.166 */ 1.167 typedef struct 1.168 { 1.169 @@ -219,44 +172,51 @@ 1.170 RequestHandler requestHandler; 1.171 1.172 SchedSlot ***allSchedSlots; 1.173 - VMSQueueStruc **readyToAnimateQs; 1.174 + VMSQueueStruc **readyToAnimateQs; 1.175 VirtProcr **masterVPs; 1.176 1.177 void *semanticEnv; 1.178 void *OSEventStruc; //for future, when add I/O to BLIS 1.179 - MallocArrays *freeLists; 1.180 - int32 amtOfOutstandingMem; //total currently allocated 1.181 1.182 void *coreLoopReturnPt;//addr to jump to to re-enter coreLoop 1.183 1.184 int32 setupComplete; 1.185 volatile int32 masterLock; 1.186 + 1.187 + MallocArrays *freeLists[NUM_CORES]; 1.188 + int32 amtOfOutstandingMem; //total currently allocated 1.189 1.190 int32 numMasterInARow[NUM_CORES];//detect back-to-back masterVP 1.191 - GateStruc *workStealingGates[ NUM_CORES ]; //concurrent work-steal 1.192 + GateStruc *workStealingGates[NUM_CORES]; //concurrent work-steal 1.193 int32 workStealingLock; 1.194 1.195 - int32 numProcrsCreated; //gives ordering to processor creation 1.196 + InterMasterReqst* interMasterRequestsFor[NUM_CORES]; 1.197 + InterMasterReqst* interMasterRequestsSentBy[NUM_CORES]; 1.198 + RequestHandler interPluginReqHdlr; 1.199 + 1.200 + int32 numProcrsCreated; //gives ordering to processor creation 1.201 + 1.202 + int32 currentMasterProcrID; 1.203 1.204 //=========== MEASUREMENT STUFF ============= 1.205 - IntervalProbe **intervalProbes; 1.206 - PrivDynArrayInfo *dynIntervalProbesInfo; 1.207 - HashTable *probeNameHashTbl; 1.208 - int32 masterCreateProbeID; 1.209 - float64 createPtInSecs; 1.210 - Histogram **measHists; 1.211 - PrivDynArrayInfo *measHistsInfo; 1.212 + IntervalProbe **intervalProbes; 1.213 + PrivDynArrayInfo *dynIntervalProbesInfo; 1.214 + HashTable *probeNameHashTbl; 1.215 + int32 masterCreateProbeID; 1.216 + float64 createPtInSecs; 1.217 + Histogram **measHists; 1.218 + PrivDynArrayInfo *measHistsInfo; 1.219 #ifdef MEAS__TIME_PLUGIN 1.220 - Histogram *reqHdlrLowTimeHist; 1.221 - Histogram *reqHdlrHighTimeHist; 1.222 + Histogram *reqHdlrLowTimeHist; 1.223 + Histogram *reqHdlrHighTimeHist; 1.224 #endif 1.225 #ifdef MEAS__TIME_MALLOC 1.226 - Histogram *mallocTimeHist; 1.227 - Histogram *freeTimeHist; 1.228 + Histogram *mallocTimeHist; 1.229 + Histogram *freeTimeHist; 1.230 #endif 1.231 #ifdef MEAS__TIME_MASTER_LOCK 1.232 - Histogram *masterLockLowTimeHist; 1.233 - Histogram *masterLockHighTimeHist; 1.234 + Histogram *masterLockLowTimeHist; 1.235 + Histogram *masterLockHighTimeHist; 1.236 #endif 1.237 } 1.238 MasterEnv; 1.239 @@ -303,8 +263,6 @@ 1.240 volatile MasterEnv *_VMSMasterEnv; 1.241 1.242 1.243 - 1.244 - 1.245 //=========================== Function Prototypes ========================= 1.246 1.247 1.248 @@ -368,6 +326,14 @@ 1.249 inline void 1.250 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); 1.251 1.252 + 1.253 +void inline 1.254 +VMS__send_inter_plugin_req( void *reqData, int32 targetMaster, 1.255 + VirtProcr *requestingMaster ); 1.256 +void inline 1.257 +VMS__send_inter_VMSCore_req( InterVMSCoreReqst *reqData, int32 targetMaster, 1.258 + VirtProcr *requestingMaster ); 1.259 + 1.260 VMSReqst * 1.261 VMS__take_next_request_out_of( VirtProcr *procrWithReq ); 1.262 1.263 @@ -571,7 +537,6 @@ 1.264 1.265 //===== 1.266 1.267 -#include "ProcrContext.h" 1.268 #include "probes.h" 1.269 #include "vutilities.h" 1.270
