SimpleNetwork.hh (11124:5d38dc2f7d66) SimpleNetwork.hh (11663:cf870cd20cfc)
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/network/Network.hh"
36#include "params/SimpleNetwork.hh"
37
38class NetDest;
39class MessageBuffer;
40class Throttle;
41class Switch;
42
43class SimpleNetwork : public Network
44{
45 public:
46 typedef SimpleNetworkParams Params;
47 SimpleNetwork(const Params *p);
48 ~SimpleNetwork();
49
50 void init();
51
52 int getBufferSize() { return m_buffer_size; }
53 int getEndpointBandwidth() { return m_endpoint_bandwidth; }
54 bool getAdaptiveRouting() {return m_adaptive_routing; }
55
56 void collateStats();
57 void regStats();
58
59 bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
60
61 // 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/network/Network.hh"
36#include "params/SimpleNetwork.hh"
37
38class NetDest;
39class MessageBuffer;
40class Throttle;
41class Switch;
42
43class SimpleNetwork : public Network
44{
45 public:
46 typedef SimpleNetworkParams Params;
47 SimpleNetwork(const Params *p);
48 ~SimpleNetwork();
49
50 void init();
51
52 int getBufferSize() { return m_buffer_size; }
53 int getEndpointBandwidth() { return m_endpoint_bandwidth; }
54 bool getAdaptiveRouting() {return m_adaptive_routing; }
55
56 void collateStats();
57 void regStats();
58
59 bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
60
61 // Methods used by Topology to setup the network
62 void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
63 LinkDirection direction,
62 void makeExtOutLink(SwitchID src, NodeID dest, BasicLink* link,
64 const NetDest& routing_table_entry);
63 const NetDest& routing_table_entry);
65 void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
66 LinkDirection direction,
64 void makeExtInLink(NodeID src, SwitchID dest, BasicLink* link,
67 const NetDest& routing_table_entry);
68 void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
65 const NetDest& routing_table_entry);
66 void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
69 LinkDirection direction,
70 const NetDest& routing_table_entry);
71
72 void print(std::ostream& out) const;
73
74 bool functionalRead(Packet *pkt);
75 uint32_t functionalWrite(Packet *pkt);
76
77 private:
78 void addLink(SwitchID src, SwitchID dest, int link_latency);
79 void makeLink(SwitchID src, SwitchID dest,
80 const NetDest& routing_table_entry, int link_latency);
81 void makeTopology();
82
83 // Private copy constructor and assignment operator
84 SimpleNetwork(const SimpleNetwork& obj);
85 SimpleNetwork& operator=(const SimpleNetwork& obj);
86
87 std::vector<Switch*> m_switches;
88 std::vector<MessageBuffer*> m_int_link_buffers;
89 int m_num_connected_buffers;
90 const int m_buffer_size;
91 const int m_endpoint_bandwidth;
92 const bool m_adaptive_routing;
93
94 //Statistical variables
95 Stats::Formula m_msg_counts[MessageSizeType_NUM];
96 Stats::Formula m_msg_bytes[MessageSizeType_NUM];
97};
98
99inline std::ostream&
100operator<<(std::ostream& out, const SimpleNetwork& obj)
101{
102 obj.print(out);
103 out << std::flush;
104 return out;
105}
106
107#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__
67 const NetDest& routing_table_entry);
68
69 void print(std::ostream& out) const;
70
71 bool functionalRead(Packet *pkt);
72 uint32_t functionalWrite(Packet *pkt);
73
74 private:
75 void addLink(SwitchID src, SwitchID dest, int link_latency);
76 void makeLink(SwitchID src, SwitchID dest,
77 const NetDest& routing_table_entry, int link_latency);
78 void makeTopology();
79
80 // Private copy constructor and assignment operator
81 SimpleNetwork(const SimpleNetwork& obj);
82 SimpleNetwork& operator=(const SimpleNetwork& obj);
83
84 std::vector<Switch*> m_switches;
85 std::vector<MessageBuffer*> m_int_link_buffers;
86 int m_num_connected_buffers;
87 const int m_buffer_size;
88 const int m_endpoint_bandwidth;
89 const bool m_adaptive_routing;
90
91 //Statistical variables
92 Stats::Formula m_msg_counts[MessageSizeType_NUM];
93 Stats::Formula m_msg_bytes[MessageSizeType_NUM];
94};
95
96inline std::ostream&
97operator<<(std::ostream& out, const SimpleNetwork& obj)
98{
99 obj.print(out);
100 out << std::flush;
101 return out;
102}
103
104#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__