Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff MasterLoop.c @ 120:d4c881c7f03a
Added fn to send inter-master requests, and cleaned up code
| author | Me@portablequad |
|---|---|
| date | Sat, 03 Sep 2011 20:41:51 -0700 |
| parents | ac11b50220bd |
| children | 24466227d8bb |
line diff
1.1 --- a/MasterLoop.c Tue Aug 30 21:55:04 2011 -0700 1.2 +++ b/MasterLoop.c Sat Sep 03 20:41:51 2011 -0700 1.3 @@ -49,9 +49,7 @@ 1.4 *So VMS__init just births the master virtual processor same way it births 1.5 * all the others -- then does any extra setup needed and puts it into the 1.6 * work queue. 1.7 - *However means have to make masterEnv a global static volatile the same way 1.8 - * did with readyToAnimateQ in core loop. -- for performance, put the 1.9 - * jump to the core loop directly in here, and have it directly jump back. 1.10 + *However means have to make masterEnv a global static volatile. 1.11 * 1.12 * 1.13 *Aug 18, 2010 -- Going to a separate MasterVP for each core, to see if this 1.14 @@ -60,7 +58,7 @@ 1.15 * 1.16 *So, this function is coupled to each of the MasterVPs, -- meaning this 1.17 * function can't rely on a particular stack and frame -- each MasterVP that 1.18 - * animates this function has a different one. 1.19 + * animates this function has a different stack. 1.20 * 1.21 *At this point, the masterLoop does not write itself into the queue anymore, 1.22 * instead, the coreLoop acquires the masterLock when it has nothing to 1.23 @@ -96,24 +94,17 @@ 1.24 //So, setup values about stack ptr, jmp pt and all that 1.25 //masterPr->nextInstrPt = &&masterLoopStartPt; 1.26 1.27 - 1.28 - //Note, got rid of writing the stack and frame ptr up here, because 1.29 - // only one 1.30 - // core can ever animate a given MasterVP, so don't need to communicate 1.31 - // new frame and stack ptr to the MasterVP storage before a second 1.32 - // version of that MasterVP can get animated on a different core. 1.33 - //Also got rid of the busy-wait. 1.34 - 1.35 - 1.36 - //masterLoopStartPt: 1.37 - //The animating materVP suspends at end of this loop, then later resumes and 1.38 - // comes back here 1.39 - while(1){ 1.40 + //Sept 2011 1.41 + //Old code jumped directly to this point, but doesn't work on x64 1.42 + // So, just make this an endless loop, and do assembly function at end 1.43 + // that saves its own return addr, then jumps to core_loop. 1.44 + while(1) 1.45 + { 1.46 1.47 //============================= MEASUREMENT STUFF ======================== 1.48 #ifdef MEAS__TIME_MASTER 1.49 //Total Master time includes one coreloop time -- just assume the core 1.50 - // loop time is same for Master as for AppVPs, even though it may be 1.51 + // loop time is same for Master as is for AppVPs, even though it may be 1.52 // smaller due to higher predictability of the fixed jmp. 1.53 saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); 1.54 #endif 1.55 @@ -122,7 +113,7 @@ 1.56 masterEnv = (MasterEnv*)_VMSMasterEnv; 1.57 1.58 //GCC may optimize so doesn't always re-define from frame-storage 1.59 - masterPr = (VirtProcr*)volatileMasterPr; //on stack, to be sure after jmp 1.60 + masterPr = (VirtProcr*)volatileMasterPr; //on stack, reload after jmp 1.61 thisCoresIdx = masterPr->coreAnimatedBy; 1.62 readyToAnimateQ = masterEnv->readyToAnimateQs[thisCoresIdx]; 1.63 schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; 1.64 @@ -132,15 +123,15 @@ 1.65 semanticEnv = masterEnv->semanticEnv; 1.66 1.67 //First, check for requests from other MasterVPs, and handle them 1.68 - if( masterEnv->requestsWaitingFor[thisCoresIdx] ) 1.69 - { masterReqQ = masterEnv->masterReqQs[thisCoresIdx]; 1.70 - while( currReq = readVMSQ(masterReqQ) ) 1.71 - { handleMasterReq( currReq, semanticEnv, masterPr ); 1.72 - } 1.73 - } 1.74 + if( currReq = masterEnv->interMasterRequestsFor[thisCoresIdx] ) 1.75 + { do 1.76 + { handleInterMasterReq( currReq, semanticEnv, masterPr ); 1.77 + } 1.78 + while( currReq = currReq->nextReqst ); 1.79 + } 1.80 //Now, take care of the SlaveVPs 1.81 - //Go through the slots -- if Slave there newly suspended, handle its request 1.82 - // then, either way, ask assigner to fill each slot 1.83 + //Go through the slots -- if Slave there newly suspended, handle its request 1.84 + // then, either way, ask assigner to fill each slot 1.85 numSlotsFilled = 0; 1.86 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) 1.87 { 1.88 @@ -208,14 +199,15 @@ 1.89 * master_loop, others are handed off to the plugin. 1.90 */ 1.91 void inline 1.92 -handleMasterReq( MasterReq *currReq, void *_semEnv, VirtProcr *masterPr ) 1.93 - { 1.94 - switch( currReq->reqType ) 1.95 - { case interVMSReq: 1.96 - handleInterVMSReq( (InterVMSCoreReq *)currReq, masterPr); 1.97 +handleInterMasterReq( InterMasterReqst *currReq, void *_semEnv, 1.98 + VirtProcr *masterPr ) 1.99 + { switch( currReq->reqType ) 1.100 + { case destVMSCore: 1.101 + handleInterVMSCoreReq( (InterVMSCoreReqst *)currReq, masterPr); 1.102 break; 1.103 - case interPluginReq: 1.104 - (*interPluginReqHdlr)( (InterPluginReq *)currReq, _semEnv ); 1.105 + case destPlugin: 1.106 + (*interPluginReqHdlr)( ((InterPluginReqst *)currReq)->pluginReq, 1.107 + _semEnv ); 1.108 break; 1.109 default: 1.110 break; 1.111 @@ -223,15 +215,16 @@ 1.112 } 1.113 1.114 void inline 1.115 -handleInterVMSReq( InterVMSCoreReq *currReq, VirtProcr *masterPr ) 1.116 +handleInterVMSReq( InterVMSCoreReqst *currReq, VirtProcr *masterPr ) 1.117 { 1.118 switch( currReq->reqType ) 1.119 { 1.120 - case transfer_free: handleTransferFree( currReq, masterPr ); 1.121 + case transfer_free_ptr: handleTransferFree( currReq, masterPr ); 1.122 break; 1.123 } 1.124 } 1.125 1.126 + 1.127 1.128 /*Work Stealing Alg -- racy one 1.129 *This algorithm has a race condition -- the coreloops are accessing their
