SimpleNetwork.hh revision 6145:15cca6ab723a
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * SimpleNetwork.h
32 *
33 * Description: The SimpleNetwork class implements the interconnection
34 * SimpleNetwork between components (processor/cache components and
35 * memory/directory components).  The interconnection network as
36 * described here is not a physical network, but a programming concept
37 * used to implement all communication between components.  Thus parts
38 * of this 'network' may model the on-chip connections between cache
39 * controllers and directory controllers as well as the links between
40 * chip and network switches.
41 *
42 * Two conceptual networks, an address and data network, are modeled.
43 * The data network is unordered, where the address network provides
44 * and conforms to a global ordering of all transactions.
45 *
46 * Currently the data network is point-to-point and the address
47 * network is a broadcast network. These two distinct conceptual
48 * network can be modeled as physically separate networks or
49 * multiplexed over a single physical network.
50 *
51 * The network encapsulates all notion of virtual global time and is
52 * responsible for ordering the network transactions received.  This
53 * hides all of these ordering details from the processor/cache and
54 * directory/memory modules.
55 *
56 * FIXME: Various flavor of networks are provided as a compiler time
57 *        configurable. We currently include this SimpleNetwork in the
58 *        makefile's vpath, so that SimpleNetwork.C can provide an alternative
59 *        version constructor for the abstract Network class. It is easy to
60 *        modify this to make network a runtime configuable. Just make the
61 *        abstract Network class take a enumeration parameter, and based on
62 *        that to initial proper network. Or even better, just make the ruby
63 *        system initializer choose the proper network to initiate.
64 *
65 * $Id$
66 *
67 */
68
69#ifndef SIMPLENETWORK_H
70#define SIMPLENETWORK_H
71
72#include "Global.hh"
73#include "Vector.hh"
74#include "Network.hh"
75#include "NodeID.hh"
76
77class NetDest;
78class MessageBuffer;
79class Throttle;
80class Switch;
81class Topology;
82
83class SimpleNetwork : public Network {
84public:
85  // Constructors
86  SimpleNetwork(int nodes);
87
88  // Destructor
89  ~SimpleNetwork();
90
91  // Public Methods
92  void printStats(ostream& out) const;
93  void clearStats();
94  void printConfig(ostream& out) const;
95
96  void reset();
97
98  // returns the queue requested for the given component
99  MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
100  MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
101  virtual const Vector<Throttle*>* getThrottles(NodeID id) const;
102
103  bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
104  bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
105
106  int getNumNodes() {return m_nodes; }
107
108  // Methods used by Topology to setup the network
109  void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration);
110  void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration);
111  void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration);
112
113  void print(ostream& out) const;
114private:
115  void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
116  void addLink(SwitchID src, SwitchID dest, int link_latency);
117  void makeLink(SwitchID src, SwitchID dest, const NetDest& routing_table_entry, int link_latency);
118  SwitchID createSwitch();
119  void makeTopology();
120  void linkTopology();
121
122
123  // Private copy constructor and assignment operator
124  SimpleNetwork(const SimpleNetwork& obj);
125  SimpleNetwork& operator=(const SimpleNetwork& obj);
126
127  // Data Members (m_ prefix)
128
129  // vector of queues from the components
130  Vector<Vector<MessageBuffer*> > m_toNetQueues;
131  Vector<Vector<MessageBuffer*> > m_fromNetQueues;
132
133  int m_nodes;
134  int m_virtual_networks;
135  Vector<bool> m_in_use;
136  Vector<bool> m_ordered;
137  Vector<Switch*> m_switch_ptr_vector;
138  Vector<MessageBuffer*> m_buffers_to_free;
139  Vector<Switch*> m_endpoint_switches;
140  Topology* m_topology_ptr;
141};
142
143// Output operator declaration
144ostream& operator<<(ostream& out, const SimpleNetwork& obj);
145
146// ******************* Definitions *******************
147
148// Output operator definition
149extern inline
150ostream& operator<<(ostream& out, const SimpleNetwork& obj)
151{
152  obj.print(out);
153  out << flush;
154  return out;
155}
156
157#endif //SIMPLENETWORK_H
158