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

sst/elements/introspector_cpuTemperature/introspector_cpuTemperature.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_CPUTEMPERATURE_H
00013 #define _INTROSPECTOR_CPUTEMPERATURE_H
00014 
00015 //#include <sst/core/component.h>
00016 #include <sst/core/introspector.h>
00017 
00018 
00019 using namespace SST;
00020 
00021 #if DBG_INTROSPECTOR_CPUTEMPERATURE
00022 #define _INTROSPECTOR_CPUTEMPERATURE_DBG( fmt, args...)\
00023          printf( "%d:Introspector_cpuTemperature::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00024 #else
00025 #define _INTROSPECTOR_CPUTEMPERATURE_DBG( fmt, args...)
00026 #endif
00027 
00028 
00029 
00030 class Introspector_cpuTemperature : public Introspector {
00031        
00032     public:
00033         Introspector_cpuTemperature(Component::Params_t& params) :
00034             Introspector(),
00035             params( params ),
00036             frequency( "1ns" )
00037         {
00038             _INTROSPECTOR_CPUTEMPERATURE_DBG( "new id=%lu\n", id );
00039 
00040             Component::Params_t::iterator it = params.begin(); 
00041             while( it != params.end() ) { 
00042                 _INTROSPECTOR_CPUTEMPERATURE_DBG("key=%s value=%s\n",
00043                             it->first.c_str(),it->second.c_str());
00044                 if ( ! it->first.compare("period") ) {
00045                     frequency = it->second;
00046                 }  
00047                 else if ( ! it->first.compare("model") ) {
00048                     model = it->second;
00049                 }    
00050                 ++it;
00051             } 
00052             
00053            
00054             _INTROSPECTOR_CPUTEMPERATURE_DBG("-->frequency=%s\n",frequency.c_str());
00055 //             Handler = new EventHandler< Introspector_cpuTemperature, bool, Cycle_t >
00056 //                                                 ( this, &Introspector_cpuTemperature::pullData );
00057 //             TimeConverter* tc = registerClock( frequency, handler );
00058             TimeConverter* tc = registerClock( frequency, new Clock::Handler<Introspector_cpuTemperature>( this, &Introspector_cpuTemperature::pullData ) );
00059 
00060             printf("INTROSPECTOR_CPUTEMPERATURE period: %ld\n",
00061                    (long int) tc->getFactor());
00062             _INTROSPECTOR_CPUTEMPERATURE_DBG("Done registering clock\n");
00063 
00064             
00065         }
00066         int Setup() {
00067             std::pair<bool, int> pdouble;
00068 
00069             //get a list of relevant component. Must be done after all components are created 
00070             MyCompList = getModels(model); 
00071             //std::cout << " introspector_cpuTemperature has MyCompList size = " << MyCompList.size() << std::endl;
00072             for (std::list<IntrospectedComponent*>::iterator i = MyCompList.begin();
00073                 i != MyCompList.end(); ++i) {
00074                     // state that we will monitor those components 
00075                     // (pass introspector's info to the component)
00076                     monitorComponent(*i);
00077 
00078                     //check if the component counts the specified int/double data
00079                     pdouble = (*i)->ifMonitorDoubleData("core_temperature");
00080 
00081                     if(pdouble.first){
00082                         //store pointer to component and the dataID of the data of interest
00083                         addToDoubleDatabase(*i, pdouble.second);
00084                     }
00085 
00086 
00087              }
00088 
00089             _INTROSPECTOR_CPUTEMPERATURE_DBG("\n");
00090             return 0;
00091         }
00092         int Finish() {
00093             _INTROSPECTOR_CPUTEMPERATURE_DBG("\n");
00094             return 0;
00095         }
00096 
00097 
00098     private:
00099 
00100         Introspector_cpuTemperature( const Introspector_cpuTemperature& c );
00101         //Introspector_cpuTemperature() {}
00102         Introspector_cpuTemperature() :  Introspector() {} // for serialization only
00103 
00104         bool pullData( Cycle_t );
00105         
00106 
00107         Component::Params_t    params;        
00108         std::string frequency;
00109         std::string model;
00110 
00111         friend class boost::serialization::access;
00112     template<class Archive>
00113     void serialize(Archive & ar, const unsigned int version )
00114     {
00115         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Introspector);
00116         ar & BOOST_SERIALIZATION_NVP(params);
00117         ar & BOOST_SERIALIZATION_NVP(frequency);
00118         ar & BOOST_SERIALIZATION_NVP(model);
00119     }
00120 };
00121 
00122 #endif

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