# HG changeset patch # User Me # Date 1284205212 25200 # Node ID cf3e9238aeb07849ff7992d7f95f1d392e5a9a9a # Parent 1df8d7f2c9b10e2faf06d836e73a2dbfac389083 Measure suspend and master times works -- refactored diff -r 1df8d7f2c9b1 -r cf3e9238aeb0 Histogram/Histogram.c --- a/Histogram/Histogram.c Sat Sep 11 03:26:07 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -/* - * Copyright 2010 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - -#include "Histogram.h" -#include - - -/*This Histogram Abstract Data Type has a number of bins plus a range of - * values that the bins span, both chosen at creation. - * - *One creates a Histogram instance using the makeHistogram function, then - * updates it with the addToHist function, and prints it out with the - * printHist function. - * - *Note, the bin width is an integer, so the end of the range is adjusted - * accordingly. Use the bin-width to calculate the bin boundaries. - */ - - -Histogram * -makeHistogram( int numBins, int startOfRange, int endOfRange ) - { - Histogram *hist; - int i; - - hist = malloc( sizeof(Histogram) ); - hist->bins = malloc( numBins * sizeof(int) ); - - hist->numBins = numBins; - hist->binWidth = (endOfRange - startOfRange) / numBins; - hist->endOfRange = startOfRange + hist->binWidth * numBins; - hist->startOfRange = startOfRange; - - for( i = 0; i < hist->numBins; i++ ) - { - hist->bins[ i ] = 0; - } - - return hist; - } - -void -addToHist( int value, Histogram *hist ) - { - int binIdx; - - if( value < hist->startOfRange ) - { binIdx = 0; - } - else if( value > hist->endOfRange ) - { binIdx = hist->numBins - 1; - } - else - { - binIdx = (value - hist->startOfRange) / hist->binWidth; - } - - hist->bins[ binIdx ] += 1; - } - -void -printHist( Histogram *hist ) - { - int binIdx, i, numBars, maxHeight, barValue, binStart, binEnd; - - maxHeight = 0; - for( i = 0; i < hist->numBins; i++ ) - { - if( maxHeight < hist->bins[ i ] ) maxHeight = hist->bins[ i ]; - } - barValue = maxHeight / 60; //60 spaces across page for tallest bin - - printf("histogram: \n"); - if( barValue == 0 ) printf("error printing histogram\n"); - for( binIdx = 0; binIdx < hist->numBins; binIdx++ ) - { - binStart = hist->startOfRange + hist->binWidth * binIdx; - binEnd = binStart + hist->binWidth; - printf("bin range: %d - %d", binStart, binEnd ); - - numBars = hist->bins[ binIdx ] / barValue; - //print one bin, height of bar is num dashes across page - for( i = 0; i < numBars; i++ ) - { - printf("-"); - } - printf("\n"); - } - } - diff -r 1df8d7f2c9b1 -r cf3e9238aeb0 Histogram/Histogram.h --- a/Histogram/Histogram.h Sat Sep 11 03:26:07 2010 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright 2010 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - * - * Author: seanhalle@yahoo.com - * - */ - - -#ifndef _HISTOGRAM_H -#define _HISTOGRAM_H - -typedef struct - { - int startOfRange; - int endOfRange; - int numBins; - int binWidth; - int *bins; - } -Histogram; - -Histogram * -makeHistogram( int numBins, int startOfRange, int endOfRange ); - -void -addToHist( int value, Histogram *hist ); - -void -printHist( Histogram *hist ); - -#endif /* _HISTOGRAM_H */ - diff -r 1df8d7f2c9b1 -r cf3e9238aeb0 MasterLoop.c --- a/MasterLoop.c Sat Sep 11 03:26:07 2010 -0700 +++ b/MasterLoop.c Sat Sep 11 04:40:12 2010 -0700 @@ -102,7 +102,7 @@ #ifdef MEAS__TIME_MASTER //Total Master time includes one coreloop time -- just assume the core // loop time is same for Master as for AppVPs, even though it will be - // smaller due to high predictability of the jumps. + // smaller due to high predictability of the fixed jmp. saveLowTimeStampCountInto( masterPr->startMasterTSCLow ); #endif //======================================================================== @@ -166,9 +166,6 @@ #ifdef MEAS__TIME_MASTER saveLowTimeStampCountInto( masterPr->endMasterTSCLow ); - int diff = masterPr->endMasterTSCLow - masterPr->startMasterTSCLow; - if( diff > 1000000 ) diff = 0; - addToHist( diff, masterEnv->measMasterHist ); #endif asm volatile("movl %0, %%eax; \ diff -r 1df8d7f2c9b1 -r cf3e9238aeb0 VMS.c --- a/VMS.c Sat Sep 11 03:26:07 2010 -0700 +++ b/VMS.c Sat Sep 11 04:40:12 2010 -0700 @@ -128,19 +128,6 @@ // initFreeList(); - //============================= MEASUREMENT STUFF ======================== - #ifdef MEAS__TIME_STAMP_SUSP - //RDTSC may run out of order, and so measure a time-span different - // from the desired time-span -- got some weird changes in suspend - // hist when added Master hist - _VMSMasterEnv->measSuspHist = makeHistogram( 25, 110, 1300 ); - #endif - - #ifdef MEAS__TIME_MASTER - _VMSMasterEnv->measMasterHist = makeHistogram( 25, 500, 800 ); - #endif - //======================================================================== - } /* @@ -371,10 +358,12 @@ /* clobber */ : "%eax" \ ); + //=========================== Measurement stuff ======================== #ifdef MEAS__TIME_STAMP_SUSP - //record time stamp: compare to time-stamp recorded below, at resume + //record time stamp: compare to time-stamp recorded below saveLowTimeStampCountInto( animatingPr->preSuspTSCLow ); #endif + //======================================================================= //restore coreloop's frame ptr, then jump back to "start" of core loop //Note, GCC compiles to assembly that saves esp and ebp in the stack @@ -392,13 +381,8 @@ ResumePt: #ifdef MEAS__TIME_STAMP_SUSP + //NOTE: only take low part of count -- do sanity check when take diff saveLowTimeStampCountInto( animatingPr->postSuspTSCLow ); - //Take difference between the pre-suspend and post-suspend times - // and do sanity check to see if rollover happened between - int diff = animatingPr->postSuspTSCLow - animatingPr->preSuspTSCLow; - if( diff > 1000000 ) diff = 0; - addToHist( diff, _VMSMasterEnv->measSuspHist ); - #endif return; diff -r 1df8d7f2c9b1 -r cf3e9238aeb0 VMS.h --- a/VMS.h Sat Sep 11 03:26:07 2010 -0700 +++ b/VMS.h Sat Sep 11 04:40:12 2010 -0700 @@ -42,7 +42,7 @@ // stack #define VIRT_PROCR_STACK_SIZE 0x10000 - //256M of total memory for VMS application to VMS__malloc + //256M of total memory for VMS__malloc #define MASSIVE_MALLOC_SIZE 0x10000000 #define NUM_PREPEND_BYTES sizeof(FreeListElem) + sizeof(ownerElem); @@ -151,14 +151,6 @@ int setupComplete; int masterLock; - //============================= MEASUREMENT STUFF ======================== - #ifdef MEAS__TIME_STAMP_SUSP - Histogram *measSuspHist; - #endif - #ifdef MEAS__TIME_MASTER - Histogram *measMasterHist; - #endif - //======================================================================== } MasterEnv;