Deleted Added
sdiff udiff text old ( 10303:71e0934af9f1 ) new ( 10311:ad9c042dce54 )
full compact
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;

--- 79 unchanged lines hidden (view full) ---

88 const NetDest& routing_table_entry)
89{
90 assert(dest < m_nodes);
91 assert(src < m_switches.size());
92 assert(m_switches[src] != NULL);
93
94 SimpleExtLink *simple_link = safe_cast<SimpleExtLink*>(link);
95
96 m_switches[src]->addOutPort(m_fromNetQueues[dest],
97 routing_table_entry,
98 simple_link->m_latency,
99 simple_link->m_bw_multiplier);
100
101 m_endpoint_switches[dest] = m_switches[src];
102}
103
104// From an endpoint node to a switch
105void
106SimpleNetwork::makeInLink(NodeID src, SwitchID dest, BasicLink* link,
107 LinkDirection direction,

--- 5 unchanged lines hidden (view full) ---

113
114// From a switch to a switch
115void
116SimpleNetwork::makeInternalLink(SwitchID src, SwitchID dest, BasicLink* link,
117 LinkDirection direction,
118 const NetDest& routing_table_entry)
119{
120 // Create a set of new MessageBuffers
121 std::vector<MessageBuffer*> queues;
122 for (int i = 0; i < m_virtual_networks; i++) {
123 // allocate a buffer
124 MessageBuffer* buffer_ptr = new MessageBuffer;
125 buffer_ptr->setOrdering(true);
126 if (m_buffer_size > 0) {
127 buffer_ptr->resize(m_buffer_size);
128 }
129 queues.push_back(buffer_ptr);
130 // remember to deallocate it
131 m_buffers_to_free.push_back(buffer_ptr);
132 }
133 // Connect it to the two switches
134 SimpleIntLink *simple_link = safe_cast<SimpleIntLink*>(link);
135
136 m_switches[dest]->addInPort(queues);
137 m_switches[src]->addOutPort(queues, routing_table_entry,
138 simple_link->m_latency,
139 simple_link->m_bw_multiplier);
140}
141
142void
143SimpleNetwork::checkNetworkAllocation(NodeID id, bool ordered, int network_num)
144{
145 assert(id < m_nodes);
146 assert(network_num < m_virtual_networks);
147
148 if (ordered) {
149 m_ordered[network_num] = true;
150 }
151 m_in_use[network_num] = true;
152}
153
154MessageBuffer*
155SimpleNetwork::getToNetQueue(NodeID id, bool ordered, int network_num,
156 std::string vnet_type)
157{
158 checkNetworkAllocation(id, ordered, network_num);
159 return m_toNetQueues[id][network_num];
160}
161
162MessageBuffer*
163SimpleNetwork::getFromNetQueue(NodeID id, bool ordered, int network_num,
164 std::string vnet_type)
165{
166 checkNetworkAllocation(id, ordered, network_num);
167 return m_fromNetQueues[id][network_num];
168}
169
170void
171SimpleNetwork::regStats()
172{
173 for (MessageSizeType type = MessageSizeType_FIRST;
174 type < MessageSizeType_NUM; ++type) {
175 m_msg_counts[(unsigned int) type]

--- 77 unchanged lines hidden ---