Throttle.cc (11108:6342ddf6d733) | Throttle.cc (11111:6da33e720481) |
---|---|
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; --- 80 unchanged lines hidden (view full) --- 89 90void 91Throttle::operateVnet(int vnet, int &bw_remaining, bool &schedule_wakeup, 92 MessageBuffer *in, MessageBuffer *out) 93{ 94 if (out == nullptr || in == nullptr) { 95 return; 96 } | 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; --- 80 unchanged lines hidden (view full) --- 89 90void 91Throttle::operateVnet(int vnet, int &bw_remaining, bool &schedule_wakeup, 92 MessageBuffer *in, MessageBuffer *out) 93{ 94 if (out == nullptr || in == nullptr) { 95 return; 96 } |
97 |
|
97 assert(m_units_remaining[vnet] >= 0); | 98 assert(m_units_remaining[vnet] >= 0); |
99 Tick current_time = m_switch->clockEdge(); |
|
98 | 100 |
99 while (bw_remaining > 0 && (in->isReady() || m_units_remaining[vnet] > 0) && 100 out->areNSlotsAvailable(1)) { 101 | 101 while (bw_remaining > 0 && (in->isReady(current_time) || 102 m_units_remaining[vnet] > 0) && 103 out->areNSlotsAvailable(1, current_time)) { |
102 // See if we are done transferring the previous message on 103 // this virtual network | 104 // See if we are done transferring the previous message on 105 // this virtual network |
104 if (m_units_remaining[vnet] == 0 && in->isReady()) { | 106 if (m_units_remaining[vnet] == 0 && in->isReady(current_time)) { |
105 // Find the size of the message we are moving 106 MsgPtr msg_ptr = in->peekMsgPtr(); 107 Message *net_msg_ptr = msg_ptr.get(); 108 m_units_remaining[vnet] += 109 network_message_to_size(net_msg_ptr); 110 111 DPRINTF(RubyNetwork, "throttle: %d my bw %d bw spent " 112 "enqueueing net msg %d time: %lld.\n", 113 m_node, getLinkBandwidth(), m_units_remaining[vnet], 114 m_ruby_system->curCycle()); 115 116 // Move the message | 107 // Find the size of the message we are moving 108 MsgPtr msg_ptr = in->peekMsgPtr(); 109 Message *net_msg_ptr = msg_ptr.get(); 110 m_units_remaining[vnet] += 111 network_message_to_size(net_msg_ptr); 112 113 DPRINTF(RubyNetwork, "throttle: %d my bw %d bw spent " 114 "enqueueing net msg %d time: %lld.\n", 115 m_node, getLinkBandwidth(), m_units_remaining[vnet], 116 m_ruby_system->curCycle()); 117 118 // Move the message |
117 in->dequeue(); 118 out->enqueue(msg_ptr, m_link_latency); | 119 in->dequeue(current_time); 120 out->enqueue(msg_ptr, current_time, 121 m_switch->cyclesToTicks(m_link_latency)); |
119 120 // Count the message 121 m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++; 122 DPRINTF(RubyNetwork, "%s\n", *out); 123 } 124 125 // Calculate the amount of bandwidth we spent on this message 126 int diff = m_units_remaining[vnet] - bw_remaining; 127 m_units_remaining[vnet] = max(0, diff); 128 bw_remaining = max(0, -diff); 129 } 130 | 122 123 // Count the message 124 m_msg_counts[net_msg_ptr->getMessageSize()][vnet]++; 125 DPRINTF(RubyNetwork, "%s\n", *out); 126 } 127 128 // Calculate the amount of bandwidth we spent on this message 129 int diff = m_units_remaining[vnet] - bw_remaining; 130 m_units_remaining[vnet] = max(0, diff); 131 bw_remaining = max(0, -diff); 132 } 133 |
131 if (bw_remaining > 0 && (in->isReady() || m_units_remaining[vnet] > 0) && 132 !out->areNSlotsAvailable(1)) { | 134 if (bw_remaining > 0 && (in->isReady(current_time) || 135 m_units_remaining[vnet] > 0) && 136 !out->areNSlotsAvailable(1, current_time)) { |
133 DPRINTF(RubyNetwork, "vnet: %d", vnet); 134 135 // schedule me to wakeup again because I'm waiting for my 136 // output queue to become available 137 schedule_wakeup = true; 138 } 139} 140 --- 116 unchanged lines hidden --- | 137 DPRINTF(RubyNetwork, "vnet: %d", vnet); 138 139 // schedule me to wakeup again because I'm waiting for my 140 // output queue to become available 141 schedule_wakeup = true; 142 } 143} 144 --- 116 unchanged lines hidden --- |