Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnBenchScheduler Class Reference

A frame scheduler that produces execution time information. More...

#include <PsnBenchScheduler.h>

Inheritance diagram for PsnBenchScheduler:

Inheritance graph
[legend]
Collaboration diagram for PsnBenchScheduler:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnBenchScheduler (unsigned int numberOfSteps, const int &indiceEchantillon, unsigned int _numberOfSamples, ostream &outputFile)
 constructor

virtual ~PsnBenchScheduler ()
 destructor

virtual void addToScheduable (PsnReferenceObjectHandle *ref, unsigned int when)
 redefine to create the adequate data structures for the added object

virtual void removeFromScheduable (PsnReferenceObjectHandle *ref)
 redefine to destroy specific data structures for the removed object

virtual void runStep (unsigned int which)
 redefine to bench each execution time for each object


Protected Attributes

map< PsnReferenceObjectHandle *,
long * > 
_tabVitesse
const int & _sampleIndex
int _numberOfSamples
ostream & _outputFile

Detailed Description

A frame scheduler that produces execution time information.

Definition at line 29 of file PsnBenchScheduler.h.


Constructor & Destructor Documentation

PsnBenchScheduler::PsnBenchScheduler unsigned int    numberOfSteps,
const int &    indiceEchantillon,
unsigned int    _numberOfSamples,
ostream &    outputFile
 

constructor

Definition at line 27 of file PsnBenchScheduler.cxx.

00031    : PsnFrameScheduler ( numberOfSteps ),
00032      _sampleIndex ( _sampleIndex ),
00033      _numberOfSamples( _numberOfSamples ),
00034      _outputFile ( outputFile )
00035 {
00036 
00037 }

PsnBenchScheduler::~PsnBenchScheduler   [virtual]
 

destructor

Definition at line 39 of file PsnBenchScheduler.cxx.

References _numberOfSamples, _outputFile, _tabVitesse, map< PsnReferenceObjectHandle *, long * >::begin(), and map< PsnReferenceObjectHandle *, long * >::end().

00040 {
00041    assert (_outputFile.good() ) ;
00042    map<PsnReferenceObjectHandle *, long*>::iterator pTab;
00043    long moyenne ;
00044    long nbValeurs ;
00045    for (pTab= _tabVitesse.begin();
00046         pTab != _tabVitesse.end(); 
00047         pTab++)
00048       {
00049          //make sure the object still exists 
00050          assert ( dynamic_cast<const PsSimulatedObject *>( &((*pTab).first->getSimulatedObject() ) ) );
00051          _outputFile<<"Table des temps pour "<<(*pTab).first->getSimulatedObject().getObjectDescriptor().getName()<<endl;;
00052          moyenne=0;
00053          nbValeurs=0;
00054          for(int i=0;i<_numberOfSamples;i++) {
00055             long duree=(*pTab).second[i];
00056             _outputFile<<duree<<endl;
00057             if (duree>=0) {
00058 #ifdef _SGI
00059                moyenne = moyenne+(duree/1000);
00060 #else
00061                moyenne +=duree ;
00062 #endif
00063                nbValeurs++;
00064             }
00065          }
00066          _outputFile<<"Average running time for "<<(*pTab).first->getSimulatedObject().getName()<<": "<<moyenne/nbValeurs<<" microseconds"<<endl; 
00067       }
00068 }


Member Function Documentation

void PsnBenchScheduler::addToScheduable PsnReferenceObjectHandle   ref,
unsigned int    when
[virtual]
 

redefine to create the adequate data structures for the added object

Reimplemented from PsnFrameScheduler.

Definition at line 70 of file PsnBenchScheduler.cxx.

References _numberOfSamples, _tabVitesse, PsnFrameScheduler::addToScheduable(), map< PsnReferenceObjectHandle *, long * >::end(), and map< PsnReferenceObjectHandle *, long * >::find().

00070                                                                                           {
00071    PsnFrameScheduler::addToScheduable( ref , when ) ;
00072    if ( _tabVitesse.find (ref) == _tabVitesse.end() ) {
00073       //to avoid multiple creation in multi-fréquential mode
00074       _tabVitesse [ ref ] = new long[ _numberOfSamples ];
00075    }
00076 }

void PsnBenchScheduler::removeFromScheduable PsnReferenceObjectHandle   ref [virtual]
 

redefine to destroy specific data structures for the removed object

Reimplemented from PsnFrameScheduler.

Definition at line 80 of file PsnBenchScheduler.cxx.

