00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _INTROSPECTOR_ROUTER_H
00013 #define _INTROSPECTOR_ROUTER_H
00014
00015 #include <sst/core/introspector.h>
00016
00017
00018 using namespace SST;
00019
00020 #if DBG_INTROSPECTOR_ROUTER
00021 #define _INTROSPECTOR_ROUTER_DBG( fmt, args...)\
00022 printf( "%d:Introspector_router::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00023 #else
00024 #define _INTROSPECTOR_ROUTER_DBG( fmt, args...)
00025 #endif
00026
00027
00028
00029 class Introspector_router : public Introspector {
00030
00031 public:
00032 Introspector_router(Component::Params_t& params ) :
00033 Introspector(),
00034 params( params ),
00035 frequency( "1ns" )
00036 {
00037 _INTROSPECTOR_ROUTER_DBG( "new id=%lu\n", id );
00038
00039 Component::Params_t::iterator it = params.begin();
00040 while( it != params.end() ) {
00041 _INTROSPECTOR_ROUTER_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 totalRouterDelay = 0;
00053 numLocalMessage = 0;
00054 currentPower = leakagePower = runtimePower = totalPower = peakPower = 0;
00055
00056 _INTROSPECTOR_ROUTER_DBG("-->frequency=%s\n",frequency.c_str());
00057
00058 TimeConverter* tc = registerClock( frequency, new Clock::Handler<Introspector_router>(this, &Introspector_router::pullData) );
00059
00060
00061
00062
00063
00064 printf("INTROSPECTOR_ROUTER period: %ld\n",(long int)tc->getFactor());
00065 _INTROSPECTOR_ROUTER_DBG("Done registering clock\n");
00066
00067 }
00068 int Setup() {
00069 std::pair<bool, int> pint, pdouble;
00070
00071
00072 MyCompList = getModels(model);
00073
00074 for (std::list<IntrospectedComponent*>::iterator i = MyCompList.begin();
00075 i != MyCompList.end(); ++i) {
00076
00077
00078 monitorComponent(*i);
00079
00080
00081 pint = (*i)->ifMonitorIntData("router_delay");
00082 if(pint.first){
00083
00084 addToIntDatabase(*i, pint.second);
00085 }
00086 pint = (*i)->ifMonitorIntData("local_message");
00087 if(pint.first){
00088 addToIntDatabase(*i, pint.second);
00089 }
00090
00091 pdouble = (*i)->ifMonitorDoubleData("current_power");
00092 if(pdouble.first){
00093 addToDoubleDatabase(*i, pdouble.second);
00094 }
00095 pdouble = (*i)->ifMonitorDoubleData("leakage_power");
00096 if(pdouble.first){
00097 addToDoubleDatabase(*i, pdouble.second);
00098 }
00099 pdouble = (*i)->ifMonitorDoubleData("runtime_power");
00100 if(pdouble.first){
00101 addToDoubleDatabase(*i, pdouble.second);
00102 }
00103 pdouble = (*i)->ifMonitorDoubleData("total_power");
00104 if(pdouble.first){
00105 addToDoubleDatabase(*i, pdouble.second);
00106 }
00107 pdouble = (*i)->ifMonitorDoubleData("peak_power");
00108 if(pdouble.first){
00109 addToDoubleDatabase(*i, pdouble.second);
00110 }
00111
00112 }
00113
00114 _INTROSPECTOR_ROUTER_DBG("\n");
00115 return 0;
00116 }
00117 int Finish() {
00118 _INTROSPECTOR_ROUTER_DBG("\n");
00119 return 0;
00120 }
00121
00122
00123 private:
00124 Introspector_router( const Introspector_router& c );
00125
00126 Introspector_router() : Introspector() {}
00127
00128 bool pullData( Cycle_t );
00129 bool mpiCollectInt( Cycle_t );
00130 void mpiOneTimeCollect(Event* e);
00131
00132 Event::Handler< Introspector_router > *mpionetimehandler;
00133 Component::Params_t params;
00134 std::string frequency;
00135 std::string model;
00136 uint64_t totalRouterDelay, numLocalMessage, intData;
00137 double currentPower, leakagePower, runtimePower, totalPower, peakPower;
00138
00139 friend class boost::serialization::access;
00140 template<class Archive>
00141 void serialize(Archive & ar, const unsigned int version )
00142 {
00143 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Introspector);
00144 ar & BOOST_SERIALIZATION_NVP(params);
00145 ar & BOOST_SERIALIZATION_NVP(frequency);
00146 ar & BOOST_SERIALIZATION_NVP(model);
00147 }
00148 };
00149
00150 #endif