Skip to content

Commit 8617d36

Browse files
committed
Fix frame initialization when frame has multiple runs (runlist)
Capture is tracking BOs at individual run level. If application uses an xrt::runlist then each run in the runlist are captured separately but reflected as a frame with multiple runs in the replay json. When a frame is initialized, it should initialize each BO at most once, so double check that identical BOs in a frame refer to same captured data (file). Signed-off-by: Soren Soe <2106410+stsoe@users.noreply.github.com>
1 parent bcf46a8 commit 8617d36

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/runtime_src/core/common/runner/replay.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,20 @@ struct replayer
436436
void
437437
add(std::string bonm, xrt::bo xbo, std::string fnm)
438438
{
439-
// It's an error to emplace the same bo multiple times
440-
if (!m_bo2data.emplace(std::move(bonm), std::make_pair(std::move(xbo), std::move(fnm))).second)
439+
// It's an error to emplace the same bo multiple times, but capture
440+
// is tracking BOs at individual run level. If application used an
441+
// xrt::runlist then each run in the runlist are captured separately
442+
// but reflected as a frame with multiple runs in the replay json.
443+
// When a frame is initialized, it should initialize each BO at
444+
// most once, so here each bo is inserted only once. Still it would
445+
// be an error if multiple runs in a frame initialize the same BO
446+
// with different data, so that is asserted.
447+
auto [itr, inserted] = m_bo2data.try_emplace(std::move(bonm), std::move(xbo), std::move(fnm));
448+
if (inserted)
449+
return;
450+
451+
// try_emplace ensures xbo and fnm remain valid if not inserted
452+
if (fnm != m_bo2data.at(bonm).second)
441453
throw std::runtime_error("Unexpected reinit of buffer");
442454
}
443455
};

0 commit comments

Comments
 (0)