Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 189:91d0d2e06719 false_sharing
backoff won't be optimized out by gcc
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 03 Feb 2012 17:57:09 +0100 |
| parents | c66137e4dc2f |
| children | a8312581709c |
| files | CoreLoop.c MasterLoop.c |
| diffstat | 2 files changed, 23 insertions(+), 11 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Fri Jan 13 11:49:05 2012 +0100 1.2 +++ b/CoreLoop.c Fri Feb 03 17:57:09 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 + 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,16 @@ 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*numMasterInARow))*100; 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 + workspace2 += (workspace2 + 23.2)/1.4; 1.28 + } 1.29 + } 1.30 + 1.31 gotLock = __sync_bool_compare_and_swap(masterLock, 1.32 UNLOCKED, LOCKED ); 1.33 if( gotLock ) 1.34 @@ -161,7 +168,11 @@ 1.35 wait_iterations=(randomNumber(&seed1, &seed2) % (tries+1))*100; 1.36 //addToHist( wait_iterations, coreLoopThdParams->wait_iterations_hist ); 1.37 int i; 1.38 - for(i=0; i<wait_iterations; i++)/*busy wait*/; 1.39 + for(i=0; i<wait_iterations; i++) 1.40 + {/*busy wait*/ 1.41 + workspace1 += (workspace1 + 32)/2; 1.42 + workspace2 += (workspace2 + 23.2)/1.4; 1.43 + } 1.44 } 1.45 1.46 tries++; //if too many, means master on other core taking too long 1.47 @@ -199,7 +210,9 @@ 1.48 _VMSMasterEnv->startMaster.longVal = endSusp.longVal; 1.49 #endif 1.50 //================================================== 1.51 - }//CoreLoop 1.52 + }//CoreLoop 1.53 + 1.54 + return (workspace1 + workspace2); //gcc fake out for -O3 1.55 } 1.56 1.57 inline uint32_t
2.1 --- a/MasterLoop.c Fri Jan 13 11:49:05 2012 +0100 2.2 +++ b/MasterLoop.c Fri Feb 03 17:57:09 2012 +0100 2.3 @@ -106,7 +106,6 @@ 2.4 slaveScheduler = masterEnv->slaveScheduler; 2.5 semanticEnv = masterEnv->semanticEnv; 2.6 2.7 - //masterLoopStartPt: 2.8 while(1){ //switch to core_loop and back to here is at end of loop 2.9 2.10 //============================= MEASUREMENT STUFF ======================= 2.11 @@ -120,10 +119,10 @@ 2.12 2.13 2.14 //Poll each slot's Done flag 2.15 - numSlotsFilled = 0; 2.16 - /* 2.17 + numSlotsFilled = 0; 2.18 + /* 2.19 Meas_startMasterLoop 2.20 - */ 2.21 + */ 2.22 for( slotIdx = 0; slotIdx < NUM_SCHED_SLOTS; slotIdx++) 2.23 { 2.24 currSlot = schedSlots[ slotIdx ];
