Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VSs_impls > VSs__MC_shared_impl
comparison VSs.c @ 6:1780f6b00e3d
Not working -- checkpoint while making explicitly created VPs work, and DKU pattern
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 01 Aug 2012 00:18:53 -0700 |
| parents | 8188c5b4bfd7 |
| children | 3999b8429ddd |
comparison
equal
deleted
inserted
replaced
| 4:2e6293a1eccc | 5:f772dad3b39e |
|---|---|
| 71 *NOTE: no Threads should exist in the outside program that might touch | 71 *NOTE: no Threads should exist in the outside program that might touch |
| 72 * any of the data reachable from initData passed in to here | 72 * any of the data reachable from initData passed in to here |
| 73 */ | 73 */ |
| 74 void | 74 void |
| 75 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fnPtr, void *initData ) | 75 VSs__create_seed_slave_and_do_work( TopLevelFnPtr fnPtr, void *initData ) |
| 76 { VSsSemEnv *semEnv; | 76 { VSsSemEnv *semEnv; |
| 77 SlaveVP *seedSlv; | 77 SlaveVP *seedSlv; |
| 78 VSsSemData *semData; | |
| 79 VSsTaskStub *explPrTaskStub; | |
| 78 | 80 |
| 79 VSs__init(); //normal multi-thd | 81 VSs__init(); //normal multi-thd |
| 80 | 82 |
| 81 semEnv = _VMSMasterEnv->semanticEnv; | 83 semEnv = _VMSMasterEnv->semanticEnv; |
| 82 | 84 |
| 83 //VSs starts with one processor, which is put into initial environ, | 85 //VSs starts with one processor, which is put into initial environ, |
| 84 // and which then calls create() to create more, thereby expanding work | 86 // and which then calls create() to create more, thereby expanding work |
| 85 seedSlv = VSs__create_slave_helper( fnPtr, initData, | 87 seedSlv = VSs__create_slave_helper( fnPtr, initData, |
| 86 semEnv, semEnv->nextCoreToGetNewSlv++ ); | 88 semEnv, semEnv->nextCoreToGetNewSlv++ ); |
| 87 | 89 |
| 88 //seedVP doesn't do tasks | 90 //seed slave is an explicit processor, so make one of the special |
| 89 ((VSsSemData *)seedSlv->semanticData)->needsTaskAssigned = FALSE; | 91 // task stubs for explicit processors, and attach it to the slave |
| 90 | 92 explPrTaskStub = create_expl_proc_task_stub( initData ); |
| 91 resume_slaveVP( seedSlv, semEnv ); | 93 |
| 94 semData = (VSsSemData *)seedSlv->semanticData; | |
| 95 //seedVP already has a permanent task | |
| 96 semData->needsTaskAssigned = FALSE; | |
| 97 semData->taskStub = explPrTaskStub; | |
| 98 | |
| 99 resume_slaveVP( seedSlv, semEnv ); //returns right away, just queues Slv | |
| 92 | 100 |
| 93 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd | 101 VMS_SS__start_the_work_then_wait_until_done(); //normal multi-thd |
| 94 | 102 |
| 95 VSs__cleanup_after_shutdown(); | 103 VSs__cleanup_after_shutdown(); |
| 96 } | 104 } |
| 167 } | 175 } |
| 168 | 176 |
| 169 void | 177 void |
| 170 VSs__init_Helper() | 178 VSs__init_Helper() |
| 171 { VSsSemEnv *semanticEnv; | 179 { VSsSemEnv *semanticEnv; |
| 172 PrivQueueStruc **readyVPQs; | 180 int32 i, coreNum, slotNum; |
| 173 int coreIdx, i, j; | |
| 174 | 181 |
| 175 //Hook up the semantic layer's plug-ins to the Master virt procr | 182 //Hook up the semantic layer's plug-ins to the Master virt procr |
| 176 _VMSMasterEnv->requestHandler = &VSs__Request_Handler; | 183 _VMSMasterEnv->requestHandler = &VSs__Request_Handler; |
| 177 _VMSMasterEnv->slaveAssigner = &VSs__assign_slaveVP_to_slot; | 184 _VMSMasterEnv->slaveAssigner = &VSs__assign_slaveVP_to_slot; |
| 178 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS | 185 #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS |
| 188 VSs__init_counter_data_structs(); | 195 VSs__init_counter_data_structs(); |
| 189 #endif | 196 #endif |
| 190 | 197 |
| 191 semanticEnv->shutdownInitiated = FALSE; | 198 semanticEnv->shutdownInitiated = FALSE; |
| 192 semanticEnv->coreIsDone = VMS_int__malloc( NUM_CORES * sizeof( bool32 ) ); | 199 semanticEnv->coreIsDone = VMS_int__malloc( NUM_CORES * sizeof( bool32 ) ); |
| 193 for( i = 0; i < NUM_CORES; ++i ) | 200 //For each animation slot, there is an idle slave, and an initial |
| 194 { semanticEnv->coreIsDone[i] = FALSE; | 201 // slave assigned as the current-task-slave. Create them here. |
| 195 for( j = 0; j < NUM_ANIM_SLOTS; ++j ) | 202 SlaveVP *idleSlv, *currTaskSlv; |
| 196 { | 203 for( coreNum = 0; coreNum < NUM_CORES; coreNum++ ) |
| 197 semanticEnv->idleSlv[i][j] = VMS_int__create_slaveVP(&idle_fn,NULL); | 204 { semanticEnv->coreIsDone[coreNum] = FALSE; //use during shutdown |
| 198 semanticEnv->idleSlv[i][j]->coreAnimatedBy = i; | 205 |
| 206 for( slotNum = 0; slotNum < NUM_ANIM_SLOTS; ++slotNum ) | |
| 207 { idleSlv = VMS_int__create_slaveVP(&idle_fn,NULL); | |
| 208 idleSlv->coreAnimatedBy = coreNum; | |
| 209 idleSlv->animSlotAssignedTo = slotNum; | |
| 210 semanticEnv->idleSlv[coreNum][slotNum] = idleSlv; | |
| 211 | |
| 212 currTaskSlv = VMS_int__create_slaveVP( &idle_fn, NULL ); | |
| 213 currTaskSlv->coreAnimatedBy = coreNum; | |
| 214 currTaskSlv->animSlotAssignedTo = slotNum; | |
| 215 semanticEnv->currTaskSlvs[coreNum][slotNum] = currTaskSlv; | |
| 199 } | 216 } |
| 200 } | 217 } |
| 201 | 218 |
| 202 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC | 219 //create the ready queues, hash tables used for matching and so forth |
| 203 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128); | 220 semanticEnv->slavesReadyToResumeQ = makeVMSQ(); |
| 204 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128); | 221 semanticEnv->extraTaskSlvQ = makeVMSQ(); |
| 205 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128); | 222 semanticEnv->taskReadyQ = makeVMSQ(); |
| 206 semanticEnv->dynDependenciesList = makeListOfArrays(sizeof(Dependency),128); | |
| 207 semanticEnv->ntonGroupsInfo = makePrivDynArrayOfSize((void***)&(semanticEnv->ntonGroups),8); | |
| 208 | |
| 209 semanticEnv->hwArcs = makeListOfArrays(sizeof(Dependency),128); | |
| 210 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit))); | |
| 211 #endif | |
| 212 | |
| 213 //create the ready queue, hash tables used for matching and so forth | |
| 214 readyVPQs = VMS_int__malloc( NUM_CORES * sizeof(PrivQueueStruc *) ); | |
| 215 | |
| 216 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) | |
| 217 { | |
| 218 readyVPQs[ coreIdx ] = makeVMSQ(); | |
| 219 } | |
| 220 | |
| 221 semanticEnv->readyVPQs = readyVPQs; | |
| 222 | |
| 223 semanticEnv->taskReadyQ = makeVMSQ(); | |
| 224 | |
| 225 semanticEnv->nextCoreToGetNewSlv = 0; | |
| 226 semanticEnv->numSlaveVP = 0; | |
| 227 | 223 |
| 228 semanticEnv->argPtrHashTbl = makeHashTable32( 16, &VMS_int__free ); | 224 semanticEnv->argPtrHashTbl = makeHashTable32( 16, &VMS_int__free ); |
| 229 semanticEnv->commHashTbl = makeHashTable32( 16, &VMS_int__free ); | 225 semanticEnv->commHashTbl = makeHashTable32( 16, &VMS_int__free ); |
| 226 | |
| 227 semanticEnv->nextCoreToGetNewSlv = 0; | |
| 228 | |
| 230 | 229 |
| 231 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit | 230 //TODO: bug -- turn these arrays into dyn arrays to eliminate limit |
| 232 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( ); | 231 //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( ); |
| 233 //semanticEnv->transactionStrucs = makeDynArrayInfo( ); | 232 //semanticEnv->transactionStrucs = makeDynArrayInfo( ); |
| 234 for( i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++ ) | 233 for( i = 0; i < NUM_STRUCS_IN_SEM_ENV; i++ ) |
| 237 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE; | 236 semanticEnv->fnSingletons[i].hasBeenStarted = FALSE; |
| 238 semanticEnv->fnSingletons[i].hasFinished = FALSE; | 237 semanticEnv->fnSingletons[i].hasFinished = FALSE; |
| 239 semanticEnv->fnSingletons[i].waitQ = makeVMSQ(); | 238 semanticEnv->fnSingletons[i].waitQ = makeVMSQ(); |
| 240 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ(); | 239 semanticEnv->transactionStrucs[i].waitingVPQ = makeVMSQ(); |
| 241 } | 240 } |
| 241 | |
| 242 semanticEnv->numAdditionalSlvs = 0; //must be last | |
| 243 | |
| 244 #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC | |
| 245 semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128); | |
| 246 semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128); | |
| 247 semanticEnv->commDependenciesList = makeListOfArrays(sizeof(Dependency),128); | |
| 248 semanticEnv->dynDependenciesList = makeListOfArrays(sizeof(Dependency),128); | |
| 249 semanticEnv->ntonGroupsInfo = makePrivDynArrayOfSize((void***)&(semanticEnv->ntonGroups),8); | |
| 250 | |
| 251 semanticEnv->hwArcs = makeListOfArrays(sizeof(Dependency),128); | |
| 252 memset(semanticEnv->last_in_slot,0,sizeof(NUM_CORES * NUM_ANIM_SLOTS * sizeof(Unit))); | |
| 253 #endif | |
| 242 } | 254 } |
| 243 | 255 |
| 244 | 256 |
| 245 /*Frees any memory allocated by VSs__init() then calls VMS_int__shutdown | 257 /*Frees any memory allocated by VSs__init() then calls VMS_int__shutdown |
| 246 */ | 258 */ |
