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

sst/elements/sstdisksim/sstdisksim.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 _SSTDISKSIM_H
00013 #define _SSTDISKSIM_H
00014 
00015 #include "sstdisksim_event.h"
00016 
00017 #include <sst/core/log.h>
00018 #include <sst/core/component.h>
00019 #include <sst/core/simulation.h>
00020 #include <stdlib.h>
00021 #include <stddef.h>
00022 #include <sst/core/timeConverter.h>
00023 
00024 #include "syssim_driver.h"
00025 #include <disksim_interface.h>
00026 #include <disksim_rand48.h>
00027 
00028 using namespace std;
00029 using namespace SST;
00030 
00031 #ifndef DISKSIM_DBG
00032 #define DISKSIM_DBG 0
00033 #endif
00034 
00035 typedef struct  {
00036   int n;
00037   double sum;
00038   double sqr;
00039 } sstdisksim_stat;
00040 
00041 class sstdisksim : public Component {
00042 
00043  public:
00044 
00045   sstdisksim( ComponentId_t id, Params_t& params );
00046   ~sstdisksim();
00047   int Setup();
00048   int Finish();
00049 
00050   SysTime __now;                /* current time */
00051   SysTime __next_event; /* next event */
00052   sstdisksim_stat __st;
00053   
00054  private:
00055 
00056   bool __done;
00057   sstdisksim_stat __disksim_stat;
00058   struct disksim_interface* __disksim;
00059   Simulation* __sim;
00060   Params_t __params;
00061   ComponentId_t __id;
00062 
00063   /* To be removed later-this is just to test the component
00064      before we start having trace-reading functionality. */
00065   int numsectors;
00066 
00067   Log< DISKSIM_DBG >&  m_dbg;
00068   
00069   sstdisksim( const sstdisksim& c );
00070   
00071   unsigned long sstdisksim_process_event(sstdisksim_event* ev);
00072   unsigned long processBlock(unsigned long blkno,
00073                              unsigned long count,
00074                              int devno, 
00075                              eventtype etype);
00076   void handleEvent(Event* ev);
00077   void emptyEvent(Event* ev);
00078 
00079   bool clock(Cycle_t current);
00080 
00081 
00082   SST::Link* link;
00083   SST::Link* empty;
00084   
00085   friend class boost::serialization::access;
00086   template<class Archive>
00087     void save(Archive & ar, const unsigned int version) const
00088     {
00089       ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Component);
00090       ar & BOOST_SERIALIZATION_NVP(numsectors);
00091       ar & BOOST_SERIALIZATION_NVP(link);
00092     }
00093   
00094   template<class Archive>
00095     void load(Archive & ar, const unsigned int version)
00096     {
00097       ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Component);
00098       ar & BOOST_SERIALIZATION_NVP(numsectors);
00099       ar & BOOST_SERIALIZATION_NVP(link);
00100       ar & BOOST_SERIALIZATION_NVP(empty);
00101 
00102       
00103       link->setFunctor(new SST::Event::Handler<sstdisksim>(this, &sstdisksim::handleEvent));
00104       empty->setFunctor(new SST::Event::Handler<sstdisksim>(this, &sstdisksim::emptyEvent));
00105     }
00106         
00107   BOOST_SERIALIZATION_SPLIT_MEMBER()    
00108 };
00109 
00110 #endif /* _SSTDISKSIM_H */

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