Deleted Added
sdiff udiff text old ( 11108:6342ddf6d733 ) new ( 11111:6da33e720481 )
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;

--- 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 assert(m_units_remaining[vnet] >= 0);
98
99 while (bw_remaining > 0 && (in->isReady() || m_units_remaining[vnet] > 0) &&
100 out->areNSlotsAvailable(1)) {
101
102 // See if we are done transferring the previous message on
103 // this virtual network
104 if (m_units_remaining[vnet] == 0 && in->isReady()) {
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
117 in->dequeue();
118 out->enqueue(msg_ptr, 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
131 if (bw_remaining > 0 && (in->isReady() || m_units_remaining[vnet] > 0) &&
132 !out->areNSlotsAvailable(1)) {
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 ---