Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
diff VSs.c @ 3:468b8638ff92
Works -- first working version, includes slave pruning and shutdown detection
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 06 Jun 2012 17:55:36 -0700 |
| parents | f2ed1c379fe7 |
| children | 13af59ed7ea5 |
line diff
1.1 --- a/VSs.c Wed May 30 15:02:38 2012 -0700 1.2 +++ b/VSs.c Wed Jun 06 17:55:36 2012 -0700 1.3 @@ -12,7 +12,7 @@ 1.4 #include "Hash_impl/PrivateHash.h" 1.5 1.6 #include "VSs.h" 1.7 -#include "VSs_Counter_Recording.h" 1.8 +#include "Measurement/VSs_Counter_Recording.h" 1.9 1.10 //========================================================================== 1.11 1.12 @@ -74,7 +74,7 @@ 1.13 void 1.14 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fnPtr, void *initData ) 1.15 { VSsSemEnv *semEnv; 1.16 - SlaveVP *seedPr; 1.17 + SlaveVP *seedSlv; 1.18 1.19 VSs__init(); //normal multi-thd 1.20 1.21 @@ -82,10 +82,13 @@ 1.22 1.23 //VSs starts with one processor, which is put into initial environ, 1.24 // and which then calls create() to create more, thereby expanding work 1.25 - seedPr = VSs__create_slave_helper( fnPtr, initData, 1.26 - semEnv, semEnv->nextCoreToGetNewPr++ ); 1.27 + seedSlv = VSs__create_slave_helper( fnPtr, initData, 1.28 + semEnv, semEnv->nextCoreToGetNewSlv++ ); 1.29 + 1.30 + //seedVP doesn't do tasks 1.31 + ((VSsSemData *)seedSlv->semanticData)->needsTaskAssigned = FALSE; 1.32 1.33 - resume_slaveVP( seedPr, semEnv ); 1.34 + resume_slaveVP( seedSlv, semEnv ); 1.35 1.36 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd 1.37 1.38 @@ -184,13 +187,17 @@ 1.39 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS 1.40 VSs__init_counter_data_structs(); 1.41 #endif 1.42 + 1.43 semanticEnv->shutdownInitiated = FALSE; 1.44 - for(i=0;i<NUM_CORES;++i){ 1.45 - for(j=0;j<NUM_ANIM_SLOTS;++j){ 1.46 - semanticEnv->idlePr[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL); 1.47 - semanticEnv->idlePr[i][j]->coreAnimatedBy = i; 1.48 + semanticEnv->coreIsDone = VMS_int__malloc( NUM_CORES * sizeof( bool32 ) ); 1.49 + for( i = 0; i < NUM_CORES; ++i ) 1.50 + { semanticEnv->coreIsDone[i] = FALSE; 1.51 + for( j = 0; j < NUM_ANIM_SLOTS; ++j ) 1.52 + { 1.53 + semanticEnv->idleSlv[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL); 1.54 + semanticEnv->idleSlv[i][j]->coreAnimatedBy = i; 1.55 } 1.56 - } 1.57 + } 1.58 1.59 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC 1.60 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128); 1.61 @@ -203,10 +210,7 @@ 1.62 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit))); 1.63 #endif 1.64 1.65 - //create the ready queue, hash tables used for pairing send to receive 1.66 - // and so forth 1.67 - //TODO: add hash tables for pairing sends with receives, and 1.68 - // initialize the data ownership system 1.69 + //create the ready queue, hash tables used for matching and so forth 1.70 readyVPQs = VMS_int__malloc( NUM_CORES * sizeof(PrivQueueStruc *) ); 1.71 1.72 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 1.73 @@ -216,10 +220,12 @@ 1.74 1.75 semanticEnv->readyVPQs = readyVPQs; 1.76 1.77 - semanticEnv->nextCoreToGetNewPr = 0; 1.78 + semanticEnv->taskReadyQ = makeVMSQ(); 1.79 + 1.80 + semanticEnv->nextCoreToGetNewSlv = 0; 1.81 semanticEnv->numSlaveVP = 0; 1.82 1.83 - semanticEnv->argPtrHashTbl = makeHashTable( 1<<16, &VMS_int__free );//start big 1.84 + semanticEnv->argPtrHashTbl = makeHashTable32( 16, &VMS_int__free ); 1.85 1.86 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit 1.87 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( ); 1.88 @@ -376,7 +382,7 @@ 1.89 */ 1.90 SlaveVP * 1.91 VSs__create_slave_with( TopLevelFnPtr fnPtr, void *initData, 1.92 - SlaveVP *creatingPr ) 1.93 + SlaveVP *creatingSlv ) 1.94 { VSsSemReq reqData; 1.95 1.96 //the semantic request data is on the stack and disappears when this 1.97 @@ -386,30 +392,30 @@ 1.98 reqData.coreToAssignOnto = -1; //means round-robin assign 1.99 reqData.fnPtr = fnPtr; 1.100 reqData.initData = initData; 1.101 - reqData.callingSlv = creatingPr; 1.102 + reqData.callingSlv = creatingSlv; 1.103 1.104 - VMS_WL__send_create_slaveVP_req( &reqData, creatingPr ); 1.105 + VMS_WL__send_create_slaveVP_req( &reqData, creatingSlv ); 1.106 1.107 - return creatingPr->dataRetFromReq; 1.108 + return creatingSlv->dataRetFromReq; 1.109 } 1.110 1.111 SlaveVP * 1.112 VSs__create_slave_with_affinity( TopLevelFnPtr fnPtr, void *initData, 1.113 - SlaveVP *creatingPr, int32 coreToAssignOnto ) 1.114 + SlaveVP *creatingSlv, int32 coreToAssignOnto ) 1.115 { VSsSemReq reqData; 1.116 1.117 //the semantic request data is on the stack and disappears when this 1.118 // call returns -- it's guaranteed to remain in the VP's stack for as 1.119 // long as the VP is suspended. 1.120 - reqData.reqType = create_slave; 1.121 + reqData.reqType = create_slave_w_aff; //not used, May 2012 1.122 reqData.coreToAssignOnto = coreToAssignOnto; 1.123 reqData.fnPtr = fnPtr; 1.124 reqData.initData = initData; 1.125 - reqData.callingSlv = creatingPr; 1.126 + reqData.callingSlv = creatingSlv; 1.127 1.128 - VMS_WL__send_create_slaveVP_req( &reqData, creatingPr ); 1.129 + VMS_WL__send_create_slaveVP_req( &reqData, creatingSlv ); 1.130 1.131 - return creatingPr->dataRetFromReq; 1.132 + return creatingSlv->dataRetFromReq; 1.133 } 1.134 1.135 1.136 @@ -438,7 +444,7 @@ 1.137 1.138 1.139 VMS_WL__send_sem_request( &reqData, animSlv ); 1.140 - return animSlv->dataRetFromReq; 1.141 + return (int32)animSlv->dataRetFromReq; 1.142 } 1.143 1.144 /*NOTE: if want, don't need to send the animating SlaveVP around.. 1.145 @@ -488,7 +494,7 @@ 1.146 * semantic environment. 1.147 */ 1.148 void 1.149 -VSs__start_fn_singleton( int32 singletonID, SlaveVP *animPr ) 1.150 +VSs__start_fn_singleton( int32 singletonID, SlaveVP *animSlv ) 1.151 { 1.152 VSsSemReq reqData; 1.153 1.154 @@ -496,10 +502,10 @@ 1.155 reqData.reqType = singleton_fn_start; 1.156 reqData.singletonID = singletonID; 1.157 1.158 - VMS_WL__send_sem_request( &reqData, animPr ); 1.159 - if( animPr->dataRetFromReq ) //will be 0 or addr of label in end singleton 1.160 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.161 + if( animSlv->dataRetFromReq ) //will be 0 or addr of label in end singleton 1.162 { 1.163 - VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animPr ); 1.164 + VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animSlv ); 1.165 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID])); 1.166 } 1.167 } 1.168 @@ -509,7 +515,7 @@ 1.169 * location. 1.170 */ 1.171 void 1.172 -VSs__start_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animPr ) 1.173 +VSs__start_data_singleton( VSsSingleton **singletonAddr, SlaveVP *animSlv ) 1.174 { 1.175 VSsSemReq reqData; 1.176 1.177 @@ -519,8 +525,8 @@ 1.178 reqData.reqType = singleton_data_start; 1.179 reqData.singletonPtrAddr = singletonAddr; 1.180 1.181 - VMS_WL__send_sem_request( &reqData, animPr ); 1.182 - if( animPr->dataRetFromReq ) //either 0 or end singleton's return addr 1.183 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.184 + if( animSlv->dataRetFromReq ) //either 0 or end singleton's return addr 1.185 { //Assembly code changes the return addr on the stack to the one 1.186 // saved into the singleton by the end-singleton-fn 1.187 //The return addr is at 0x4(%%ebp) 1.188 @@ -538,26 +544,26 @@ 1.189 * inside is shared by all invocations of a given singleton ID. 1.190 */ 1.191 void 1.192 -VSs__end_fn_singleton( int32 singletonID, SlaveVP *animPr ) 1.193 +VSs__end_fn_singleton( int32 singletonID, SlaveVP *animSlv ) 1.194 { 1.195 VSsSemReq reqData; 1.196 1.197 //don't need this addr until after at least one singleton has reached 1.198 // this function 1.199 - VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animPr ); 1.200 + VSsSemEnv *semEnv = VMS_int__give_sem_env_for( animSlv ); 1.201 asm_write_ret_from_singleton(&(semEnv->fnSingletons[ singletonID])); 1.202 1.203 reqData.reqType = singleton_fn_end; 1.204 reqData.singletonID = singletonID; 1.205 1.206 - VMS_WL__send_sem_request( &reqData, animPr ); 1.207 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.208 1.209 EndSingletonInstrAddr: 1.210 return; 1.211 } 1.212 1.213 void 1.214 -VSs__end_data_singleton( VSsSingleton **singletonPtrAddr, SlaveVP *animPr ) 1.215 +VSs__end_data_singleton( VSsSingleton **singletonPtrAddr, SlaveVP *animSlv ) 1.216 { 1.217 VSsSemReq reqData; 1.218 1.219 @@ -575,7 +581,7 @@ 1.220 reqData.reqType = singleton_data_end; 1.221 reqData.singletonPtrAddr = singletonPtrAddr; 1.222 1.223 - VMS_WL__send_sem_request( &reqData, animPr ); 1.224 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.225 } 1.226 1.227 /*This executes the function in the masterVP, so it executes in isolation 1.228 @@ -590,7 +596,7 @@ 1.229 */ 1.230 void 1.231 VSs__animate_short_fn_in_isolation( PtrToAtomicFn ptrToFnToExecInMaster, 1.232 - void *data, SlaveVP *animPr ) 1.233 + void *data, SlaveVP *animSlv ) 1.234 { 1.235 VSsSemReq reqData; 1.236 1.237 @@ -599,7 +605,7 @@ 1.238 reqData.fnToExecInMaster = ptrToFnToExecInMaster; 1.239 reqData.dataForFn = data; 1.240 1.241 - VMS_WL__send_sem_request( &reqData, animPr ); 1.242 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.243 } 1.244 1.245 1.246 @@ -617,16 +623,16 @@ 1.247 *If NULL, then write requesting into the field and resume. 1.248 */ 1.249 void 1.250 -VSs__start_transaction( int32 transactionID, SlaveVP *animPr ) 1.251 +VSs__start_transaction( int32 transactionID, SlaveVP *animSlv ) 1.252 { 1.253 VSsSemReq reqData; 1.254 1.255 // 1.256 - reqData.callingSlv = animPr; 1.257 + reqData.callingSlv = animSlv; 1.258 reqData.reqType = trans_start; 1.259 reqData.transID = transactionID; 1.260 1.261 - VMS_WL__send_sem_request( &reqData, animPr ); 1.262 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.263 } 1.264 1.265 /*This suspends to the master, then uses transactionID as index into an 1.266 @@ -639,14 +645,14 @@ 1.267 * resumes both. 1.268 */ 1.269 void 1.270 -VSs__end_transaction( int32 transactionID, SlaveVP *animPr ) 1.271 +VSs__end_transaction( int32 transactionID, SlaveVP *animSlv ) 1.272 { 1.273 VSsSemReq reqData; 1.274 1.275 // 1.276 - reqData.callingSlv = animPr; 1.277 + reqData.callingSlv = animSlv; 1.278 reqData.reqType = trans_end; 1.279 reqData.transID = transactionID; 1.280 1.281 - VMS_WL__send_sem_request( &reqData, animPr ); 1.282 + VMS_WL__send_sem_request( &reqData, animSlv ); 1.283 }
