AbstractController.cc (9595:470016acf37d) AbstractController.cc (9596:aa73a81cf92c)
1/*
2 * Copyright (c) 2011 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;

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

81}
82
83void
84AbstractController::connectWithPeer(AbstractController *c)
85{
86 getQueuesFromPeer(c);
87 c->getQueuesFromPeer(this);
88}
1/*
2 * Copyright (c) 2011 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;

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

81}
82
83void
84AbstractController::connectWithPeer(AbstractController *c)
85{
86 getQueuesFromPeer(c);
87 c->getQueuesFromPeer(this);
88}
89
90void
91AbstractController::stallBuffer(MessageBuffer* buf, Address addr)
92{
93 if (m_waiting_buffers.count(addr) == 0) {
94 MsgVecType* msgVec = new MsgVecType;
95 msgVec->resize(m_max_in_port_rank, NULL);
96 m_waiting_buffers[addr] = msgVec;
97 }
98 (*(m_waiting_buffers[addr]))[m_cur_in_port_rank] = buf;
99}
100
101void
102AbstractController::wakeUpBuffers(Address addr)
103{
104 if (m_waiting_buffers.count(addr) > 0) {
105 //
106 // Wake up all possible lower rank (i.e. lower priority) buffers that could
107 // be waiting on this message.
108 //
109 for (int in_port_rank = m_cur_in_port_rank - 1;
110 in_port_rank >= 0;
111 in_port_rank--) {
112 if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
113 (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
114 }
115 }
116 delete m_waiting_buffers[addr];
117 m_waiting_buffers.erase(addr);
118 }
119}
120
121void
122AbstractController::wakeUpAllBuffers(Address addr)
123{
124 if (m_waiting_buffers.count(addr) > 0) {
125 //
126 // Wake up all possible lower rank (i.e. lower priority) buffers that could
127 // be waiting on this message.
128 //
129 for (int in_port_rank = m_max_in_port_rank - 1;
130 in_port_rank >= 0;
131 in_port_rank--) {
132 if ((*(m_waiting_buffers[addr]))[in_port_rank] != NULL) {
133 (*(m_waiting_buffers[addr]))[in_port_rank]->reanalyzeMessages(addr);
134 }
135 }
136 delete m_waiting_buffers[addr];
137 m_waiting_buffers.erase(addr);
138 }
139}
140
141void
142AbstractController::wakeUpAllBuffers()
143{
144 //
145 // Wake up all possible buffers that could be waiting on any message.
146 //
147
148 std::vector<MsgVecType*> wokeUpMsgVecs;
149
150 if(m_waiting_buffers.size() > 0) {
151 for (WaitingBufType::iterator buf_iter = m_waiting_buffers.begin();
152 buf_iter != m_waiting_buffers.end();
153 ++buf_iter) {
154 for (MsgVecType::iterator vec_iter = buf_iter->second->begin();
155 vec_iter != buf_iter->second->end();
156 ++vec_iter) {
157 if (*vec_iter != NULL) {
158 (*vec_iter)->reanalyzeAllMessages();
159 }
160 }
161 wokeUpMsgVecs.push_back(buf_iter->second);
162 }
163
164 for (std::vector<MsgVecType*>::iterator wb_iter = wokeUpMsgVecs.begin();
165 wb_iter != wokeUpMsgVecs.end();
166 ++wb_iter) {
167 delete (*wb_iter);
168 }
169
170 m_waiting_buffers.clear();
171 }
172}