# HG changeset patch # User Some Random Person # Date 1331966455 25200 # Node ID ecbf6992dab48ff439d9088b6e850f1bb896a394 # Parent 0ee1a3c8972db6178edab0df366dcbeae843093f debugging -- made master lock padding arch indep -- changed schedSlot to animSlot diff -r 0ee1a3c8972d -r ecbf6992dab4 AnimationMaster.c --- a/AnimationMaster.c Fri Mar 16 10:43:15 2012 -0700 +++ b/AnimationMaster.c Fri Mar 16 23:40:55 2012 -0700 @@ -12,14 +12,6 @@ #include "VMS.h" -//========================= Local Fn Prototypes ============================= -void inline -stealWorkInto( SchedSlot *currSlot, VMSQueueStruc *readyToAnimateQ, - SlaveVP *masterVP ); - -//=========================================================================== - - /*The animationMaster embodies most of the animator of the language. The * animator is what emodies the behavior of language constructs. @@ -129,7 +121,7 @@ { //Used while scanning and filling animation slots int32 slotIdx, numSlotsFilled; - SchedSlot *currSlot, **schedSlots; + AnimSlot *currSlot, **animSlots; SlaveVP *assignedSlaveVP; //the slave chosen by the assigner //Local copies, for performance @@ -143,7 +135,7 @@ masterEnv = (MasterEnv*)_VMSMasterEnv; thisCoresIdx = masterVP->coreAnimatedBy; - schedSlots = masterEnv->allSchedSlots[thisCoresIdx]; + animSlots = masterEnv->allAnimSlots[thisCoresIdx]; requestHandler = masterEnv->requestHandler; slaveAssigner = masterEnv->slaveAssigner; @@ -159,7 +151,7 @@ numSlotsFilled = 0; for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) { - currSlot = schedSlots[ slotIdx ]; + currSlot = animSlots[ slotIdx ]; //Check if newly-done slave in slot, which will need request handld if( currSlot->workIsDone ) @@ -183,7 +175,7 @@ //put the chosen slave into slot, and adjust flags and state if( assignedSlaveVP != NULL ) { currSlot->slaveAssignedToSlot = assignedSlaveVP; - assignedSlaveVP->schedSlotAssignedTo = currSlot; + assignedSlaveVP->animSlotAssignedTo = currSlot; currSlot->needsSlaveAssigned = FALSE; numSlotsFilled += 1; } @@ -194,6 +186,7 @@ masterSwitchToCoreCtlr( masterVP ); flushRegisters(); + DEBUG__printf(FALSE,"came back after switch to core -- so lock released!"); }//while(1) } diff -r 0ee1a3c8972d -r ecbf6992dab4 CoreController.c --- a/CoreController.c Fri Mar 16 10:43:15 2012 -0700 +++ b/CoreController.c Fri Mar 16 23:40:55 2012 -0700 @@ -72,7 +72,7 @@ int32 thisCoresIdx; int32 numRepetitionsWithNoWork; SlaveVP *currVP; - SchedSlot *currSlot, **schedSlots; + AnimSlot *currSlot, **animSlots; int32 currSlotIdx; volatile int32 *addrOfMasterLock; //thing pointed to is volatile, not ptr SlaveVP *thisCoresMasterVP; @@ -94,7 +94,7 @@ //Assembly that saves addr of label of return instr -- label in assmbly recordCoreCtlrReturnLabelAddr((void**)&(_VMSMasterEnv->coreCtlrReturnPt)); - schedSlots = _VMSMasterEnv->allSchedSlots[thisCoresIdx]; + animSlots = _VMSMasterEnv->allAnimSlots[thisCoresIdx]; currSlotIdx = 0; //start at slot 0, go up until one empty, then do master numRepetitionsWithNoWork = 0; addrOfMasterLock = &(_VMSMasterEnv->masterLock); @@ -117,6 +117,8 @@ { pthread_cond_wait( &suspendCond, &suspendLock ); } pthread_mutex_unlock( &suspendLock ); + + DEBUG__printf1(TRUE, "started coreCtrlr", thisCoresIdx ); //====================== The Core Controller ====================== while(1) //An endless loop is just one way of doing the control structure @@ -131,10 +133,9 @@ // switchToSlv() call. Then control loops back to here. //Alternatively, the VP suspend primitive could just not bother // returning from switchToSlv, and instead jmp directly to here. - DEBUG_Print1(TRUE, "started coreCtrl", thisCoresIdx ); if( currSlotIdx >= NUM_SCHED_SLOTS ) goto switchToMaster; - currSlot = schedSlots[ currSlotIdx ]; + currSlot = animSlots[ currSlotIdx ]; if( ! currSlot->needsSlaveAssigned ) //slot does have slave assigned { numRepetitionsWithNoWork = 0; //reset back2back master count @@ -274,13 +275,13 @@ int32 thisCoresIdx; int32 numRepetitionsWithNoWork; SlaveVP *currVP; - SchedSlot *currSlot, **schedSlots; + AnimSlot *currSlot, **animSlots; int32 currSlotIdx; int32 *addrOfMasterLock; SlaveVP *thisCoresMasterVP; //=============== Initializations =================== - schedSlots = _VMSMasterEnv->allSchedSlots[thisCoresIdx]; + animSlots = _VMSMasterEnv->allAnimSlots[thisCoresIdx]; currSlotIdx = 0; //start at slot 0, go up until one empty, then do master numRepetitionsWithNoWork = 0; addrOfMasterLock = &(_VMSMasterEnv->masterLock); @@ -296,7 +297,7 @@ while(1) { if( currSlotIdx >= NUM_SCHED_SLOTS ) goto switchToMaster; - currSlot = schedSlots[ currSlotIdx ]; + currSlot = animSlots[ currSlotIdx ]; if( ! currSlot->needsSlaveAssigned ) //slot does have slave assigned { numRepetitionsWithNoWork = 0; //reset B2B master count diff -r 0ee1a3c8972d -r ecbf6992dab4 Defines/VMS_defs__turn_on_and_off.h --- a/Defines/VMS_defs__turn_on_and_off.h Fri Mar 16 10:43:15 2012 -0700 +++ b/Defines/VMS_defs__turn_on_and_off.h Fri Mar 16 23:40:55 2012 -0700 @@ -21,7 +21,7 @@ /*turns on the probe-instrumentation in the application -- when not * defined, the calls to the probe functions turn into comments */ -//#define DEBUG__TURN_ON_DEBUG_PRINT +#define DEBUG__TURN_ON_DEBUG_PRINT /*These defines turn types of bug messages on and off */ diff -r 0ee1a3c8972d -r ecbf6992dab4 Hardware_Dependent/VMS__primitives_asm.s --- a/Hardware_Dependent/VMS__primitives_asm.s Fri Mar 16 10:43:15 2012 -0700 +++ b/Hardware_Dependent/VMS__primitives_asm.s Fri Mar 16 23:40:55 2012 -0700 @@ -32,7 +32,7 @@ * * _VMSMasterEnv offsets: * 0x00 coreCtlrReturnPt - * 0x08 masterLock + * 0x100 masterLock */ .globl switchToSlv switchToSlv: @@ -57,7 +57,7 @@ * * _VMSMasterEnv offsets: * 0x00 coreCtlrReturnPt - * 0x08 masterLock + * 0x100 masterLock */ .globl switchToCoreCtlr switchToCoreCtlr: @@ -87,7 +87,7 @@ * * _VMSMasterEnv offsets: * 0x00 coreCtlrReturnPt - * 0x08 masterLock + * 0x100 masterLock */ .globl masterSwitchToCoreCtlr masterSwitchToCoreCtlr: @@ -100,7 +100,7 @@ movq $_VMSMasterEnv, %rcx movq (%rcx), %rcx #_VMSMasterEnv is pointer to struct movq 0x00(%rcx), %rax #get CoreCtlr return pt - movl $0x0 , 0x100(%rcx) #release lock + movl $0x0 , 0x100(%rcx) #release lock jmp *%rax #jmp to CoreCtlr MasterReturn: ret @@ -123,7 +123,7 @@ * * _VMSMasterEnv offsets: * 0x00 coreCtlrReturnPt - * 0x08 masterLock + * 0x100 masterLock */ .globl asmTerminateCoreCtlr asmTerminateCoreCtlr: #SlaveVP ptr is in %rdi diff -r 0ee1a3c8972d -r ecbf6992dab4 Services_Offered_by_VMS/Debugging/DEBUG__macros.h --- a/Services_Offered_by_VMS/Debugging/DEBUG__macros.h Fri Mar 16 10:43:15 2012 -0700 +++ b/Services_Offered_by_VMS/Debugging/DEBUG__macros.h Fri Mar 16 23:40:55 2012 -0700 @@ -13,16 +13,37 @@ /* */ #ifdef DEBUG__TURN_ON_DEBUG_PRINT - #define DEBUG_Print( bool, msg) \ - if( bool){ printf(msg); fflush(stdin);} - #define DEBUG_Print1( bool, msg, param) \ - if(bool){printf(msg, param); fflush(stdin);} - #define DEBUG_Print2( bool, msg, p1, p2) \ - if(bool) {printf(msg, p1, p2); fflush(stdin);} + #define DEBUG__printf( bool, msg) \ + do{\ + if(bool)\ + { printf(msg);\ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + + #define DEBUG__printf1( bool, msg, param) \ + do{\ + if(bool)\ + { printf(msg, param);\ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + + #define DEBUG__printf2( bool, msg, p1, p2) \ + do{\ + if(bool)\ + { printf(msg, p1, p2); \ + printf(" | function: %s\n", __FUNCTION__);\ + fflush(stdin);\ + }\ + }while(0);/*macro magic to isolate var-names*/ + #else - #define DEBUG_Print( bool, msg) - #define DEBUG_Print1( bool, msg, param) - #define DEBUG_Print2( bool, msg, p1, p2) + #define DEBUG__printf( bool, msg) + #define DEBUG__printf1( bool, msg, param) + #define DEBUG__printf2( bool, msg, p1, p2) #endif //============================= ERROR MSGs ============================ diff -r 0ee1a3c8972d -r ecbf6992dab4 Services_Offered_by_VMS/Measurement_and_Stats/probes.c --- a/Services_Offered_by_VMS/Measurement_and_Stats/probes.c Fri Mar 16 10:43:15 2012 -0700 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/probes.c Fri Mar 16 23:40:55 2012 -0700 @@ -199,7 +199,7 @@ VMS_impl__record_interval_start_in_probe( int32 probeID ) { IntervalProbe *probe; - DEBUG_Print( dbgProbes, "record start of interval\n" ) + DEBUG__printf( dbgProbes, "record start of interval" ) probe = _VMSMasterEnv->intervalProbes[ probeID ]; //record *start* point as last thing, after lookup @@ -253,7 +253,7 @@ #endif - DEBUG_Print( dbgProbes, "record end of interval\n" ) + DEBUG__printf( dbgProbes, "record end of interval" ) } diff -r 0ee1a3c8972d -r ecbf6992dab4 VMS.h --- a/VMS.h Fri Mar 16 10:43:15 2012 -0700 +++ b/VMS.h Fri Mar 16 23:40:55 2012 -0700 @@ -31,14 +31,14 @@ // typedef unsigned long long TSCount; -typedef struct _SchedSlot SchedSlot; +typedef struct _AnimSlot AnimSlot; typedef struct _VMSReqst VMSReqst; typedef struct _SlaveVP SlaveVP; typedef struct _MasterVP MasterVP; typedef struct _IntervalProbe IntervalProbe; -typedef SlaveVP *(*SlaveAssigner) ( void *, SchedSlot*); //semEnv, slot for HW info +typedef SlaveVP *(*SlaveAssigner) ( void *, AnimSlot*); //semEnv, slot for HW info typedef void (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv @@ -96,7 +96,7 @@ } SlotPerfInfo; -struct _SchedSlot +struct _AnimSlot { int workIsDone; int needsSlaveAssigned; @@ -106,7 +106,7 @@ int coreOfSlot; SlotPerfInfo *perfInfo; //used by assigner to pick best slave for core }; -//SchedSlot +//AnimSlot enum VPtype { Slave = 1, //default @@ -126,26 +126,27 @@ void *coreCtlrStackPtr; //restore before jmp back to core controller //============ below this, no fields are used in asm ============= - int slaveID; //each slave given a globally unique ID - int coreAnimatedBy; + + int slaveID; //each slave given a globally unique ID + int coreAnimatedBy; void *startOfStack; //used to free, and to point slave to Fn + enum VPtype typeOfVP; //Slave vs Master vs Shutdown.. + int assignCount; //Each assign is for one work-unit, so IDs it + //note, a scheduling decision is uniquely identified by the triple: + // -- used in record & replay //for comm -- between master and coreCtlr & btwn wrapper lib and plugin - SchedSlot *schedSlotAssignedTo; + AnimSlot *animSlotAssignedTo; VMSReqst *requests; //wrapper lib puts in requests, plugin takes out void *dataRetFromReq;//Return vals from plugin to Wrapper Lib - //Slave used as carrier for data + //For using Slave as carrier for data void *semanticData; //Lang saves lang-specific things in slave here - //=========== MEASUREMENT STUFF ========== - MEAS__Insert_Meas_Fields_into_Slave; - //======================================== - - enum VPtype type; - int numTimesAssigned; - - float64 createPtInSecs; //have space but don't use on some configs + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Meas_Fields_into_Slave; + float64 createPtInSecs; //time VP created, in seconds + //======================================== }; //SlaveVP @@ -155,13 +156,14 @@ typedef struct { //The offsets of these fields are hard-coded into assembly void *coreCtlrReturnPt; //offset of field used in asm - int32 masterLock __align_to_cacheline__; //used in asm - + int8 falseSharePad1[256 - sizeof(void*)]; + int32 masterLock; //offset of field used in asm + int8 falseSharePad2[256 - sizeof(int32)]; //============ below this, no fields are used in asm ============= //Basic VMS infrastructure SlaveVP **masterVPs; - SchedSlot ***allSchedSlots; + AnimSlot ***allAnimSlots; //plugin related SlaveAssigner slaveAssigner; diff -r 0ee1a3c8972d -r ecbf6992dab4 VMS__int.c --- a/VMS__int.c Fri Mar 16 10:43:15 2012 -0700 +++ b/VMS__int.c Fri Mar 16 23:40:55 2012 -0700 @@ -78,8 +78,8 @@ // "return" from this call. //animatingSlv->resumeInstrPtr = &&ResumePt; - //return ownership of the Slv and sched slot to Master virt pr - animatingSlv->schedSlotAssignedTo->workIsDone = TRUE; + //return ownership of the Slv and anim slot to Master virt pr + animatingSlv->animSlotAssignedTo->workIsDone = TRUE; MEAS__Capture_Pre_Susp_Point; switchToCoreCtlr(animatingSlv); @@ -137,9 +137,9 @@ void VMS_int__dissipate_slaveVP( SlaveVP *animatingSlv ) { + DEBUG__printf2(dbgRqstHdlr, "dissipate: %d, alive: %d",animatingSlv->slaveID, _VMSMasterEnv->numSlavesAlive-1); //dis-own all locations owned by this processor, causing to be freed // any locations that it is (was) sole owner of - _VMSMasterEnv->numSlavesAlive -= 1; if( _VMSMasterEnv->numSlavesAlive == 0 ) { //no more work, so shutdown @@ -174,9 +174,9 @@ newSlv->startOfStack = stackLocs; newSlv->slaveID = _VMSMasterEnv->numSlavesCreated++; newSlv->requests = NULL; - newSlv->schedSlotAssignedTo = NULL; - newSlv->type = Slave; - newSlv->numTimesAssigned = 0; + newSlv->animSlotAssignedTo = NULL; + newSlv->typeOfVP = Slave; + newSlv->assignCount = 0; VMS_int__point_slaveVP_to_Fn( newSlv, fnPtr, dataParam ); diff -r 0ee1a3c8972d -r ecbf6992dab4 VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Fri Mar 16 10:43:15 2012 -0700 +++ b/VMS__startup_and_shutdown.c Fri Mar 16 23:40:55 2012 -0700 @@ -28,8 +28,8 @@ //=========================================================================== -SchedSlot ** -create_sched_slots(); +AnimSlot ** +create_anim_slots(); void create_masterEnv(); @@ -82,7 +82,7 @@ printf( "\n\n Running in SEQUENTIAL mode \n\n" ); #else create_masterEnv(); - printf("Offset of lock in masterEnv:%d\n",offsetof(MasterEnv,masterLock)); + DEBUG__printf1(TRUE,"Offset of lock in masterEnv: %d ", (int32)offsetof(MasterEnv,masterLock) ); create_the_coreCtlr_OS_threads(); #endif } @@ -274,7 +274,7 @@ VMSQueueStruc **readyToAnimateQs; int coreIdx; SlaveVP **masterVPs; - SchedSlot ***allSchedSlots; //ptr to array of ptrs + AnimSlot ***allAnimSlots; //ptr to array of ptrs //Make the master env, which holds everything else @@ -294,7 +294,7 @@ masterVPs = VMS_int__malloc( NUM_CORES * sizeof(SlaveVP *) ); //One array for each core, several in array, core's masterVP scheds all - allSchedSlots = VMS_int__malloc( NUM_CORES * sizeof(SchedSlot *) ); + allAnimSlots = VMS_int__malloc( NUM_CORES * sizeof(AnimSlot *) ); _VMSMasterEnv->numSlavesAlive = 0; //used to detect shut-down condition @@ -306,12 +306,12 @@ //Q: should give masterVP core-specific info as its init data? masterVPs[ coreIdx ] = VMS_int__create_slaveVP( (TopLevelFnPtr)&animationMaster, (void*)masterEnv ); masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; - masterVPs[ coreIdx ]->type = Master; - allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core + masterVPs[ coreIdx ]->typeOfVP = Master; + allAnimSlots[ coreIdx ] = create_anim_slots(); //makes for one core } _VMSMasterEnv->masterVPs = masterVPs; _VMSMasterEnv->masterLock = UNLOCKED; - _VMSMasterEnv->allSchedSlots = allSchedSlots; + _VMSMasterEnv->allAnimSlots = allAnimSlots; _VMSMasterEnv->measHistsInfo = NULL; //============================= MEASUREMENT STUFF ======================== @@ -330,34 +330,34 @@ //======================================================================== } -SchedSlot ** -create_sched_slots() - { SchedSlot **schedSlots; +AnimSlot ** +create_anim_slots() + { AnimSlot **animSlots; int i; - schedSlots = VMS_int__malloc( NUM_SCHED_SLOTS * sizeof(SchedSlot *) ); + animSlots = VMS_int__malloc( NUM_SCHED_SLOTS * sizeof(AnimSlot *) ); for( i = 0; i < NUM_SCHED_SLOTS; i++ ) { - schedSlots[i] = VMS_int__malloc( sizeof(SchedSlot) ); + animSlots[i] = VMS_int__malloc( sizeof(AnimSlot) ); //Set state to mean "handling requests done, slot needs filling" - schedSlots[i]->workIsDone = FALSE; - schedSlots[i]->needsSlaveAssigned = TRUE; - schedSlots[i]->slotIdx = i; //quick retrieval of slot pos + animSlots[i]->workIsDone = FALSE; + animSlots[i]->needsSlaveAssigned = TRUE; + animSlots[i]->slotIdx = i; //quick retrieval of slot pos } - return schedSlots; + return animSlots; } void -freeSchedSlots( SchedSlot **schedSlots ) +freeAnimSlots( AnimSlot **animSlots ) { int i; for( i = 0; i < NUM_SCHED_SLOTS; i++ ) { - VMS_int__free( schedSlots[i] ); + VMS_int__free( animSlots[i] ); } - VMS_int__free( schedSlots ); + VMS_int__free( animSlots ); } @@ -374,6 +374,7 @@ _VMSMasterEnv->setupComplete = 0; //initialize the cond used to make the new threads wait and sync up + //must do this before *creating* the threads.. pthread_mutex_init( &suspendLock, NULL ); pthread_cond_init( &suspendCond, NULL ); @@ -400,8 +401,8 @@ void -VMS_SS__register_sched_assigner( SlaveAssigner schedAssigner ) - { _VMSMasterEnv->slaveAssigner = schedAssigner; +VMS_SS__register_anim_assigner( SlaveAssigner animAssigner ) + { _VMSMasterEnv->slaveAssigner = animAssigner; } VMS_SS__register_semantic_env( void *semanticEnv ) @@ -456,7 +457,7 @@ SlaveVP* shutdownVP; shutdownVP = VMS_int__create_slaveVP( &endOSThreadFn, NULL ); - shutdownVP->type = Shutdown; + shutdownVP->typeOfVP = Shutdown; return shutdownVP; } @@ -497,19 +498,19 @@ VMS_SS__shutdown() { int32 coreIdx; SlaveVP *shutDownSlv; - SchedSlot **schedSlots; + AnimSlot **animSlots; //create the shutdown processors, one for each core controller -- put them // directly into the Q -- each core will die when gets one for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { //Note, this is running in the master shutDownSlv = VMS_SS__create_shutdown_slave(); //last slave has dissipated, so no more in slots, so write - // shut down slave into first schedulng slot. - schedSlots = _VMSMasterEnv->allSchedSlots[ coreIdx ]; - schedSlots[0]->slaveAssignedToSlot = shutDownSlv; - schedSlots[0]->needsSlaveAssigned = FALSE; + // shut down slave into first animulng slot. + animSlots = _VMSMasterEnv->allAnimSlots[ coreIdx ]; + animSlots[0]->slaveAssignedToSlot = shutDownSlv; + animSlots[0]->needsSlaveAssigned = FALSE; shutDownSlv->coreAnimatedBy = coreIdx; - shutDownSlv->schedSlotAssignedTo = schedSlots[ 0 ]; + shutDownSlv->animSlotAssignedTo = animSlots[ 0 ]; } } @@ -562,7 +563,7 @@ /* readyToAnimateQs = _VMSMasterEnv->readyToAnimateQs; masterVPs = _VMSMasterEnv->masterVPs; - allSchedSlots = _VMSMasterEnv->allSchedSlots; + allAnimSlots = _VMSMasterEnv->allAnimSlots; for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { @@ -570,12 +571,12 @@ //master Slvs were created external to VMS, so use external free VMS_int__dissipate_slaveVP( masterVPs[ coreIdx ] ); - freeSchedSlots( allSchedSlots[ coreIdx ] ); + freeAnimSlots( allAnimSlots[ coreIdx ] ); } VMS_int__free( _VMSMasterEnv->readyToAnimateQs ); VMS_int__free( _VMSMasterEnv->masterVPs ); - VMS_int__free( _VMSMasterEnv->allSchedSlots ); + VMS_int__free( _VMSMasterEnv->allAnimSlots ); //============================= MEASUREMENT STUFF ======================== #ifdef PROBES__TURN_ON_STATS_PROBES