References _numberOfSamples, _outputFile, _tabVitesse, map< PsnReferenceObjectHandle *, long * >::end(), map< PsnReferenceObjectHandle *, long * >::erase(), map< PsnReferenceObjectHandle *, long * >::find(), and PsnFrameScheduler::removeFromScheduable().

00080                                                                            {
00081    PsnFrameScheduler::removeFromScheduable( ref ) ;
00082    assert ( _tabVitesse.find (ref) != _tabVitesse.end() ) ;
00083 
00084    map<PsnReferenceObjectHandle *, long*>::iterator pTab = _tabVitesse.find (ref) ;
00085 
00086    assert ( dynamic_cast<const PsSimulatedObject *>( &(*pTab).first->getSimulatedObject() ) );
00087 
00088    long moyenne=0;
00089    long nbValeurs=0;
00090    for(int i=0;i<_numberOfSamples;i++) {
00091       long duree=(*pTab).second[i];
00092       //_outputFile<<duree<<endl;
00093       if (duree>=0) {
00094 #ifdef _SGI
00095          moyenne = moyenne+(duree/1000);
00096 #else
00097          moyenne +=duree ;
00098 #endif
00099          nbValeurs++;
00100       }
00101    }
00102    _outputFile<<"Average compute time of "<<(*pTab).first->getSimulatedObject().getObjectDescriptor().getName()<<": "<<moyenne/nbValeurs<<" microsecondes (computed using "<<nbValeurs<<" samples)"<<endl;    
00103    delete [] ( _tabVitesse[ ref ] ) ;
00104    _tabVitesse.erase( ref ) ; 
00105 }

void PsnBenchScheduler::runStep unsigned int    which [virtual]
 

redefine to bench each execution time for each object

Reimplemented from PsnFrameScheduler.

Definition at line 109 of file PsnBenchScheduler.cxx.

References _sampleIndex, _tabVitesse, PsnDoubleList::begin(), map< PsnReferenceObjectHandle *, long * >::end(), map< PsnReferenceObjectHandle *, long * >::find(), PsnFrameScheduler::Frames, and PsnDoubleList::next().

00109                                                   {
00110 #ifdef _SGI
00111    timespec avant, apres;
00112 #else
00113    timeval avant, apres ;
00114 #endif
00115    // Un pas de simulation pour les ObjetSimul de tous les referentiels
00116    PsnDoubleListElement * pListe ;
00117    for (pListe = Frames [which]->begin () ;
00118         pListe != NULL ; 
00119         pListe = Frames[which]->next (pListe)) {
00120       //initialisation du compteur de cet objet
00121 #ifdef _SGI
00122       clock_gettime(CLOCK_SGI_CYCLE, &avant);
00123 #else
00124       gettimeofday(&avant, NULL);
00125 #endif
00126       (*pListe).listeElem->compute () ;
00127 #ifdef _COUTPOLATION
00128       cout<<"Calcul de "<<(*pListe).listeElem->objetSimul ()->getName()<<endl;
00129 #endif
00130       //lecture du compteur
00131 #ifdef _SGI
00132       clock_gettime(CLOCK_SGI_CYCLE, &apres);
00133 #else
00134       gettimeofday(&apres, NULL);
00135 #endif
00136       //mise à jour de la structure de donnée
00137       if( _sampleIndex >= 0 ) {
00138 #ifdef _SGI
00139          _tabVitesse[(*pListe).listeElem][_sampleIndex] = apres.tv_nsec - avant.tv_nsec;
00140 #else
00141          assert (_tabVitesse.find( (*pListe).listeElem ) != _tabVitesse.end() ) ;
00142          _tabVitesse[(*pListe).listeElem][_sampleIndex] = apres.tv_usec - avant.tv_usec;
00143 #endif
00144       }
00145    }
00146 }


Member Data Documentation

int PsnBenchScheduler::_numberOfSamples [protected]
 

Definition at line 56 of file PsnBenchScheduler.h.

Referenced by addToScheduable(), removeFromScheduable(), and ~PsnBenchScheduler().

ostream& PsnBenchScheduler::_outputFile [protected]
 

Definition at line 57 of file PsnBenchScheduler.h.

Referenced by removeFromScheduable(), and ~PsnBenchScheduler().

const int& PsnBenchScheduler::_sampleIndex [protected]
 

Definition at line 55 of file PsnBenchScheduler.h.

Referenced by runStep().

map<PsnReferenceObjectHandle *, long*> PsnBenchScheduler::_tabVitesse [protected]
 

Definition at line 54 of file PsnBenchScheduler.h.

Referenced by addToScheduable(), removeFromScheduable(), runStep(), and ~PsnBenchScheduler().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:25:52 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001