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/eventFunctor.h>
00016 #include <sst/core/introspector.h>
00017
00018
00019 using namespace SST;
00020
00021 #if DBG_INTROSPECTOR_CPU
00022 #define _INTROSPECTOR_CPU_DBG( fmt, args...)\
00023 printf( "%d:Introspector_cpu::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00024 #else
00025 #define _INTROSPECTOR_CPU_DBG( fmt, args...)
00026 #endif
00027
00028
00029
00030 class Introspector_cpu : public Introspector {
00031
00032 public:
00033 Introspector_cpu( ComponentId_t id, Component::Params_t& params ) :
00034 Introspector( id),
00035 params( params ),
00036 frequency( "1ns" )
00037 {
00038 _INTROSPECTOR_CPU_DBG( "new id=%lu\n", id );
00039
00040 registerExit();
00041
00042 Component::Params_t::iterator it = params.begin();
00043 while( it != params.end() ) {
00044 _INTROSPECTOR_CPU_DBG("key=%s value=%s\n",
00045 it->first.c_str(),it->second.c_str());
00046 if ( ! it->first.compare("period") ) {
00047 frequency = it->second;
00048 }
00049 else if ( ! it->first.compare("model") ) {
00050 model = it->second;
00051 }
00052 ++it;
00053 }
00054
00055 intData = 0;
00056 handler = new EventHandler< Introspector_cpu, bool, Cycle_t >
00057 ( this, &Introspector_cpu::pullData );
00058 _INTROSPECTOR_CPU_DBG("-->frequency=%s\n",frequency.c_str());
00059 TimeConverter* tc = registerClock( frequency, handler );
00060
00061 mpihandler = new EventHandler< Introspector_cpu, bool, Cycle_t >
00062 ( this, &Introspector_cpu::mpiCollectInt );
00063 registerClock( frequency, mpihandler );
00064
00065 mpionetimehandler = new EventHandler< Introspector_cpu, bool, Event* >
00066 ( this, &Introspector_cpu::mpiOneTimeCollect );
00067
00068 printf("INTROSPECTOR_CPU period: %ld\n",(long int)tc->getFactor());
00069 _INTROSPECTOR_CPU_DBG("Done registering clock\n");
00070
00071 }
00072 int Setup() {
00073 std::pair<bool, int> pint;
00074 std::pair<bool, double*> pdouble;
00075
00076
00077 MyCompList = getModels(model);
00078
00079 for (std::list<Component*>::iterator i = MyCompList.begin();
00080 i != MyCompList.end(); ++i) {
00081
00082
00083 monitorComponent(*i);
00084
00085
00086
00087
00088
00089
00090
00091 pint = (*i)->ifMonitorIntData("il1_read");
00092
00093
00094 if(pint.first){
00095
00096
00097 addToIntDatabase(*i, pint.second);
00098
00099 }
00100
00101
00102
00103
00104
00105
00106 }
00107 oneTimeCollect(90000, mpionetimehandler);
00108 _INTROSPECTOR_CPU_DBG("\n");
00109 return 0;
00110 }
00111 int Finish() {
00112 _INTROSPECTOR_CPU_DBG("\n");
00113 unregisterExit();
00114 return 0;
00115 }
00116
00117
00118 private:
00119
00120 Introspector_cpu( const Introspector_cpu& c );
00121 Introspector_cpu() {}
00122
00123 bool pullData( Cycle_t );
00124 bool mpiCollectInt( Cycle_t );
00125 bool mpiOneTimeCollect(Event* e);
00126
00127 ClockHandler_t *handler, *mpihandler;
00128 EventHandler< Introspector_cpu, bool, Event* > *mpionetimehandler;
00129 Component::Params_t params;
00130 std::string frequency;
00131 std::string model;
00132 uint64_t intData;
00133
00134 #if WANT_CHECKPOINT_SUPPORT2
00135 BOOST_SERIALIZE {
00136 printf("introspector_cpu::serialize()\n");
00137 _AR_DBG( Introspector_cpu, "start\n" );
00138 printf(" doing void cast\n");
00139 BOOST_VOID_CAST_REGISTER( Introspector_cpu*, Introspector* );
00140 printf(" base serializing: introspector\n");
00141 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Introspector );
00142 printf(" serializing: handler\n");
00143 ar & BOOST_SERIALIZATION_NVP( handler );
00144 _AR_DBG( Introspector_cpu, "done\n" );
00145 }
00146 #endif
00147 };
00148
00149 #endif