• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/introspector_dram/introspector_dram.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 #ifndef _INTROSPECTOR_DRAM_H
00013 #define _INTROSPECTOR_DRAM_H
00014 
00015 #include <sst/core/introspector.h>
00016 
00017 
00018 using namespace SST;
00019 
00020 #if DBG_INTROSPECTOR_DRAM
00021 #define _INTROSPECTOR_DRAM_DBG( fmt, args...)\
00022          printf( "%d:Introspector_dram::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00023 #else
00024 #define _INTROSPECTOR_DRAM_DBG( fmt, args...)
00025 #endif
00026 
00027 
00028 
00029 class Introspector_dram : public Introspector {
00030        
00031     public:
00032         Introspector_dram(Component::Params_t& params ) :
00033             Introspector(),
00034             params( params ),
00035             frequency( "1ns" )
00036         {
00037             _INTROSPECTOR_DRAM_DBG( "new id=%lu\n", id );
00038 
00039             Component::Params_t::iterator it = params.begin(); 
00040             while( it != params.end() ) { 
00041                 _INTROSPECTOR_DRAM_DBG("key=%s value=%s\n",
00042                             it->first.c_str(),it->second.c_str());
00043                 if ( ! it->first.compare("period") ) {
00044                     frequency = it->second;
00045                 }  
00046                 else if ( ! it->first.compare("model") ) {
00047                     model = it->second;
00048                 }    
00049                 ++it;
00050             } 
00051             
00052             intData = 0;
00053             _INTROSPECTOR_DRAM_DBG("-->frequency=%s\n",frequency.c_str());
00054 
00055             TimeConverter* tc = registerClock( frequency, new Clock::Handler<Introspector_dram>(this, &Introspector_dram::pullData) );
00056 
00057             ///registerClock( frequency, new Clock::Handler<Introspector_dram>(this, &Introspector_dram::mpiCollectInt) );
00058             ///mpionetimehandler = new Event::Handler< Introspector_dram >
00059                                                 ( this, &Introspector_dram::mpiOneTimeCollect );
00060 
00061             printf("INTROSPECTOR_DRAM period: %ld\n",(long int)tc->getFactor());
00062             _INTROSPECTOR_DRAM_DBG("Done registering clock\n");
00063             
00064         }
00065         int Setup() {
00066             std::pair<bool, int> pint;
00067             
00068             //get a list of relevant component. Must be done after all components are created 
00069             MyCompList = getModels(model); 
00070             //std::cout << " introspector_dram has MyCompList size = " << MyCompList.size() << std::endl;
00071             for (std::list<IntrospectedComponent*>::iterator i = MyCompList.begin();
00072                 i != MyCompList.end(); ++i) {
00073                     // state that we will monitor those components 
00074                     // (pass introspector's info to the component)
00075                     monitorComponent(*i);
00076 
00077                     //check if the component counts the specified int/double data
00078                     pint = (*i)->ifMonitorIntData("dram_backgroundEnergy");
00079                     if(pint.first){             
00080                         //store pointer to component and the dataID of the data of interest     
00081                         addToIntDatabase(*i, pint.second); 
00082                     }
00083                 
00084                     pint = (*i)->ifMonitorIntData("dram_burstEnergy");
00085                     if(pint.first){                     
00086                         addToIntDatabase(*i, pint.second);  
00087                     }
00088                 
00089                     pint = (*i)->ifMonitorIntData("dram_actpreEnergy");
00090                     if(pint.first){                     
00091                         addToIntDatabase(*i, pint.second); 
00092                     }
00093                 
00094                     pint = (*i)->ifMonitorIntData("dram_refreshEnergy");
00095                     if(pint.first){                     
00096                         addToIntDatabase(*i, pint.second); 
00097                     }
00098                 
00099 
00100              }
00101             ///oneTimeCollect(2000000, mpionetimehandler);
00102             _INTROSPECTOR_DRAM_DBG("\n");
00103             return 0;
00104         }
00105         int Finish() {
00106             _INTROSPECTOR_DRAM_DBG("\n");
00107             return 0;
00108         }
00109 
00110 
00111     private:
00112         Introspector_dram( const Introspector_dram& c );
00113         //~Introspector_dram();
00114         Introspector_dram() :  Introspector() {} // for serialization only
00115 
00116         bool pullData( Cycle_t );
00117         bool mpiCollectInt( Cycle_t );
00118         void mpiOneTimeCollect(Event* e);
00119 
00120         Event::Handler< Introspector_dram > *mpionetimehandler;
00121         Component::Params_t    params;        
00122         std::string frequency;
00123         std::string model;
00124         uint64_t intData;
00125 
00126         friend class boost::serialization::access;
00127     template<class Archive>
00128     void serialize(Archive & ar, const unsigned int version )
00129     {
00130         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Introspector);
00131         ar & BOOST_SERIALIZATION_NVP(params);
00132         ar & BOOST_SERIALIZATION_NVP(frequency);
00133         ar & BOOST_SERIALIZATION_NVP(model);
00134     }
00135 };
00136 
00137 #endif

Generated on Fri Oct 22 2010 11:02:25 for SST by  doxygen 1.7.1