BasicLink.cc revision 6493
1
2#include "mem/protocol/MachineType.hh"
3#include "mem/ruby/network/Network.hh"
4
5Network::Network(const string & name)
6  :  m_name(name)
7{
8  m_virtual_networks = 0;
9  m_topology_ptr = NULL;
10}
11
12void Network::init(const vector<string> & argv)
13{
14  m_nodes = MachineType_base_number(MachineType_NUM); // Total nodes in network
15
16  for (size_t i=0; i<argv.size(); i+=2) {
17   if (argv[i] == "number_of_virtual_networks")
18     m_virtual_networks = atoi(argv[i+1].c_str());
19   else if (argv[i] == "topology")
20     m_topology_ptr = RubySystem::getTopology(argv[i+1]);
21   else if (argv[i] == "buffer_size")
22     m_buffer_size = atoi(argv[i+1].c_str());
23   else if (argv[i] == "endpoint_bandwidth")
24     m_endpoint_bandwidth = atoi(argv[i+1].c_str());
25   else if (argv[i] == "adaptive_routing")
26     m_adaptive_routing = (argv[i+1]=="true");
27   else if (argv[i] == "link_latency")
28     m_link_latency = atoi(argv[i+1].c_str());
29   else if (argv[i] == "control_msg_size")
30     m_control_msg_size = atoi(argv[i+1].c_str());
31  }
32
33  m_data_msg_size = RubySystem::getBlockSizeBytes() + m_control_msg_size;
34
35  assert(m_virtual_networks != 0);
36  assert(m_topology_ptr != NULL);
37}
38
39int Network::MessageSizeType_to_int(MessageSizeType size_type)
40{
41  switch(size_type) {
42  case MessageSizeType_Undefined:
43    ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
44    break;
45  case MessageSizeType_Control:
46  case MessageSizeType_Request_Control:
47  case MessageSizeType_Reissue_Control:
48  case MessageSizeType_Response_Control:
49  case MessageSizeType_Writeback_Control:
50  case MessageSizeType_Forwarded_Control:
51  case MessageSizeType_Invalidate_Control:
52  case MessageSizeType_Unblock_Control:
53  case MessageSizeType_Persistent_Control:
54  case MessageSizeType_Completion_Control:
55    return m_control_msg_size;
56    break;
57  case MessageSizeType_Data:
58  case MessageSizeType_Response_Data:
59  case MessageSizeType_ResponseLocal_Data:
60  case MessageSizeType_ResponseL2hit_Data:
61  case MessageSizeType_Writeback_Data:
62    return m_data_msg_size;
63    break;
64  default:
65    ERROR_MSG("Invalid range for type MessageSizeType");
66    break;
67  }
68  return 0;
69}
70