00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00069 MyCompList = getModels(model);
00070
00071 for (std::list<IntrospectedComponent*>::iterator i = MyCompList.begin();
00072 i != MyCompList.end(); ++i) {
00073
00074
00075 monitorComponent(*i);
00076
00077
00078
00079
00080
00081
00082 pint = (*i)->ifMonitorIntData("il1_read");
00083
00084
00085 if(pint.first){
00086
00087
00088 addToIntDatabase(*i, pint.second);
00089
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
00112
00113
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
00131 Introspector_cpu() : Introspector() {}
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