# HG changeset patch # User Sean Halle # Date 1345717263 25200 # Node ID 459055db7fc05c9729ced0752225192967a8c589 # Parent b2bc973182627ef8d9d6837717f44339ef492692 bug fix -- shutsdown correctly now -- count extra task slaves correctly diff -r b2bc97318262 -r 459055db7fc0 VSs.c --- a/VSs.c Thu Aug 23 01:27:26 2012 -0700 +++ b/VSs.c Thu Aug 23 03:21:03 2012 -0700 @@ -191,9 +191,6 @@ //Hook up the semantic layer's plug-ins to the Master virt procr _VMSMasterEnv->requestHandler = &VSs__Request_Handler; _VMSMasterEnv->slaveAssigner = &VSs__assign_slaveVP_to_slot; - #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS - _VMSMasterEnv->counterHandler = &VSs__counter_handler; - #endif //create the semantic layer's environment (all its data) and add to // the master environment @@ -201,6 +198,7 @@ _VMSMasterEnv->semanticEnv = semanticEnv; #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS + _VMSMasterEnv->counterHandler = &VSs__counter_handler; VSs__init_counter_data_structs(); #endif @@ -255,7 +253,7 @@ } semanticEnv->numLiveExtraTaskSlvs = 0; //must be last - semanticEnv->numLiveThreadSlvs = 1; //must be last, count the seed + semanticEnv->numLiveThreadSlvs = 1; //must be last, counts the seed #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128); diff -r b2bc97318262 -r 459055db7fc0 VSs_PluginFns.c --- a/VSs_PluginFns.c Thu Aug 23 01:27:26 2012 -0700 +++ b/VSs_PluginFns.c Thu Aug 23 03:21:03 2012 -0700 @@ -62,15 +62,19 @@ semEnv = (VSsSemEnv *)_semEnv; - returnSlv = readPrivQ( semEnv->slavesReadyToResumeQ ); - if( returnSlv != NULL ) //Yes, have a slave, so return it. - { returnSlv->coreAnimatedBy = coreNum; - if( semEnv->coreIsDone[coreNum] == TRUE ) //reads are higher perf - semEnv->coreIsDone[coreNum] = FALSE; //don't just write always - goto ReturnTheSlv; - } - //Speculatively set the return slave to the slot taskSlave - //TODO: false sharing ? Always read.. + //Check for suspended slaves that are ready to resume + returnSlv = readPrivQ( semEnv->slavesReadyToResumeQ ); + if( returnSlv != NULL ) //Yes, have a slave, so return it. + { returnSlv->coreAnimatedBy = coreNum; + + //have work, so reset Done flag (when work generated on other core) + if( semEnv->coreIsDone[coreNum] == TRUE ) //reads are higher perf + semEnv->coreIsDone[coreNum] = FALSE; //don't just write always + goto ReturnTheSlv; + } + + //If none, speculate will have a task, so get the slot slave + //TODO: false sharing ? (think not bad cause mostly read..) returnSlv = semEnv->slotTaskSlvs[coreNum][slotNum]; semData = (VSsSemData *)returnSlv->semanticData; @@ -85,17 +89,18 @@ semData->taskStub = newTaskStub; newTaskStub->slaveAssignedTo = returnSlv; semData->needsTaskAssigned = FALSE; + + //have work, so reset Done flag, if was set if( semEnv->coreIsDone[coreNum] == TRUE ) //reads are higher perf semEnv->coreIsDone[coreNum] = FALSE; //don't just write always goto ReturnTheSlv; } else - { //no task, so try to get a ready to resume slave - - //If get here, then no task, so check if have extra free slaves + { //no task, so try to clean up unused extra task slaves extraSlv = readPrivQ( semEnv->freeExtraTaskSlvQ ); if( extraSlv != NULL ) - { //means have two slaves need tasks -- redundant, kill one + { //have two slaves need tasks, so delete one + //This both bounds the num extras, and delivers shutdown cond handleDissipate( extraSlv, semEnv ); //then return NULL returnSlv = NULL; @@ -104,7 +109,7 @@ else { //candidate for shutdown.. if all extras dissipated, and no tasks // and no ready to resume slaves, then no way to generate - // more tasks.. + // more tasks (on this core -- other core might have task still) if( semEnv->numLiveExtraTaskSlvs == 0 && semEnv->numLiveThreadSlvs == 0 ) { //This core sees no way to generate more tasks, so say it @@ -113,6 +118,7 @@ semEnv->coreIsDone[coreNum] = TRUE; #ifdef DEBUG__TURN_ON_SEQUENTIAL_MODE semEnv->shutdownInitiated = TRUE; + #else if( semEnv->numCoresDone == NUM_CORES ) { //means no cores have work, and none can generate more @@ -137,9 +143,7 @@ #ifdef HOLISTIC__TURN_ON_OBSERVE_UCC if( returnSlv == NULL ) { returnSlv = semEnv->idleSlv[coreNum][slotNum]; - if(semEnv->shutdownInitiated) - { returnSlv = VMS_SS__create_shutdown_slave(); - } + //things that would normally happen in resume(), but these VPs // never go there returnSlv->assignCount++; //Somewhere here! @@ -290,6 +294,7 @@ //if make it to here, then is a thread slave ending semEnv->numLiveThreadSlvs -= 1; //for detecting shutdown condition + ownTaskStub = semData->taskStub; parentTaskStub = ownTaskStub->parentTaskStub; parentTaskStub->numLiveChildThreads -= 1; //not freed, even if ended @@ -319,12 +324,15 @@ parentTaskStub->numLiveChildThreads == 0 ) free_task_stub( parentTaskStub ); //just stub, semData already freed } - + //Free the semData and requesting slave's base state for all cases FreeSlaveStateAndReturn: VMS_PI__free( semData ); VMS_PI__dissipate_slaveVP( requestingSlv ); return; + //Note, this is not a location to check for shutdown because doesn't + // say anything about work availability here.. check for shutdown in + // places try to get work for the core (in the assigner) } @@ -347,7 +355,7 @@ semData->highestTransEntered = -1; semData->lastTransEntered = NULL; semData->needsTaskAssigned = TRUE; - semData->taskStub =NULL; + semData->taskStub = NULL; newSlv->semanticData = semData; @@ -371,7 +379,7 @@ } #endif //======================================================================== - + return newSlv; } diff -r b2bc97318262 -r 459055db7fc0 VSs_Request_Handlers.c --- a/VSs_Request_Handlers.c Thu Aug 23 01:27:26 2012 -0700 +++ b/VSs_Request_Handlers.c Thu Aug 23 03:21:03 2012 -0700 @@ -915,6 +915,8 @@ newSlotSlv = readPrivQ( semEnv->freeExtraTaskSlvQ ); if( newSlotSlv == NULL ) { newSlotSlv = VSs__create_slave_helper( &idle_fn, NULL, semEnv, 0); + //just made a new extra task slave, so count it + semEnv->numLiveExtraTaskSlvs += 1; } //set slave values to make it the slot slave