35 #include "debug/RubyNetwork.hh"
52 int link_bandwidth_multiplier,
int endpoint_bandwidth,
54 :
Consumer(em), m_switch_id(sID), m_switch(em), m_node(node),
59 assert(link_bandwidth_multiplier > 0);
73 assert(in_vec.size() == out_vec.size());
75 for (
int vnet = 0; vnet < in_vec.size(); ++vnet) {
81 m_in.push_back(in_ptr);
82 m_out.push_back(out_ptr);
86 string desc =
"[Queue to Throttle " + to_string(
m_switch_id) +
" " +
95 if (out ==
nullptr || in ==
nullptr) {
102 while (bw_remaining > 0 && (in->
isReady(current_time) ||
110 Message *net_msg_ptr = msg_ptr.get();
114 DPRINTF(RubyNetwork,
"throttle: %d my bw %d bw spent "
115 "enqueueing net msg %d time: %lld.\n",
121 out->
enqueue(msg_ptr, current_time,
126 DPRINTF(RubyNetwork,
"%s\n", *out);
132 bw_remaining = max(0, -diff);
135 if (bw_remaining > 0 && (in->
isReady(current_time) ||
138 DPRINTF(RubyNetwork,
"vnet: %d", vnet);
142 schedule_wakeup =
true;
154 bool schedule_wakeup =
false;
157 bool iteration_direction =
false;
163 iteration_direction =
true;
166 if (iteration_direction) {
167 for (
int vnet = 0; vnet <
m_vnets; ++vnet) {
172 for (
int vnet =
m_vnets-1; vnet >= 0; --vnet) {
188 if (bw_remaining > 0 && !schedule_wakeup) {
192 DPRINTF(RubyNetwork,
"%s not scheduled again\n", *
this);
194 DPRINTF(RubyNetwork,
"%s scheduled again\n", *
this);
208 for (MessageSizeType
type = MessageSizeType_FIRST;
209 type < MessageSizeType_NUM; ++
type) {
213 MessageSizeType_to_string(
type))
218 MessageSizeType_to_string(
type))
251 assert(net_msg_ptr != NULL);
void ccprintf(cp::Print &print)
virtual const MessageSizeType & getMessageSize() const
std::vector< MessageBuffer * > m_out
virtual const NetDest & getDestination() const
Cycles is a wrapper class for representing cycle counts, i.e.
void addLinks(const std::vector< MessageBuffer * > &in_vec, const std::vector< MessageBuffer * > &out_vec)
std::shared_ptr< Message > MsgPtr
std::vector< MessageBuffer * > m_in
Stats::Formula m_msg_bytes[MessageSizeType_NUM]
void scheduleEvent(Cycles timeDelta)
Tick cyclesToTicks(Cycles c) const
static uint32_t getNumberOfVirtualNetworks()
void init(NodeID node, Cycles link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth)
std::vector< int > m_units_remaining
int getLinkBandwidth() const
RubySystem * m_ruby_system
void print(std::ostream &out) const
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Stats::Scalar m_link_utilization
Throttle(int sID, RubySystem *rs, NodeID node, Cycles link_latency, int link_bandwidth_multiplier, int endpoint_bandwidth, Switch *em)
bool areNSlotsAvailable(unsigned int n, Tick curTime)
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
const MsgPtr & peekMsgPtr() const
double m_link_utilization_proxy
int m_link_bandwidth_multiplier
std::string csprintf(const char *format, const Args &...args)
const int MESSAGE_SIZE_MULTIPLIER
uint64_t Tick
Tick count type.
void setConsumer(Consumer *consumer)
Tick dequeue(Tick current_time, bool decrement_messages=true)
Updates the delay cycles of the message at the head of the queue, removes it from the queue and retur...
const int BROADCAST_SCALING
Stats::Vector m_msg_counts[MessageSizeType_NUM]
static uint32_t MessageSizeType_to_int(MessageSizeType size_type)
const int PRIORITY_SWITCH_LIMIT
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
bool isReady(Tick current_time) const
static int network_message_to_size(Message *net_msg_ptr)
const FlagsType nozero
Don't print if this is zero.
void enqueue(MsgPtr message, Tick curTime, Tick delta)
void regStats(std::string name)
void operateVnet(int vnet, int &bw_remainin, bool &schedule_wakeup, MessageBuffer *in, MessageBuffer *out)