Add kernel profiling time info to counter collection records (#1000)

* Add kernel profiling time info to counter collection records

- lib/rocprofiler-sdk/kernel_dispatch
  - added profiling_time.{hpp,cpp}
  - restructured tracing.cpp
- updated queue.cpp AsyncSignalHandler
  - gets kernel dispatch profiling time and passes to dispatch_complete and signal callbacks
- structured some header includes to reduce cyclic include probability
  - originally, including kernel_dispatch/tracing.hpp in hsa/queue.hpp created a lot of cyclic includes

* Fix kernel_dispatch.cpp includes

* Fix kernel_dispatch.cpp

- include <cstring>
- replace use of ROCPROFILER_HSA_AMD_EXT_API_ID_NONE with ROCPROFILER_KERNEL_DISPATCH_LAST
This commit is contained in:
Jonathan R. Madsen
2024-08-19 20:05:04 -05:00
committad av GitHub
förälder fa1b9e67ab
incheckning b15e498945
27 ändrade filer med 395 tillägg och 182 borttagningar
+5 -12
Visa fil
@@ -28,6 +28,7 @@
#include "lib/rocprofiler-sdk/hsa/details/fmt.hpp"
#include "lib/rocprofiler-sdk/hsa/hsa.hpp"
#include "lib/rocprofiler-sdk/hsa/queue_controller.hpp"
#include "lib/rocprofiler-sdk/kernel_dispatch/profiling_time.hpp"
#include "lib/rocprofiler-sdk/kernel_dispatch/tracing.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/hsa_adapter.hpp"
#include "lib/rocprofiler-sdk/pc_sampling/service.hpp"
@@ -60,16 +61,6 @@ static_assert(offsetof(hsa_ext_amd_aql_pm4_packet_t, completion_signal) ==
offsetof(hsa_barrier_or_packet_t, completion_signal),
"unexpected ABI incompatibility");
#define ROCP_HSA_TABLE_CALL(SEVERITY, EXPR) \
auto ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) = (EXPR); \
ROCP_##SEVERITY##_IF(ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) != \
HSA_STATUS_SUCCESS) \
<< #EXPR << " returned non-zero status code " \
<< ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__) << " :: " \
<< ::rocprofiler::hsa::get_hsa_status_string( \
ROCPROFILER_VARIABLE(rocp_hsa_table_call_, __LINE__)) \
<< ". "
namespace rocprofiler
{
namespace hsa
@@ -116,8 +107,9 @@ AsyncSignalHandler(hsa_signal_value_t /*signal_v*/, void* data)
}
auto& queue_info_session = *static_cast<Queue::queue_info_session_t*>(data);
auto dispatch_time = kernel_dispatch::get_dispatch_time(queue_info_session);
kernel_dispatch::dispatch_complete(queue_info_session);
kernel_dispatch::dispatch_complete(queue_info_session, dispatch_time);
// Calls our internal callbacks to callers who need to be notified post
// kernel execution.
@@ -127,7 +119,8 @@ AsyncSignalHandler(hsa_signal_value_t /*signal_v*/, void* data)
cb_pair.second(queue_info_session.queue,
queue_info_session.kernel_pkt,
queue_info_session,
queue_info_session.inst_pkt);
queue_info_session.inst_pkt,
dispatch_time);
}
});