Skip to content

Commit 357e658

Browse files
committed
fix simx deadlock bugs caused by LsuMemAdaptor in types.cpp
1 parent 92a6bb0 commit 357e658

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sim/simx/emulator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ bool Emulator::barrier_wait(uint32_t bar_id, uint32_t token, uint32_t wid) {
352352
stalled_warps_.set(wid);
353353
return false;
354354
}
355-
stalled_warps_.reset(wid);
355+
// stalled_warps_.reset(wid);
356356
return true;
357357
}
358358

@@ -367,7 +367,7 @@ bool Emulator::barrier_wait(uint32_t bar_id, uint32_t token, uint32_t wid) {
367367

368368

369369
b.waiting_mask.reset(wid);
370-
stalled_warps_.reset(wid);
370+
// stalled_warps_.reset(wid);
371371

372372

373373
return true;

sim/simx/types.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,27 @@ void LsuMemAdapter::tick() {
150150
out_rsp.uuid = rsp_in.uuid;
151151

152152
// merge other responses with the same tag
153+
std::vector<uint32_t> pop_list;
154+
pop_list.reserve(input_size);
155+
pop_list.push_back(i);
153156
for (uint32_t j = i + 1; j < input_size; ++j) {
154157
if (RspIn.at(j).empty())
155158
continue;
156159
auto& other_rsp = RspIn.at(j).peek();
157160
if (rsp_in.tag == other_rsp.tag) {
158161
out_rsp.mask.set(j);
159162
DT(4, this->name() << "-rsp" << j << ": " << other_rsp);
160-
RspIn.at(j).pop();
163+
pop_list.push_back(j);
161164
}
162165
}
163166

164167
// send memory response
165168
if (RspOut.try_send(out_rsp, 1)) {
166169
DT(4, this->name() << "-rsp" << i << ": " << rsp_in);
167-
// remove input
168-
RspIn.at(i).pop();
170+
// Pop all merged inputs only after successful send.
171+
for (auto idx : pop_list) {
172+
RspIn.at(idx).pop();
173+
}
169174
}
170175

171176
break;
@@ -204,4 +209,4 @@ void LsuMemAdapter::tick() {
204209
ReqIn.pop();
205210
}
206211
}
207-
}
212+
}

0 commit comments

Comments
 (0)