SimpleNetwork.hh (8254:779d775abc11) SimpleNetwork.hh (8257:7226aebb77b4)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
30#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
31
32#include <iostream>
33#include <vector>
34
35#include "mem/ruby/common/Global.hh"
36#include "mem/ruby/network/Network.hh"
37#include "mem/ruby/system/NodeID.hh"
38#include "params/SimpleNetwork.hh"
39#include "sim/sim_object.hh"
40
41class NetDest;
42class MessageBuffer;
43class Throttle;
44class Switch;
45class Topology;
46
47class SimpleNetwork : public Network
48{
49 public:
50 typedef SimpleNetworkParams Params;
51 SimpleNetwork(const Params *p);
52 ~SimpleNetwork();
53
54 void init();
55
56 void printStats(std::ostream& out) const;
57 void clearStats();
58 void printConfig(std::ostream& out) const;
59
60 void reset();
61
62 // returns the queue requested for the given component
63 MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
64 MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
65 virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
66
67 bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
68 bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
69
70 int getNumNodes() {return m_nodes; }
71
72 // Methods used by Topology to setup the network
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
30#define __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
31
32#include <iostream>
33#include <vector>
34
35#include "mem/ruby/common/Global.hh"
36#include "mem/ruby/network/Network.hh"
37#include "mem/ruby/system/NodeID.hh"
38#include "params/SimpleNetwork.hh"
39#include "sim/sim_object.hh"
40
41class NetDest;
42class MessageBuffer;
43class Throttle;
44class Switch;
45class Topology;
46
47class SimpleNetwork : public Network
48{
49 public:
50 typedef SimpleNetworkParams Params;
51 SimpleNetwork(const Params *p);
52 ~SimpleNetwork();
53
54 void init();
55
56 void printStats(std::ostream& out) const;
57 void clearStats();
58 void printConfig(std::ostream& out) const;
59
60 void reset();
61
62 // returns the queue requested for the given component
63 MessageBuffer* getToNetQueue(NodeID id, bool ordered, int network_num);
64 MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int network_num);
65 virtual const std::vector<Throttle*>* getThrottles(NodeID id) const;
66
67 bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
68 bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
69
70 int getNumNodes() {return m_nodes; }
71
72 // Methods used by Topology to setup the network
73 void makeOutLink(SwitchID src, NodeID dest,
74 const NetDest& routing_table_entry, int link_latency, int link_weight,
75 int bw_multiplier, bool isReconfiguration);
76 void makeInLink(SwitchID src, NodeID dest,
77 const NetDest& routing_table_entry, int link_latency,
78 int bw_multiplier, bool isReconfiguration);
79 void makeInternalLink(SwitchID src, NodeID dest,
80 const NetDest& routing_table_entry, int link_latency, int link_weight,
81 int bw_multiplier, bool isReconfiguration);
73 void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
74 LinkDirection direction,
75 const NetDest& routing_table_entry,
76 bool isReconfiguration);
77 void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
78 LinkDirection direction,
79 const NetDest& routing_table_entry,
80 bool isReconfiguration);
81 void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
82 LinkDirection direction,
83 const NetDest& routing_table_entry,
84 bool isReconfiguration);
82
83 void print(std::ostream& out) const;
84
85 private:
86 void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
87 void addLink(SwitchID src, SwitchID dest, int link_latency);
88 void makeLink(SwitchID src, SwitchID dest,
89 const NetDest& routing_table_entry, int link_latency);
90 SwitchID createSwitch();
91 void makeTopology();
92 void linkTopology();
93
94 // Private copy constructor and assignment operator
95 SimpleNetwork(const SimpleNetwork& obj);
96 SimpleNetwork& operator=(const SimpleNetwork& obj);
97
98 // vector of queues from the components
99 std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
100 std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
101
102 std::vector<bool> m_in_use;
103 std::vector<bool> m_ordered;
104 std::vector<Switch*> m_switch_ptr_vector;
105 std::vector<MessageBuffer*> m_buffers_to_free;
106 std::vector<Switch*> m_endpoint_switches;
107};
108
109inline std::ostream&
110operator<<(std::ostream& out, const SimpleNetwork& obj)
111{
112 obj.print(out);
113 out << std::flush;
114 return out;
115}
116
117#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
85
86 void print(std::ostream& out) const;
87
88 private:
89 void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
90 void addLink(SwitchID src, SwitchID dest, int link_latency);
91 void makeLink(SwitchID src, SwitchID dest,
92 const NetDest& routing_table_entry, int link_latency);
93 SwitchID createSwitch();
94 void makeTopology();
95 void linkTopology();
96
97 // Private copy constructor and assignment operator
98 SimpleNetwork(const SimpleNetwork& obj);
99 SimpleNetwork& operator=(const SimpleNetwork& obj);
100
101 // vector of queues from the components
102 std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
103 std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
104
105 std::vector<bool> m_in_use;
106 std::vector<bool> m_ordered;
107 std::vector<Switch*> m_switch_ptr_vector;
108 std::vector<MessageBuffer*> m_buffers_to_free;
109 std::vector<Switch*> m_endpoint_switches;
110};
111
112inline std::ostream&
113operator<<(std::ostream& out, const SimpleNetwork& obj)
114{
115 obj.print(out);
116 out << std::flush;
117 return out;
118}
119
120#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__