Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
Signed-off-by: rbramand <[email protected]>
  • Loading branch information
rbramand committed Nov 10, 2023
1 parent 9650145 commit 9a87575
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 146 deletions.
4 changes: 2 additions & 2 deletions src/runtime_src/core/common/api/xrt_bo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ class bo_impl
return handle.get();
}

std::shared_ptr<xrt_core::usage_metrics::base_logger>
xrt_core::usage_metrics::base_logger*
get_usage_logger() const
{
return m_usage_logger;
return m_usage_logger.get();
}

// BOs can be cloned internally by XRT to statisfy kernel
Expand Down
2 changes: 1 addition & 1 deletion src/runtime_src/core/common/api/xrt_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ alloc_device_index(unsigned int index)
XRT_TRACE_POINT_SCOPE(xrt_device_alloc_index);
auto dev = xrt_core::get_userpf_device(index);

dev->get_usage_logger()->log_device_info(dev);
dev->get_usage_logger()->log_device_info(dev.get());

return dev;
}
Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/common/api/xrt_hw_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ class hw_context_impl : public std::enable_shared_from_this<hw_context_impl>
return m_hdl.get();
}

std::shared_ptr<xrt_core::usage_metrics::base_logger>
xrt_core::usage_metrics::base_logger*
get_usage_logger()
{
return m_usage_logger;
return m_usage_logger.get();
}
};

Expand Down
9 changes: 5 additions & 4 deletions src/runtime_src/core/common/api/xrt_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,7 @@ class kernel_impl : public std::enable_shared_from_this<kernel_impl>
// amend args with computed data based on kernel protocol
amend_args();

m_usage_logger->log_kernel_info(device->core_device, hwctx, name, args.size());
m_usage_logger->log_kernel_info(device->core_device.get(), hwctx, name, args.size());
}

// Delegating constructor with no module
Expand Down Expand Up @@ -2347,7 +2347,8 @@ class run_impl
// This is in critical path, we need to reduce log overhead
// as much as possible, passing kernel impl pointer instead of
// constructing args in place
m_usage_logger->log_kernel_run_info(kernel.get(), this, true, ERT_CMD_STATE_NEW);
// sending state as ERT_CMD_STATE_NEW for kernel start
m_usage_logger->log_kernel_run_info(kernel.get(), this, ERT_CMD_STATE_NEW);
cmd->run();
}

Expand Down Expand Up @@ -2440,7 +2441,7 @@ class run_impl
state = cmd->wait();
}

m_usage_logger->log_kernel_run_info(kernel.get(), this, false, state);
m_usage_logger->log_kernel_run_info(kernel.get(), this, state);

return state;
}
Expand All @@ -2466,7 +2467,7 @@ class run_impl
}

if (state == ERT_CMD_STATE_COMPLETED) {
m_usage_logger->log_kernel_run_info(kernel.get(), this, false, state);
m_usage_logger->log_kernel_run_info(kernel.get(), this, state);
return std::cv_status::no_timeout;
}

Expand Down
4 changes: 2 additions & 2 deletions src/runtime_src/core/common/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ class device : public ishim
/**
* get_usage_logger() - get usage metrics logger
*/
std::shared_ptr<usage_metrics::base_logger>
usage_metrics::base_logger*
get_usage_logger()
{
return m_usage_logger;
return m_usage_logger.get();
}

private:
Expand Down
Loading

0 comments on commit 9a87575

Please sign in to comment.