garnet: separate data and ctrl VCs
[gem5.git] / src / mem / ruby / network / garnet / fixed-pipeline / GarnetNetwork_d.hh
1 /*
2 * Copyright (c) 2008 Princeton University
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 * Authors: Niket Agarwal
29 */
30
31 #ifndef __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
32 #define __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__
33
34 #include <iostream>
35 #include <vector>
36
37 #include "mem/ruby/network/garnet/NetworkHeader.hh"
38 #include "mem/ruby/network/garnet/BaseGarnetNetwork.hh"
39 #include "mem/ruby/network/Network.hh"
40 #include "params/GarnetNetwork_d.hh"
41
42 class NetworkInterface_d;
43 class MessageBuffer;
44 class Router_d;
45 class Topology;
46 class NetDest;
47 class NetworkLink_d;
48 class CreditLink_d;
49
50 class GarnetNetwork_d : public BaseGarnetNetwork
51 {
52 public:
53 typedef GarnetNetwork_dParams Params;
54 GarnetNetwork_d(const Params *p);
55
56 ~GarnetNetwork_d();
57
58 void init();
59
60 int getNumNodes() { return m_nodes; }
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
66 void clearStats();
67 void printStats(std::ostream& out) const;
68 void printConfig(std::ostream& out) const;
69 void print(std::ostream& out) const;
70
71 void
72 set_vnet_type(int vc, VNET_type vnet_type)
73 {
74 int vnet = vc/getVCsPerClass();
75 m_vnet_type[vnet] = vnet_type;
76 }
77
78 VNET_type
79 get_vnet_type(int vc)
80 {
81 int vnet = vc/getVCsPerClass();
82 return m_vnet_type[vnet];
83 }
84
85
86 inline void increment_injected_flits() { m_flits_injected++; }
87 inline void increment_received_flits() { m_flits_received++; }
88
89 inline void
90 increment_network_latency(Time latency)
91 {
92 m_network_latency += latency;
93 }
94
95 inline void
96 increment_queueing_latency(Time latency)
97 {
98 m_queueing_latency += latency;
99 }
100
101 bool isVNetOrdered(int vnet) { return m_ordered[vnet]; }
102 bool validVirtualNetwork(int vnet) { return m_in_use[vnet]; }
103 Time getRubyStartTime();
104
105 void reset();
106
107 // Methods used by Topology to setup the network
108 void makeOutLink(SwitchID src, NodeID dest,
109 const NetDest& routing_table_entry, int link_latency, int link_weight,
110 int bw_multiplier, bool isReconfiguration);
111 void makeInLink(SwitchID src, NodeID dest,
112 const NetDest& routing_table_entry, int link_latency,
113 int bw_multiplier, bool isReconfiguration);
114 void makeInternalLink(SwitchID src, NodeID dest,
115 const NetDest& routing_table_entry, int link_latency, int link_weight,
116 int bw_multiplier, bool isReconfiguration);
117
118 private:
119 void checkNetworkAllocation(NodeID id, bool ordered, int network_num);
120
121 GarnetNetwork_d(const GarnetNetwork_d& obj);
122 GarnetNetwork_d& operator=(const GarnetNetwork_d& obj);
123
124 std::vector<VNET_type > m_vnet_type;
125 // int m_virtual_networks;
126 // int m_nodes;
127 int m_flits_received, m_flits_injected;
128 double m_network_latency, m_queueing_latency;
129
130 std::vector<bool> m_in_use;
131 std::vector<bool> m_ordered;
132
133 std::vector<std::vector<MessageBuffer*> > m_toNetQueues;
134 std::vector<std::vector<MessageBuffer*> > m_fromNetQueues;
135
136 std::vector<Router_d *> m_router_ptr_vector; // All Routers in Network
137 std::vector<NetworkLink_d *> m_link_ptr_vector; // All links in the network
138 std::vector<CreditLink_d *> m_creditlink_ptr_vector; // All links in net
139 std::vector<NetworkInterface_d *> m_ni_ptr_vector; // All NI's in Network
140
141 // Topology* m_topology_ptr;
142 Time m_ruby_start;
143 };
144
145 inline std::ostream&
146 operator<<(std::ostream& out, const GarnetNetwork_d& obj)
147 {
148 obj.print(out);
149 out << std::flush;
150 return out;
151 }
152
153 #endif // __MEM_RUBY_NETWORK_GARNET_FIXED_PIPELINE_GARNETNETWORK_D_HH__