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

sst/core/timeLord.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 
00013 #ifndef _SST_TIMELORD_H
00014 #define _SST_TIMELORD_H
00015 
00016 #include <string>
00017 #include <map>
00018 
00019 #include <sst/core/sst_types.h>
00020 #include <sst/core/simulation.h>
00021 
00022 namespace SST {
00023 
00024 class TimeConverter;
00025 
00026   /** 
00027       Class for creating and managing TimeConverter objects
00028    */
00029 class TimeLord {
00030     typedef std::map<SimTime_t,TimeConverter*> TimeConverterMap_t;
00031     typedef std::map<std::string,TimeConverter*> StringToTCMap_t;
00032     
00033  public:
00034   /** 
00035       Create a new TimeConverter object using specified SI Units. For
00036       example, "1 Ghz" (1 Gigahertz), "2.5 ns" (2.5 nanoseconds).  
00037 
00038       @param ts String indicating the base unit for this object. The
00039       string should be a floating point number followed by a prefix,
00040       and then frequency (i.e. Hz) or time unit (s). Allowable seconds
00041       prefixes are: 'f' (fempto), 'p' (pico), 'n' (nano), 'u' (micro),
00042       'm' (milli). Allowable frequency prefixes are 'k' (kilo), 'M'
00043       (mega), and 'G' (giga).
00044    */
00045     TimeConverter* getTimeConverter(std::string ts);
00046     SimTime_t getSimCycles(std::string timeString, std::string where);
00047 
00048     TimeConverter* getNano() {return nano;}
00049     TimeConverter* getMicro() {return micro;}
00050     TimeConverter* getMilli() {return milli;}
00051     /* Used by power API to calculate time period in sec since last power query*/
00052     Time_t getSecFactor(){ return (Time_t)sec_factor;}
00053     
00054  private:
00055     friend class SST::SimulationBase;
00056     friend int Simulation::WireUp(Graph& graph, SDL_CompMap_t& sdlMap,
00057                                   int minPart, int myRank);
00058 
00059     // Needed by the simulator to turn minPart back into a
00060     // TimeConverter object.
00061     TimeConverter *getTimeConverter(SimTime_t simCycles);
00062 
00063     TimeLord(std::string timeBaseString);
00064     ~TimeLord();
00065 
00066     TimeLord() { }                      // For serialization
00067     TimeLord(TimeLord const&);          // Don't Implement
00068     void operator=(TimeLord const&);    // Don't Implement
00069     
00070     // Variables that need to be saved when serialized
00071     std::string timeBaseString;
00072     TimeConverterMap_t tcMap;
00073 
00074     // Variables that will be recreated so don't need to be saved when
00075     // serialized
00076     double sec_factor;
00077     StringToTCMap_t parseCache;
00078 
00079     TimeConverter* nano;
00080     TimeConverter* micro;
00081     TimeConverter* milli;
00082 
00083     friend class boost::serialization::access;
00084     template<class Archive>
00085     void serialize(Archive & ar, const unsigned int version )
00086     {
00087         ar & BOOST_SERIALIZATION_NVP(timeBaseString);
00088         ar & BOOST_SERIALIZATION_NVP(tcMap);
00089         ar & BOOST_SERIALIZATION_NVP(sec_factor);
00090         ar & BOOST_SERIALIZATION_NVP(parseCache);
00091         ar & BOOST_SERIALIZATION_NVP(nano);
00092         ar & BOOST_SERIALIZATION_NVP(micro);
00093         ar & BOOST_SERIALIZATION_NVP(milli);
00094     }
00095 };    
00096 
00097 } // namespace SST
00098 
00099 BOOST_CLASS_EXPORT_KEY(SST::TimeLord)
00100 
00101 #endif

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