changeset 176:cf5faa15cb4d false_sharing

moved more variable accesses to pointers, should be optimized out anyway
author Merten Sach <msach@mailbox.tu-berlin.de>
date Tue, 20 Dec 2011 19:42:42 +0100
parents de5e7c522f1f
children c66137e4dc2f
files CoreLoop.c VMS_defs.h
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/CoreLoop.c	Tue Dec 20 19:17:11 2011 +0100
     1.2 +++ b/CoreLoop.c	Tue Dec 20 19:42:42 2011 +0100
     1.3 @@ -41,7 +41,9 @@
     1.4     int             errorCode;
     1.5     TSCountLowHigh  endSusp;
     1.6     uint64          numCycles;
     1.7 -   int32            numMasterInARow = 0;
     1.8 +   int32           numMasterInARow = 0;
     1.9 +   volatile int32 *masterLock;
    1.10 +   VirtProcr      *masterVP;
    1.11  
    1.12        //work-stealing struc on stack to prevent false-sharing in cache-line
    1.13     volatile GateStruc gate;
    1.14 @@ -86,12 +88,15 @@
    1.15     saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt));
    1.16  
    1.17     
    1.18 -   while(1){
    1.19 -   
    1.20        //Get virtual processor from queue
    1.21        //The Q must be a global, static volatile var, so not kept in reg,
    1.22        // which forces reloading the pointer after each jmp to this point
    1.23     readyToAnimateQ  = _VMSMasterEnv->readyToAnimateQs[thisCoresIdx];
    1.24 +   
    1.25 +   masterLock = &(_VMSMasterEnv->masterLockUnion.masterLock);
    1.26 +   masterVP = _VMSMasterEnv->masterVPs[thisCoresIdx];
    1.27 +
    1.28 +while(1){
    1.29  
    1.30     #ifdef USE_WORK_STEALING
    1.31        //Alg for work-stealing designed to make common case fast.  Comment
    1.32 @@ -126,11 +131,11 @@
    1.33        while( currVP == NULL ) //if queue was empty, enter get masterLock loop
    1.34         {    //queue was empty, so get master lock
    1.35  
    1.36 -         gotLock = __sync_bool_compare_and_swap(&(_VMSMasterEnv->masterLockUnion.masterLock),
    1.37 -                                                          UNLOCKED, LOCKED );
    1.38 +         gotLock = __sync_bool_compare_and_swap(masterLock,
    1.39 +                                                UNLOCKED, LOCKED );
    1.40           if( gotLock )
    1.41            {    //run own MasterVP -- jmps to coreLoops startPt when done
    1.42 -            currVP = _VMSMasterEnv->masterVPs[thisCoresIdx];
    1.43 +            currVP = masterVP;
    1.44              if( numMasterInARow > 1000 )
    1.45               {       DEBUG( dbgB2BMaster,"Many back to back MasterVPs\n");
    1.46                 pthread_yield();
     2.1 --- a/VMS_defs.h	Tue Dec 20 19:17:11 2011 +0100
     2.2 +++ b/VMS_defs.h	Tue Dec 20 19:42:42 2011 +0100
     2.3 @@ -55,7 +55,7 @@
     2.4  
     2.5  //===========================  MEASUREMENT =======================
     2.6  
     2.7 -#define MEAS__TIME_2011_SYS
     2.8 +//#define MEAS__TIME_2011_SYS
     2.9  //define this if any MEAS__... below are
    2.10  //#define MAKE_HISTS_FOR_MEASUREMENTS
    2.11     //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and