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

sst/elements/introspector_cpu/introspector_cpu.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_CPU_H
00013 #define _INTROSPECTOR_CPU_H
00014 
00015 #include <sst/core/introspector.h>
00016 
00017 
00018 using namespace SST;
00019 
00020 #if DBG_INTROSPECTOR_CPU
00021 #define _INTROSPECTOR_CPU_DBG( fmt, args...)\
00022          printf( "%d:Introspector_cpu::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00023 #else
00024 #define _INTROSPECTOR_CPU_DBG( fmt, args...)
00025 #endif
00026 
00027 
00028 
00029 class Introspector_cpu : public Introspector {
00030        
00031     public:
00032         Introspector_cpu(Component::Params_t& params ) :
00033             Introspector(),
00034             params( params ),
00035             frequency( "1ns" )
00036         {
00037             _INTROSPECTOR_CPU_DBG( "new id=%lu\n", id );
00038 
00039             Component::Params_t::iterator it = params.begin(); 
00040             while( it != params.end() ) { 
00041                 _INTROSPECTOR_CPU_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_CPU_DBG("-->frequency=%s\n",frequency.c_str());
00054 
00055             TimeConverter* tc = registerClock( frequency, new Clock::Handler<Introspector_cpu>(this, &Introspector_cpu::pullData) );
00056 
00057             registerClock( frequency, new Clock::Handler<Introspector_cpu>(this, &Introspector_cpu::mpiCollectInt) );
00058             mpionetimehandler = new Event::Handler< Introspector_cpu >
00059                                                 ( this, &Introspector_cpu::mpiOneTimeCollect );
00060 
00061             printf("INTROSPECTOR_CPU period: %ld\n",(long int)tc->getFactor());
00062             _INTROSPECTOR_CPU_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_cpu 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("branch_read");
00079                     //pint = (*i)->ifMonitorIntData("branch_write");
00080                     //pint = (*i)->ifMonitorIntData("RAS_read");
00081                     //pint = (*i)->ifMonitorIntData("RAS_write");
00082                     pint = (*i)->ifMonitorIntData("il1_read");
00083                     //pdouble = (*i)->ifMonitorDoubleData("CPUarea");
00084 
00085                     if(pint.first){
00086                         //store pointer to component and the dataID of the data of interest
00087                         //std::cout << "introspector_cpu is calling addToIntDatabase." << std::endl;
00088                         addToIntDatabase(*i, pint.second);
00089                         //std::cout << " introspector_cpu now has intdatabase size = " << DatabaseInt.size() << std::endl;
00090                     }
00091                     pint = (*i)->ifMonitorIntData("dram_backgroundEnergy");
00092                     if(pint.first){                     
00093                         addToIntDatabase(*i, pint.second); 
00094                     }
00095                 
00096                     pint = (*i)->ifMonitorIntData("dram_burstEnergy");
00097                     if(pint.first){                     
00098                         addToIntDatabase(*i, pint.second);  
00099                     }
00100                 
00101                     pint = (*i)->ifMonitorIntData("dram_actpreEnergy");
00102                     if(pint.first){                     
00103                         addToIntDatabase(*i, pint.second); 
00104                     }
00105                 
00106                     pint = (*i)->ifMonitorIntData("dram_refreshEnergy");
00107                     if(pint.first){                     
00108                         addToIntDatabase(*i, pint.second); 
00109                     }
00110                 
00111                     //if(pdouble.first){
00112                         //store pointer to component and the dataID of the data of interest
00113                         //addToDoubleDatabase(*i, pdouble.second);
00114                     //}
00115 
00116 
00117              }
00118             oneTimeCollect(2000000, mpionetimehandler);
00119             _INTROSPECTOR_CPU_DBG("\n");
00120             return 0;
00121         }
00122         int Finish() {
00123             _INTROSPECTOR_CPU_DBG("\n");
00124             return 0;
00125         }
00126 
00127 
00128     private:
00129         Introspector_cpu( const Introspector_cpu& c );
00130         //~Introspector_cpu();
00131         Introspector_cpu() :  Introspector() {} // for serialization only
00132 
00133         bool pullData( Cycle_t );
00134         bool mpiCollectInt( Cycle_t );
00135         void mpiOneTimeCollect(Event* e);
00136 
00137         Event::Handler< Introspector_cpu > *mpionetimehandler;
00138         Component::Params_t    params;        
00139         std::string frequency;
00140         std::string model;
00141         uint64_t intData;
00142 
00143         friend class boost::serialization::access;
00144     template<class Archive>
00145     void serialize(Archive & ar, const unsigned int version )
00146     {
00147         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Introspector);
00148         ar & BOOST_SERIALIZATION_NVP(params);
00149         ar & BOOST_SERIALIZATION_NVP(frequency);
00150         ar & BOOST_SERIALIZATION_NVP(model);
00151     }
00152 };
00153 
00154 #endif

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