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

sst/elements/cpu_PowerAndData/cpu_PowerAndData.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 // A cpu component that can report unit power 
00013 // Built for testing the power model.
00014 
00015 #ifndef _CPU_POWERANDDATA_H
00016 #define _CPU_POWERANDDATA_H
00017 
00018 //#include <sst/core/eventFunctor.h>
00019 #include <sst/core/introspectedComponent.h>
00020 #include <sst/core/link.h>
00021 #include <sst/core/timeConverter.h>
00022 #include "../power/power.h"
00023 
00024 using namespace SST;
00025 
00026 #if DBG_CPU_POWERANDDATA
00027 #define _CPU_POWERANDDATA_DBG( fmt, args...)\
00028          printf( "%d:Cpu_PowerAndData::%s():%d: "fmt, _debug_rank, __FUNCTION__,__LINE__, ## args )
00029 #else
00030 #define _CPU_POWERANDDATA_DBG( fmt, args...)
00031 #endif
00032 
00033 class Cpu_PowerAndData : public IntrospectedComponent {
00034         typedef enum { WAIT, SEND } state_t;
00035         typedef enum { WHO_NIC, WHO_MEM } who_t;
00036     public:
00037         Cpu_PowerAndData( ComponentId_t id, Params_t& params ) :
00038             IntrospectedComponent( id ),
00039             params( params ),
00040             state(SEND),            
00041             area(0.0),
00042             who(WHO_MEM),
00043             frequency( "2.2GHz" )
00044         {
00045             _CPU_POWERANDDATA_DBG( "new id=%lu\n", id );
00046 
00047             registerExit();
00048 
00049             Params_t::iterator it = params.begin(); 
00050             while( it != params.end() ) { 
00051                 _CPU_POWERANDDATA_DBG("key=%s value=%s\n",
00052                             it->first.c_str(),it->second.c_str());
00053                 if ( ! it->first.compare("clock") ) {
00054                     frequency = it->second;
00055                 }    
00056                 else if ( ! it->first.compare("push_introspector") ) {
00057                     pushIntrospector = it->second;
00058                 }    
00059 
00060                 ++it;
00061             } 
00062             
00063             mem = configureLink( "MEM" );
00064  //           handler = new EventHandler< Cpu_PowerAndData, bool, Cycle_t >
00065  //                                               ( this, &Cpu_PowerAndData::clock );
00066  //         handlerPush = new EventHandler< Cpu_PowerAndData, bool, Cycle_t >
00067  //                                               ( this, &Cpu_PowerAndData::pushData );
00068 
00069             TimeConverter* tc = registerClock( frequency, new Clock::Handler< Cpu_PowerAndData >
00070                                                 ( this, &Cpu_PowerAndData::clock ) );
00071             TimeConverter* tcPush = registerClock( frequency, new Clock::Handler< Cpu_PowerAndData >
00072                                                 ( this, &Cpu_PowerAndData::pushData) );
00073 
00074             mem->setDefaultTimeBase(tc);
00075             printf("CPU_POWERANDDATA period: %ld\n",tc->getFactor());
00076             _CPU_POWERANDDATA_DBG("Done registering clock\n");
00077 
00078             counts = 0;
00079             num_il1_read = 0;
00080             num_branch_read = 0;
00081             num_branch_write = 0;
00082             num_RAS_read = 0;
00083             num_RAS_write = 0;
00084 
00085             registerMonitorInt("il1_read");
00086             registerMonitorInt("core_temperature");
00087             registerMonitorInt("branch_read");
00088             registerMonitorInt("RAS_read");
00089             registerMonitorInt("RAS_write");
00090             
00091             //registerMonitorDouble("CPUarea");
00092 
00093         }
00094         int Setup() {
00095             
00096             power = new Power(getId());
00097             power->setTech(getId(), params, CACHE_IL1, McPAT);
00098             //power->setTech(getId(), params, CACHE_IL2);
00099             /*power->setTech(getId(), params, CACHE_DL1);
00100             //power->setTech(getId(), params, CACHE_DL2);
00101             power->setTech(getId(), params, CACHE_ITLB);
00102             power->setTech(getId(), params, CACHE_DTLB);
00103             power->setTech(getId(), params, RF);
00104             power->setTech(getId(), params, IB);            
00105             power->setTech(getId(), params, ISSUE_Q);
00106             power->setTech(getId(), params, INST_DECODER);
00107             power->setTech(getId(), params, PIPELINE);
00108             power->setTech(getId(), params, BYPASS);                                
00109             power->setTech(getId(), params, LOGIC);
00110             power->setTech(getId(), params, ALU);
00111             power->setTech(getId(), params, FPU);
00112             power->setTech(getId(), params, EXEU);
00113             power->setTech(getId(), params, LSQ);
00114             power->setTech(getId(), params, BPRED);
00115             power->setTech(getId(), params, RAT);
00116             power->setTech(getId(), params, ROB);
00117             power->setTech(getId(), params, BTB);
00118             power->setTech(getId(), params, CACHE_L2);
00119             power->setTech(getId(), params, CLOCK);*/ //clock should be the last in McPAT
00120             area = power->estimateAreaMcPAT();    
00121 
00122             //query the (push)introspector on how often this should push data (power/energy)
00123             //IntrospectedComponent *c;
00124             //for (std::list<ComponentId_t>::iterator i = MyIntroList.begin();
00125             //    i != MyIntroList.end(); ++i) {
00126                   //printf("ID %lu will monitor me\n",*i);
00127             //}
00128             //c = c_sim->getComponent(pushIntrospector.c_str());
00129             //printf("component found its introspector whose period = %lu\n", c->getIntrospectFreq()); 
00130             //pushFreq = c->getFreq() / this->getFreq();
00131    
00132            return 0;
00133         }
00134         int Finish() {
00135             _CPU_POWERANDDATA_DBG("\n");
00136             //unregisterExit();
00137             return 0;
00138         }
00139         
00140         uint64_t getIntData(int dataID, int index=0)
00141         { 
00142           switch(dataID)
00143           {
00144             case 0:
00145             //core_temperature
00146                 return (mycore_temperature);
00147                 break;
00148             case 1:
00149             //branch_read
00150                 return (num_branch_read);
00151                 break;
00152             case 2: 
00153             //branch_write
00154                 return (num_branch_write);
00155                 break;
00156             case 3: 
00157             //RAS_read 
00158                 return (num_RAS_read);
00159                 break;
00160             case 4:
00161             //RAS_write
00162                 return (num_RAS_write);
00163                 break;
00164             case 5:
00165             //il1_read
00166                 return (num_il1_read);
00167                 break;
00168             default:
00169                 return (0);
00170                 break;  
00171           }
00172         }
00173         
00174 
00175     public:
00176         int counts;
00177         double area;
00178         uint64_t num_il1_read;
00179         uint64_t mycore_temperature;
00180         uint64_t num_branch_read;
00181         uint64_t num_branch_write;
00182         uint64_t num_RAS_read;
00183         uint64_t num_RAS_write;
00184         //Simulation *c_sim;
00185 
00186     private:
00187 
00188         Cpu_PowerAndData( const Cpu_PowerAndData& c );
00189         Cpu_PowerAndData() :  IntrospectedComponent(-1) {} // for serialization only
00190 
00191 
00192         bool clock( Cycle_t );
00193         bool pushData( Cycle_t);
00194         //bool handler1( Time_t time, Event *e );
00195 
00196         Params_t    params;
00197         Link*       mem;
00198         state_t     state;
00199         who_t       who;
00200         std::string frequency;
00201         std::string pushIntrospector;
00202         //SimTime_t pushFreq;
00203 
00204         Pdissipation_t pdata, pstats;
00205         Power *power;
00206         std::pair<bool, int*> p_int;
00207         std::pair<bool, double*> p_double;
00208         usagecounts_t mycounts;  //over-specified struct that holds usage counts of its sub-components
00209 
00210  friend class boost::serialization::access;
00211     template<class Archive>
00212     void serialize(Archive & ar, const unsigned int version )
00213     {
00214         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Component);
00215         ar & BOOST_SERIALIZATION_NVP(params);
00216         ar & BOOST_SERIALIZATION_NVP(mem);
00217         ar & BOOST_SERIALIZATION_NVP(state);
00218         ar & BOOST_SERIALIZATION_NVP(who);
00219         ar & BOOST_SERIALIZATION_NVP(frequency);
00220     }
00221 };
00222 
00223 #endif

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