changeset 41:cf3e9238aeb0

Measure suspend and master times works -- refactored
author Me
date Sat, 11 Sep 2010 04:40:12 -0700
parents 1df8d7f2c9b1
children 6c9f314daf24
files Histogram/Histogram.c Histogram/Histogram.h MasterLoop.c VMS.c VMS.h
diffstat 5 files changed, 6 insertions(+), 161 deletions(-) [+]
line diff
     1.1 --- a/Histogram/Histogram.c	Sat Sep 11 03:26:07 2010 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,95 +0,0 @@
     1.4 -/*
     1.5 - *  Copyright 2010 OpenSourceStewardshipFoundation.org
     1.6 - *  Licensed under GNU General Public License version 2
     1.7 - *
     1.8 - * Author: seanhalle@yahoo.com
     1.9 - *
    1.10 - */
    1.11 -
    1.12 -#include "Histogram.h"
    1.13 -#include <malloc.h>
    1.14 -
    1.15 -
    1.16 -/*This Histogram Abstract Data Type has a number of bins plus a range of
    1.17 - * values that the bins span, both chosen at creation.
    1.18 - *
    1.19 - *One creates a Histogram instance using the makeHistogram function, then
    1.20 - * updates it with the addToHist function, and prints it out with the
    1.21 - * printHist function.
    1.22 - *
    1.23 - *Note, the bin width is an integer, so the end of the range is adjusted
    1.24 - * accordingly.  Use the bin-width to calculate the bin boundaries.
    1.25 - */
    1.26 -
    1.27 -
    1.28 -Histogram *
    1.29 -makeHistogram( int numBins, int startOfRange, int endOfRange )
    1.30 - {
    1.31 -   Histogram *hist;
    1.32 -   int i;
    1.33 -
    1.34 -   hist = malloc( sizeof(Histogram) );
    1.35 -   hist->bins = malloc( numBins * sizeof(int) );
    1.36 -
    1.37 -   hist->numBins      = numBins;
    1.38 -   hist->binWidth     = (endOfRange - startOfRange) / numBins;
    1.39 -   hist->endOfRange   = startOfRange + hist->binWidth * numBins;
    1.40 -   hist->startOfRange = startOfRange;
    1.41 -
    1.42 -   for( i = 0; i < hist->numBins; i++ )
    1.43 -    {
    1.44 -      hist->bins[ i ] = 0;
    1.45 -    }
    1.46 -
    1.47 -   return hist;
    1.48 - }
    1.49 -
    1.50 -void
    1.51 -addToHist( int value, Histogram *hist )
    1.52 - {
    1.53 -   int binIdx;
    1.54 -
    1.55 -   if( value < hist->startOfRange )
    1.56 -    { binIdx = 0;
    1.57 -    }
    1.58 -   else if( value > hist->endOfRange )
    1.59 -    { binIdx = hist->numBins - 1;
    1.60 -    }
    1.61 -   else
    1.62 -    {
    1.63 -      binIdx = (value - hist->startOfRange) / hist->binWidth;
    1.64 -    }
    1.65 -
    1.66 -   hist->bins[ binIdx ] += 1;
    1.67 - }
    1.68 -
    1.69 -void
    1.70 -printHist( Histogram *hist )
    1.71 - {
    1.72 -   int binIdx, i, numBars, maxHeight, barValue, binStart, binEnd;
    1.73 -
    1.74 -   maxHeight = 0;
    1.75 -   for( i = 0; i < hist->numBins; i++ )
    1.76 -    {
    1.77 -      if( maxHeight < hist->bins[ i ] ) maxHeight = hist->bins[ i ];
    1.78 -    }
    1.79 -   barValue = maxHeight / 60;  //60 spaces across page for tallest bin
    1.80 -
    1.81 -   printf("histogram: \n");
    1.82 -   if( barValue == 0 ) printf("error printing histogram\n");
    1.83 -   for( binIdx = 0; binIdx < hist->numBins; binIdx++ )
    1.84 -    {
    1.85 -      binStart = hist->startOfRange + hist->binWidth * binIdx;
    1.86 -      binEnd = binStart + hist->binWidth;
    1.87 -      printf("bin range: %d - %d", binStart, binEnd );
    1.88 -
    1.89 -      numBars = hist->bins[ binIdx ] / barValue;
    1.90 -         //print one bin, height of bar is num dashes across page
    1.91 -      for( i = 0; i < numBars; i++ )
    1.92 -       {
    1.93 -         printf("-");
    1.94 -       }
    1.95 -      printf("\n");
    1.96 -    }
    1.97 - }
    1.98 -
     2.1 --- a/Histogram/Histogram.h	Sat Sep 11 03:26:07 2010 -0700
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,33 +0,0 @@
     2.4 -/*
     2.5 - *  Copyright 2010 OpenSourceStewardshipFoundation.org
     2.6 - *  Licensed under GNU General Public License version 2
     2.7 - *
     2.8 - * Author: seanhalle@yahoo.com
     2.9 - *
    2.10 - */
    2.11 -
    2.12 -
    2.13 -#ifndef _HISTOGRAM_H
    2.14 -#define	_HISTOGRAM_H
    2.15 -
    2.16 -typedef struct
    2.17 - {
    2.18 -   int  startOfRange;
    2.19 -   int  endOfRange;
    2.20 -   int  numBins;
    2.21 -   int  binWidth;
    2.22 -   int *bins;
    2.23 - }
    2.24 -Histogram;
    2.25 -
    2.26 -Histogram *
    2.27 -makeHistogram( int numBins, int startOfRange, int endOfRange );
    2.28 -
    2.29 -void
    2.30 -addToHist( int value, Histogram *hist );
    2.31 -
    2.32 -void
    2.33 -printHist( Histogram *hist );
    2.34 -
    2.35 -#endif	/* _HISTOGRAM_H */
    2.36 -
     3.1 --- a/MasterLoop.c	Sat Sep 11 03:26:07 2010 -0700
     3.2 +++ b/MasterLoop.c	Sat Sep 11 04:40:12 2010 -0700
     3.3 @@ -102,7 +102,7 @@
     3.4     #ifdef MEAS__TIME_MASTER
     3.5        //Total Master time includes one coreloop time -- just assume the core
     3.6        // loop time is same for Master as for AppVPs, even though it will be
     3.7 -      // smaller due to high predictability of the jumps.
     3.8 +      // smaller due to high predictability of the fixed jmp.
     3.9     saveLowTimeStampCountInto( masterPr->startMasterTSCLow );
    3.10     #endif
    3.11     //========================================================================
    3.12 @@ -166,9 +166,6 @@
    3.13     
    3.14     #ifdef MEAS__TIME_MASTER
    3.15     saveLowTimeStampCountInto( masterPr->endMasterTSCLow );
    3.16 -      int  diff = masterPr->endMasterTSCLow - masterPr->startMasterTSCLow;
    3.17 -      if( diff > 1000000 ) diff = 0;
    3.18 -      addToHist( diff, masterEnv->measMasterHist );
    3.19     #endif
    3.20  
    3.21     asm volatile("movl %0,     %%eax;  \
     4.1 --- a/VMS.c	Sat Sep 11 03:26:07 2010 -0700
     4.2 +++ b/VMS.c	Sat Sep 11 04:40:12 2010 -0700
     4.3 @@ -128,19 +128,6 @@
     4.4  
     4.5  //   initFreeList();
     4.6  
     4.7 -   //============================= MEASUREMENT STUFF ========================
     4.8 -   #ifdef MEAS__TIME_STAMP_SUSP
     4.9 -      //RDTSC may run out of order, and so measure a time-span different
    4.10 -      // from the desired time-span  --  got some weird changes in suspend
    4.11 -      // hist when added Master hist
    4.12 -   _VMSMasterEnv->measSuspHist   = makeHistogram( 25, 110, 1300 );
    4.13 -   #endif
    4.14 -
    4.15 -   #ifdef MEAS__TIME_MASTER
    4.16 -   _VMSMasterEnv->measMasterHist = makeHistogram( 25, 500, 800 );
    4.17 -   #endif
    4.18 -   //========================================================================
    4.19 -
    4.20   }
    4.21  
    4.22  /*
    4.23 @@ -371,10 +358,12 @@
    4.24     /* clobber */ : "%eax" \
    4.25                  );
    4.26  
    4.27 +   //===========================  Measurement stuff ========================
    4.28     #ifdef MEAS__TIME_STAMP_SUSP
    4.29 -      //record time stamp: compare to time-stamp recorded below, at resume
    4.30 +      //record time stamp: compare to time-stamp recorded below
    4.31     saveLowTimeStampCountInto( animatingPr->preSuspTSCLow );
    4.32     #endif
    4.33 +   //=======================================================================
    4.34  
    4.35        //restore coreloop's frame ptr, then jump back to "start" of core loop
    4.36        //Note, GCC compiles to assembly that saves esp and ebp in the stack
    4.37 @@ -392,13 +381,8 @@
    4.38  
    4.39  ResumePt:
    4.40     #ifdef MEAS__TIME_STAMP_SUSP
    4.41 +      //NOTE: only take low part of count -- do sanity check when take diff
    4.42     saveLowTimeStampCountInto( animatingPr->postSuspTSCLow );
    4.43 -      //Take difference between the pre-suspend and post-suspend times
    4.44 -      // and do sanity check to see if rollover happened between
    4.45 -   int  diff = animatingPr->postSuspTSCLow - animatingPr->preSuspTSCLow;
    4.46 -   if( diff > 1000000 ) diff = 0;
    4.47 -   addToHist( diff, _VMSMasterEnv->measSuspHist );
    4.48 -
    4.49     #endif
    4.50  
    4.51     return;
     5.1 --- a/VMS.h	Sat Sep 11 03:26:07 2010 -0700
     5.2 +++ b/VMS.h	Sat Sep 11 04:40:12 2010 -0700
     5.3 @@ -42,7 +42,7 @@
     5.4     // stack
     5.5  #define VIRT_PROCR_STACK_SIZE 0x10000
     5.6  
     5.7 -   //256M of total memory for VMS application to VMS__malloc
     5.8 +   //256M of total memory for VMS__malloc
     5.9  #define MASSIVE_MALLOC_SIZE 0x10000000
    5.10  
    5.11  #define NUM_PREPEND_BYTES sizeof(FreeListElem) + sizeof(ownerElem);
    5.12 @@ -151,14 +151,6 @@
    5.13     int              setupComplete;
    5.14     int              masterLock;
    5.15  
    5.16 -   //============================= MEASUREMENT STUFF ========================
    5.17 -   #ifdef MEAS__TIME_STAMP_SUSP
    5.18 -   Histogram   *measSuspHist;
    5.19 -   #endif
    5.20 -   #ifdef MEAS__TIME_MASTER
    5.21 -   Histogram   *measMasterHist;
    5.22 -   #endif
    5.23 -   //========================================================================
    5.24   }
    5.25  MasterEnv;
    5.26