changeset 188:f89bf9e368f5 false_sharing

tuning of backoff on xoanon
author Merten Sach <msach@mailbox.tu-berlin.de>
date Fri, 03 Feb 2012 19:00:04 +0100
parents c66137e4dc2f
children a8312581709c
files CoreLoop.c VMS_defs.h
diffstat 2 files changed, 21 insertions(+), 10 deletions(-) [+]
line diff
     1.1 --- a/CoreLoop.c	Fri Jan 13 11:49:05 2012 +0100
     1.2 +++ b/CoreLoop.c	Fri Feb 03 19:00:04 2012 +0100
     1.3 @@ -47,6 +47,8 @@
     1.4     int32           numMasterInARow = 0;
     1.5     volatile int32 *masterLock;
     1.6     VirtProcr      *masterVP;
     1.7 +   
     1.8 +   volatile double workspace1,workspace2; //variables for master lock busy waiting
     1.9  
    1.10     // init random number generator for retries
    1.11     uint32_t seed1 = rand()%1000;
    1.12 @@ -141,11 +143,15 @@
    1.13        while( currVP == NULL ) //if queue was empty, enter get masterLock loop
    1.14         {    //queue was empty, so get master lock
    1.15  
    1.16 -		 if(numMasterInARow > 2){
    1.17 -		 	wait_iterations=(randomNumber(&seed1, &seed2) % (numMasterInARow*numMasterInARow))*100;
    1.18 -	   		int i;
    1.19 -	  	    for(i=0; i<wait_iterations; i++)/*busy wait*/;
    1.20 -		 }
    1.21 +	if(numMasterInARow > 2){
    1.22 +                wait_iterations=(randomNumber(&seed1, &seed2) % (numMasterInARow*NUM_CORES));
    1.23 +	   	int i;
    1.24 +	  	for(i=0; i<wait_iterations; i++)
    1.25 +                {/*busy wait*/
    1.26 +                    workspace1 += (workspace1 + 32)/2;
    1.27 +                }
    1.28 +        }
    1.29 +                 
    1.30           gotLock = __sync_bool_compare_and_swap(masterLock,
    1.31                                                  UNLOCKED, LOCKED );
    1.32           if( gotLock )
    1.33 @@ -161,7 +167,10 @@
    1.34  	   wait_iterations=(randomNumber(&seed1, &seed2) % (tries+1))*100;
    1.35  	   //addToHist( wait_iterations, coreLoopThdParams->wait_iterations_hist );
    1.36  	   int i;
    1.37 -	   for(i=0; i<wait_iterations; i++)/*busy wait*/;
    1.38 +	   for(i=0; i<wait_iterations; i++)
    1.39 +           {/*busy wait*/
    1.40 +                workspace1 += (workspace1 + 32)/2;
    1.41 +           }
    1.42  	}
    1.43  
    1.44           tries++;      //if too many, means master on other core taking too long
    1.45 @@ -199,8 +208,10 @@
    1.46            _VMSMasterEnv->startMaster.longVal = endSusp.longVal;
    1.47            #endif
    1.48            //==================================================
    1.49 -   }//CoreLoop      
    1.50 - }
    1.51 +   }//CoreLoop
    1.52 +  
    1.53 +   return (void*)&workspace1; //gcc fake out for -O3
    1.54 +}
    1.55  
    1.56  inline uint32_t
    1.57  randomNumber(uint32_t* seed1, uint32_t* seed2){
     2.1 --- a/VMS_defs.h	Fri Jan 13 11:49:05 2012 +0100
     2.2 +++ b/VMS_defs.h	Fri Feb 03 19:00:04 2012 +0100
     2.3 @@ -81,7 +81,7 @@
     2.4  
     2.5     // tradeoff amortizing master fixed overhead vs imbalance potential
     2.6     // when work-stealing, can make bigger, at risk of losing cache affinity
     2.7 -#define NUM_SCHED_SLOTS  5
     2.8 +#define NUM_SCHED_SLOTS  3
     2.9  
    2.10  #define MIN_WORK_UNIT_CYCLES 20000
    2.11  
    2.12 @@ -91,7 +91,7 @@
    2.13  #define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
    2.14  
    2.15     // memory for VMS__malloc
    2.16 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
    2.17 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x40000000 /* 1G */
    2.18  
    2.19  #define CACHE_LINE 64
    2.20  #define PAGE_SIZE 4096