Skip to content

Commit 5be7ae3

Browse files
Split send/receive queues
1 parent e6a753b commit 5be7ae3

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/zm_mx_accl.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ bool MxAccl::in_callback_func(vector<const MX::Types::FeatureMap *> dst, int cha
264264
}
265265
if (!send_queue.size()) return false;
266266
job = send_queue.front();
267+
send_queue.pop_front();
267268
}
268269

269270
SystemTimePoint starttime = std::chrono::system_clock::now();
@@ -280,6 +281,10 @@ bool MxAccl::in_callback_func(vector<const MX::Types::FeatureMap *> dst, int cha
280281
} else {
281282
Debug(1, "in_callback took: %.3f seconds", FPSeconds(endtime - starttime).count());
282283
}
284+
{
285+
std::lock_guard<std::mutex> lck(mutex_);
286+
receive_queue.push_back(job);
287+
}
283288
condition_.notify_one();
284289
return true;
285290
}
@@ -290,12 +295,13 @@ bool MxAccl::out_callback_func(vector<const MX::Types::FeatureMap *> src, int ch
290295
Job *job;
291296
{
292297
std::unique_lock<std::mutex> lck(mutex_);
293-
while (!send_queue.size() and !zm_terminate) {
294-
Debug(1, "MxAccl waiting, queue size %zu", send_queue.size());
298+
while (!receive_queue.size() and !zm_terminate) {
299+
Debug(1, "MxAccl waiting, queue size %zu", receive_queue.size());
295300
condition_.wait(lck);
296301
}
297-
if (!send_queue.size()) return false;
298-
job = send_queue.front();
302+
if (!receive_queue.size()) return false;
303+
job = receive_queue.front();
304+
receive_queue.pop_front();
299305
}
300306

301307
// Retrieve output data from accelerator

src/zm_mx_accl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class MxAccl {
110110
};
111111
std::list<Job *> jobs;
112112
std::list<Job *> send_queue;
113+
std::list<Job *> receive_queue;
113114

114115
explicit MxAccl();
115116
~MxAccl();

0 commit comments

Comments
 (0)