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

sst/elements/include/eventChannel.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 _EVENT_CHANNEL_H
00014 #define _EVENT_CHANNEL_H
00015 
00016 #include <deque>
00017 
00018 #include <sst/core/component.h>
00019 #include <sst/core/event.h>
00020 #include <sst/core/link.h>
00021 #include <sst/core/log.h>
00022 
00023 #ifndef EVENTCHANNEL_DBG
00024 #define EVENTCHANNEL_DBG 0 
00025 #endif
00026 
00027 using namespace SST;
00028 
00029 template < typename eventT >
00030 class ChannelEvent : public Event {
00031     public:
00032         typedef enum { CREDIT, EVENT } type_t;
00033         type_t      type;
00034         uint32_t    credit;
00035         eventT*     event;
00036         int         virtChan;
00037 };
00038 
00039 template < typename eventT >
00040 class EventChannel 
00041 {
00042         typedef ChannelEvent<eventT>    event_t;
00043 
00044     public: // functions
00045 
00046         virtual ~EventChannel() {;}
00047         EventChannel( Component&, Component::Params_t, 
00048                                     std::string name, int numVC = 1 );
00049 
00050         virtual bool ready( int credits, int vc = 0 );
00051         virtual bool send( eventT*, int credits, int vc = 0 );
00052         virtual bool recv( eventT**, int vc = 0);
00053 
00054     private: // functions
00055 
00056         EventChannel( const EventChannel< eventT >& );
00057         void handler( Event* );
00058         bool clock( Cycle_t );
00059 
00060     private:
00061         class VirtChan {
00062                 typedef std::deque< ChannelEvent< eventT >* > que_t;
00063             public: 
00064                 VirtChan( int vc, Link& link, std::string& name, bool dbgFlag,
00065                         int startCredit = 1, int threshold = 0 );
00066                 bool clock( Cycle_t );
00067                 void handler( event_t* );
00068                 bool ready( int credits );
00069                 bool send( eventT*, int credits );
00070                 bool recv( eventT** );
00071 
00072             private:
00073                 int         m_vc;
00074                 Link&       m_link;
00075                 uint32_t    m_creditAvail; 
00076                 uint32_t    m_creditFreed; 
00077                 uint32_t    m_creditThreshold;
00078                 que_t       m_inQ;
00079                 que_t       m_outQ;
00080                 std::string& m_name;
00081 
00082                 Log< EVENTCHANNEL_DBG >&    m_dbg;
00083         };
00084 
00085     private: // data
00086 
00087         Component&                  m_component;
00088         std::vector< VirtChan* >    m_vcV;
00089 
00090         Log<>&                      m_log;        
00091         Log< EVENTCHANNEL_DBG >&    m_dbg;
00092 };
00093 
00094 #define EVENTCHANNEL( retType ) \
00095 template < typename eventT >\
00096 retType EventChannel< eventT >\
00097 
00098 #include <sst/elements/include/eventChannel2.h>
00099 
00100 #endif

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