# HG changeset patch # User Me # Date 1289851884 28800 # Node ID bf08108405cc4e8c756c7cb58119a11b4b0b856d # Parent 13b22ffb8a2f405b55c1ae8e50fc2d3b98d7049e Added recycle pool -- will merge later -- need to get PLDI results for now diff -r 13b22ffb8a2f -r bf08108405cc CoreLoop.c --- a/CoreLoop.c Sun Nov 14 11:17:52 2010 -0800 +++ b/CoreLoop.c Mon Nov 15 12:11:24 2010 -0800 @@ -144,44 +144,25 @@ break; //end while -- have a VP to animate now } - tries++; //if too many, means master on other core taking too long - if( tries > MASTERLOCK_RETRIES ) { tries = 0; pthread_yield(); } + tries++; //if too many, means master on other core taking too long + if( tries > MASTERLOCK_RETRIES ) + { tries = 0; pthread_yield(); } } //============================= MEASUREMENT STUFF ===================== #ifdef MEAS__TIME_MASTER_LOCK saveLowTimeStampCountInto( endStamp ); + //addIntervalToHist( startStamp, endStamp, + // _VMSMasterEnv->masterLockLowTimeHist ); addIntervalToHist( startStamp, endStamp, - _VMSMasterEnv->masterLockLowTimeHist ); - addIntervalToHist( startStamp, endStamp, - _VMSMasterEnv->masterLockHighTimeHist ); + _VMSMasterEnv->masterLockHighTimeHist); #endif //===================================================================== } -/* VirtProcr offsets: - * 0xc stackPtr - * 0x10 framePtr - * 0x14 nextInstrPt - * 0x1c coreLoopFramePtr - * 0x20 coreLoopStackPtr - * - * _VMSMasterEnv offsets: - * 0x24 coreLoopStartPt - * 0x28 coreLoopEndPt - * 0x30 masterLock - */ -// SwitchToVP( currPr ) - asm volatile("movl %0, %%ebx; \ - movl %%esp, 0x20(%%ebx); \ - movl %%ebp, 0x1c(%%ebx); \ - movl 0x14(%%ebx), %%eax; \ - movl 0x0c(%%ebx), %%esp; \ - movl 0x10(%%ebx), %%ebp; \ - jmp *%%eax" \ - /* outputs */ : \ - /* inputs */ : "g"(currPr) \ - /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ - ); + + + SwitchToVP( currPr ) + //=========== jmp to here when want to shut down the VMS system ========== diff -r 13b22ffb8a2f -r bf08108405cc SwitchAnimators.h --- a/SwitchAnimators.h Sun Nov 14 11:17:52 2010 -0800 +++ b/SwitchAnimators.h Mon Nov 15 12:11:24 2010 -0800 @@ -185,9 +185,33 @@ //switch to virt procr's stack and frame ptr then jump to virt procr fn +/* VirtProcr offsets: + * 0xc stackPtr + * 0x10 framePtr + * 0x14 nextInstrPt + * 0x1c coreLoopFramePtr + * 0x20 coreLoopStackPtr + * + * _VMSMasterEnv offsets: + * 0x24 coreLoopStartPt + * 0x28 coreLoopEndPt + * 0x30 masterLock + */ #define SwitchToVP( currPr ) \ - void *stackPtr, *framePtr, *jmpPt; \ + asm volatile("movl %0, %%ebx; \ + movl %%esp, 0x20(%%ebx); \ + movl %%ebp, 0x1c(%%ebx); \ + movl 0x14(%%ebx), %%eax; \ + movl 0x0c(%%ebx), %%esp; \ + movl 0x10(%%ebx), %%ebp; \ + jmp *%%eax" \ + /* outputs */ : \ + /* inputs */ : "g"(currPr) \ + /* clobber */ : "memory", "%eax", "%ebx", "%ecx", "%edx", "%edi", "%esi" \ + ); + +// void *stackPtr, *framePtr, *jmpPt; \ \ stackPtr = currPr->stackPtr; \ framePtr = currPr->framePtr; \ diff -r 13b22ffb8a2f -r bf08108405cc VMS.c --- a/VMS.c Sun Nov 14 11:17:52 2010 -0800 +++ b/VMS.c Mon Nov 15 12:11:24 2010 -0800 @@ -776,7 +776,7 @@ freeHistExt( _VMSMasterEnv->freeTimeHist ); #endif #ifdef MEAS__TIME_MASTER_LOCK - printHist( _VMSMasterEnv->masterLockLowTimeHist ); +// printHist( _VMSMasterEnv->masterLockLowTimeHist ); printHist( _VMSMasterEnv->masterLockHighTimeHist ); #endif #ifdef MEAS__TIME_MASTER diff -r 13b22ffb8a2f -r bf08108405cc VMS.h --- a/VMS.h Sun Nov 14 11:17:52 2010 -0800 +++ b/VMS.h Mon Nov 15 12:11:24 2010 -0800 @@ -37,8 +37,8 @@ //These defines turn types of bug messages on and off // be sure debug messages are un-commented (next block of defines) +#define dbgAppFlow TRUE /* Top level flow of application code -- general*/ #define dbgProbes FALSE /* for issues inside probes themselves*/ -#define dbgAppFlow FALSE /* Top level flow of application code -- general*/ #define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/ #define dbgRqstHdlr FALSE /* in request handler code*/ @@ -63,9 +63,9 @@ // rollover of low portion into high portion. //#define MEAS__TIME_STAMP_SUSP //#define MEAS__TIME_MASTER -//#define MEAS__TIME_PLUGIN +#define MEAS__TIME_PLUGIN //#define MEAS__TIME_MALLOC -#define MEAS__TIME_MASTER_LOCK +//#define MEAS__TIME_MASTER_LOCK #define MEAS__NUM_TIMES_TO_RUN 100000 //For code that calculates normalization-offset between TSC counts of diff -r 13b22ffb8a2f -r bf08108405cc vmalloc.c --- a/vmalloc.c Sun Nov 14 11:17:52 2010 -0800 +++ b/vmalloc.c Mon Nov 15 12:11:24 2010 -0800 @@ -11,6 +11,8 @@ #include #include "VMS.h" +#include "DynArray/DynArray.h" +#include "Queue_impl/PrivateQueue.h" /*Helper function *Insert a newly generated free chunk into the first spot on the free list. @@ -352,3 +354,72 @@ // array when all the free lists linked from it have already been freed } + + +void +add_array_to_recycle_pool( VMSRecyclePool *pool ) + { void *newArray; + int32 idxToNewArray; + + newArray = VMS__malloc( pool->currArraySize ); + idxToNewArray = addToDynArray( newArray, pool->arraysInfo ); + + pool->ptrToNextStruct = pool->arrays[ idxToNewArray ]; + pool->ptrToTopOfCurrArray = pool->ptrToNextStruct + + pool->currArraySize - 1; + + pool->currArraySize += pool->currArraySize >> 2; //mult by 1.25 + pool->hasNewStructs = TRUE; + } + +VMSRecyclePool * +VMS__make_recycle_pool( int32 sizeOfStructsToHold ) + { VMSRecyclePool *pool; + + pool = VMS__malloc( sizeof(VMSRecyclePool) ); + pool->recycleQ = makeVMSPrivQ(); + pool->arraysInfo = makePrivDynArrayOfSize( &(pool->arrays), 64 ); + pool->sizeOfStructs = sizeOfStructsToHold; + pool->currArraySize = 64 * sizeOfStructsToHold; //64 makes aligned as well + add_array_to_recycle_pool( pool ); + } + +void * +VMS__get_from_recycle_pool( VMSRecyclePool *pool ) + { void *retStruct; + + if( pool->hasNewStructs ) + { + ReStart: + retStruct = pool->ptrToNextStruct; + pool->ptrToNextStruct += pool->sizeOfStructs; + if( pool->ptrToNextStruct < pool->ptrToTopOfCurrArray ) + return retStruct; + else + { pool->hasNewStructs = FALSE; + //fall-through to code after top IF + } + } + + retStruct = readPrivQ( pool->recycleQ ); + if( retStruct != NULL ) return retStruct; + else + { add_array_to_recycle_pool( pool ); + goto ReStart; + } + } + +void +VMS__recycle( void *chunkToRecycle, VMSRecyclePool *pool ) + { //PrivQ self-expands when writing + writePrivQ( chunkToRecycle, pool->recycleQ ); + } + +void +VMS__free_recycle_pool( VMSRecyclePool *pool ) + { int32 i; + + freeDynArrayDeep( pool->arraysInfo, &VMS__free ); + freePrivQ( pool->recycleQ ); + VMS__free( pool ); + } diff -r 13b22ffb8a2f -r bf08108405cc vmalloc.h --- a/vmalloc.h Sun Nov 14 11:17:52 2010 -0800 +++ b/vmalloc.h Mon Nov 15 12:11:24 2010 -0800 @@ -31,6 +31,19 @@ } FreeListHead; +typedef struct + { + int32 hasNewStructs; + int32 sizeOfStructs; + int32 currArraySize; + void **arrays; + PrivDynArrayInfo *arraysInfo; + char *ptrToNextStruct; + char *ptrToTopOfCurrArray; + PrivQueueStruc *recycleQ; + } +VMSRecyclePool; + void * VMS__malloc( int32 sizeRequested ); @@ -54,4 +67,18 @@ void VMS_ext__free_free_list( MallocProlog *freeListHead ); +//========================================================================== + +VMSRecyclePool * +VMS__make_recycle_pool( int32 sizeOfStructsToHold ); + +void * +VMS__get_from_recycle_pool( VMSRecyclePool *pool ); + +void +VMS__recycle( void *chunkToRecycle, VMSRecyclePool *pool ); + +void +VMS__free_recycle_pool( VMSRecyclePool *pool ); + #endif \ No newline at end of file