From 127488ba91fb5a9ead32cce93a23ec3750fcc90e Mon Sep 17 00:00:00 2001 From: Aurelius84 Date: Wed, 20 Oct 2021 10:19:24 +0800 Subject: [PATCH] Add kQueueSync.synchronize_run_ logic (#36546) --- .../fluid/framework/new_executor/interpretercore.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/new_executor/interpretercore.cc b/paddle/fluid/framework/new_executor/interpretercore.cc index 083d989cb5..f6157367cd 100644 --- a/paddle/fluid/framework/new_executor/interpretercore.cc +++ b/paddle/fluid/framework/new_executor/interpretercore.cc @@ -410,13 +410,14 @@ void InterpreterCore::RunNextInstruction(const Instruction& instr) { [&, next_id] { RunInstructionAsync(next_id); }); } } - - for (size_t i = 0; i < next_instr.direct_run_.size(); ++i) { - auto next_id = next_instr.direct_run_[i]; + auto direct_run_ops = interpretercore::merge_vector( + next_instr.synchronize_run_, next_instr.direct_run_); + size_t first_op = 0; + for (auto next_id : direct_run_ops) { if (IsReady(next_id)) { // only keep one op running in current thread - if (i == 0) { - RunInstructionAsync(next_id); + if (first_op == 0) { + first_op = next_id; continue; } // move rest ops into other threads @@ -425,6 +426,7 @@ void InterpreterCore::RunNextInstruction(const Instruction& instr) { [&, next_id] { RunInstructionAsync(next_id); }); } } + if (first_op != 0) RunInstructionAsync(first_op); } } -- GitLab