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

sst/elements/introspector_router/introspector_router.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_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             ///registerClock( frequency, new Clock::Handler<Introspector_router>(this, &Introspector_router::mpiCollectInt) );
00061             ///mpionetimehandler = new Event::Handler< Introspector_router >
00062             ///                                    ( this, &Introspector_router::mpiOneTimeCollect );
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             //get a list of relevant component. Must be done after all components are created 
00072             MyCompList = getModels(model); 
00073             //std::cout << " introspector_router has MyCompList size = " << MyCompList.size() << std::endl;
00074             for (std::list<IntrospectedComponent*>::iterator i = MyCompList.begin();
00075                 i != MyCompList.end(); ++i) {
00076                     // state that we will monitor those components 
00077                     // (pass introspector's info to the component)
00078                     monitorComponent(*i);
00079 
00080                     //check if the component counts the specified int/double data
00081                     pint = (*i)->ifMonitorIntData("router_delay");
00082                     if(pint.first){             
00083                         //store pointer to component and the dataID of the data of interest     
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             ///oneTimeCollect(2000000, mpionetimehandler);
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         //~Introspector_router();
00126         Introspector_router() :  Introspector() {} // for serialization only
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

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