Skip to content

Commit

Permalink
Fix bug in runlist implementation (#8153)
Browse files Browse the repository at this point in the history
Update state check.

Getting the underlying exec bos require that the runlist is in
closed state as opposed to running.

Signed-off-by: Soren Soe <[email protected]>
  • Loading branch information
stsoe authored May 9, 2024
1 parent 17cd1ef commit 7ae1da5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2920,16 +2920,27 @@ class runlist_impl
std::vector<xrt::run> m_runlist;
std::vector<xrt_core::buffer_handle*> m_bos;

static const std::string&
state_to_string(state st)
{
static std::map<state, std::string> st2str{
{ state::idle, "idle" },
{ state::closed, "closed" },
{ state::running,"running" },
{ state::error, "error" }
};
return st2str.at(st);
}

public:
// Internal accessor during command list submission
const std::vector<xrt_core::buffer_handle*>&
get_exec_bos() const
{
// Allow exec bo access only as part of submission
// The command list must have been submitted for
// execut
if (m_state != state::running)
throw std::runtime_error("internal error: wrong state");
// The runlist must have been closed.
if (m_state != state::closed)
throw std::runtime_error("internal error: wrong state: " + state_to_string(m_state));

return m_bos;
}
Expand Down Expand Up @@ -2963,7 +2974,7 @@ class runlist_impl
add(xrt::run run)
{
if (m_state != state::idle)
throw xrt_core::error("runlist must be idle before adding run objects");
throw xrt_core::error("runlist must be idle before adding run objects, current state: " + state_to_string(m_state));


// Get the potentially throwing action out of the way first
Expand Down Expand Up @@ -2991,7 +3002,7 @@ class runlist_impl
execute(const xrt::runlist& rl)
{
if (m_state != state::idle)
throw xrt_core::error("runlist must be idle before submitting for execution");
throw xrt_core::error("runlist must be idle before submitting for execution, current state: " + state_to_string(m_state));

if (m_runlist.empty())
return;
Expand Down

0 comments on commit 7ae1da5

Please sign in to comment.