SimpleNetwork.hh (11049:dfb0aa3f0649) SimpleNetwork.hh (11064:386a5200e298)
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 // sets the queue requested
60 void setToNetQueue(NodeID id, bool ordered, int network_num,
61 std::string vnet_type, MessageBuffer *b);
62 void setFromNetQueue(NodeID id, bool ordered, int network_num,
63 std::string vnet_type, MessageBuffer *b);
64
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 // sets the queue requested
60 void setToNetQueue(NodeID id, bool ordered, int network_num,
61 std::string vnet_type, MessageBuffer *b);
62 void setFromNetQueue(NodeID id, bool ordered, int network_num,
63 std::string vnet_type, MessageBuffer *b);
64
65 bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
66 bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
65 bool isVNetOrdered(int vnet) const { return m_ordered[vnet]; }
67
68 // Methods used by Topology to setup the network
69 void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
70 LinkDirection direction,
71 const NetDest& routing_table_entry);
72 void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
73 LinkDirection direction,
74 const NetDest& routing_table_entry);
75 void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
76 LinkDirection direction,
77 const NetDest& routing_table_entry);
78
79 void print(std::ostream& out) const;
80
81 bool functionalRead(Packet *pkt);
82 uint32_t functionalWrite(Packet *pkt);
83
84 private:
85 void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
86 void addLink(SwitchID src, SwitchID dest, int link_latency);
87 void makeLink(SwitchID src, SwitchID dest,
88 const NetDest& routing_table_entry, int link_latency);
89 void makeTopology();
90
91 // Private copy constructor and assignment operator
92 SimpleNetwork(const SimpleNetwork& obj);
93 SimpleNetwork& operator=(const SimpleNetwork& obj);
94
95 std::vector<Switch*> m_switches;
96 std::vector<MessageBuffer*> m_int_link_buffers;
97 int m_num_connected_buffers;
98 std::vector<Switch*> m_endpoint_switches;
99
100 int m_buffer_size;
101 int m_endpoint_bandwidth;
102 bool m_adaptive_routing;
103
104 //Statistical variables
105 Stats::Formula m_msg_counts[MessageSizeType_NUM];
106 Stats::Formula m_msg_bytes[MessageSizeType_NUM];
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__
66
67 // Methods used by Topology to setup the network
68 void makeOutLink(SwitchID src, NodeID dest, BasicLink* link,
69 LinkDirection direction,
70 const NetDest& routing_table_entry);
71 void makeInLink(NodeID src, SwitchID dest, BasicLink* link,
72 LinkDirection direction,
73 const NetDest& routing_table_entry);
74 void makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
75 LinkDirection direction,
76 const NetDest& routing_table_entry);
77
78 void print(std::ostream& out) const;
79
80 bool functionalRead(Packet *pkt);
81 uint32_t functionalWrite(Packet *pkt);
82
83 private:
84 void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
85 void addLink(SwitchID src, SwitchID dest, int link_latency);
86 void makeLink(SwitchID src, SwitchID dest,
87 const NetDest& routing_table_entry, int link_latency);
88 void makeTopology();
89
90 // Private copy constructor and assignment operator
91 SimpleNetwork(const SimpleNetwork& obj);
92 SimpleNetwork& operator=(const SimpleNetwork& obj);
93
94 std::vector<Switch*> m_switches;
95 std::vector<MessageBuffer*> m_int_link_buffers;
96 int m_num_connected_buffers;
97 std::vector<Switch*> m_endpoint_switches;
98
99 int m_buffer_size;
100 int m_endpoint_bandwidth;
101 bool m_adaptive_routing;
102
103 //Statistical variables
104 Stats::Formula m_msg_counts[MessageSizeType_NUM];
105 Stats::Formula m_msg_bytes[MessageSizeType_NUM];
106};
107
108inline std::ostream&
109operator<<(std::ostream& out, const SimpleNetwork& obj)
110{
111 obj.print(out);
112 out << std::flush;
113 return out;
114}
115
116#endif // __MEM_RUBY_NETWORK_SIMPLE_SIMPLENETWORK_HH__