Add rocprofiler plugin
Rename ROCR -> Runtime and ROCP -> Profiler Change-Id: If90953da8fa5d695b681813dad4a3e7ec26a9c7e Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
This commit is contained in:
@@ -247,6 +247,12 @@ typedef enum {
|
||||
RDC_FI_XGMI_6_WRITE_KB, //!< XGMI_6 accumulated data write size (KB)
|
||||
RDC_FI_XGMI_7_WRITE_KB, //!< XGMI_7 accumulated data write size (KB)
|
||||
|
||||
/**
|
||||
* @brief ROC-profiler related fields
|
||||
*/
|
||||
RDC_FI_PROF_GPU_UTIL = 800, //!<
|
||||
RDC_FI_PROF_TA_BUSY_AVR, //!<
|
||||
|
||||
/*
|
||||
* @brief Raw XGMI counter events
|
||||
*/
|
||||
|
||||
@@ -36,7 +36,7 @@ THE SOFTWARE.
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcEmbeddedHandler : public RdcHandler {
|
||||
class RdcEmbeddedHandler final : public RdcHandler {
|
||||
public:
|
||||
// Job API
|
||||
rdc_status_t rdc_job_start_stats(rdc_gpu_group_t groupId, const char job_id[64],
|
||||
@@ -91,7 +91,7 @@ class RdcEmbeddedHandler : public RdcHandler {
|
||||
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
|
||||
|
||||
explicit RdcEmbeddedHandler(rdc_operation_mode_t op_mode);
|
||||
~RdcEmbeddedHandler();
|
||||
~RdcEmbeddedHandler() final;
|
||||
|
||||
private:
|
||||
rdc_status_t get_gpu_gauges(rdc_gpu_gauges_t* gpu_gauges);
|
||||
|
||||
@@ -67,7 +67,7 @@ struct MetricTask {
|
||||
std::function<void(RdcMetricFetcherImpl&, RdcFieldKey)> task;
|
||||
};
|
||||
|
||||
class RdcMetricFetcherImpl : public RdcMetricFetcher {
|
||||
class RdcMetricFetcherImpl final : public RdcMetricFetcher {
|
||||
public:
|
||||
rdc_status_t fetch_smi_field(uint32_t gpu_index, rdc_field_t field_id,
|
||||
rdc_field_value* value) override;
|
||||
@@ -75,7 +75,7 @@ class RdcMetricFetcherImpl : public RdcMetricFetcher {
|
||||
rdc_gpu_field_t* fields, uint32_t fields_count,
|
||||
std::vector<rdc_gpu_field_value_t>& results) override; // NOLINT
|
||||
RdcMetricFetcherImpl();
|
||||
~RdcMetricFetcherImpl();
|
||||
~RdcMetricFetcherImpl() final;
|
||||
|
||||
rdc_status_t acquire_smi_handle(RdcFieldKey fk) override;
|
||||
rdc_status_t delete_smi_handle(RdcFieldKey fk) override;
|
||||
|
||||
@@ -31,12 +31,13 @@ THE SOFTWARE.
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
|
||||
class RdcMetricsUpdaterImpl : public RdcMetricsUpdater {
|
||||
class RdcMetricsUpdaterImpl final : public RdcMetricsUpdater {
|
||||
public:
|
||||
void start() override;
|
||||
void stop() override;
|
||||
explicit RdcMetricsUpdaterImpl(const RdcWatchTablePtr& watch_table,
|
||||
const uint32_t check_frequency);
|
||||
~RdcMetricsUpdaterImpl() = default;
|
||||
|
||||
private:
|
||||
RdcWatchTablePtr watch_table_;
|
||||
|
||||
@@ -39,43 +39,32 @@ class RdcRocpLib : public RdcTelemetry {
|
||||
// get support field ids
|
||||
rdc_status_t rdc_telemetry_fields_query(uint32_t field_ids[MAX_NUM_FIELDS],
|
||||
uint32_t* field_count) override;
|
||||
|
||||
// Fetch
|
||||
rdc_status_t rdc_telemetry_fields_value_get(rdc_gpu_field_t* fields, uint32_t fields_count,
|
||||
rdc_field_value_f callback, void* user_data) override;
|
||||
|
||||
rdc_status_t rdc_telemetry_fields_watch(rdc_gpu_field_t* fields, uint32_t fields_count) override;
|
||||
|
||||
rdc_status_t rdc_telemetry_fields_unwatch(rdc_gpu_field_t* fields,
|
||||
uint32_t fields_count) override;
|
||||
|
||||
RdcRocpLib();
|
||||
|
||||
~RdcRocpLib();
|
||||
|
||||
private:
|
||||
RdcLibraryLoader lib_loader_;
|
||||
|
||||
rdc_status_t (*telemetry_fields_query_)(uint32_t field_ids[MAX_NUM_FIELDS],
|
||||
uint32_t* field_count);
|
||||
|
||||
rdc_status_t (*telemetry_fields_value_get_)(rdc_gpu_field_t* fields, uint32_t fields_count,
|
||||
rdc_field_value_f callback, void* user_data);
|
||||
|
||||
rdc_status_t (*telemetry_fields_watch_)(rdc_gpu_field_t* fields, uint32_t fields_count);
|
||||
|
||||
rdc_status_t (*telemetry_fields_unwatch_)(rdc_gpu_field_t* fields, uint32_t fields_count);
|
||||
|
||||
/**
|
||||
* @brief Extract current ROCM_PATH from library or the environment
|
||||
*/
|
||||
std::string get_rocm_path();
|
||||
|
||||
/**
|
||||
* @brief Set ROCMTOOLS_METRICS_PATH environment variable needed by
|
||||
* librocmtools
|
||||
* librocprofiler
|
||||
*/
|
||||
rdc_status_t set_rocmtools_path();
|
||||
rdc_status_t set_rocprofiler_path();
|
||||
};
|
||||
|
||||
using RdcRocpLibPtr = std::shared_ptr<RdcRocpLib>;
|
||||
|
||||
@@ -22,15 +22,17 @@ THE SOFTWARE.
|
||||
|
||||
#ifndef RDC_MODULES_RDC_ROCP_RDCROCPBASE_H_
|
||||
#define RDC_MODULES_RDC_ROCP_RDCROCPBASE_H_
|
||||
#include <rocmtools.h>
|
||||
#include <rocprofiler/rocprofiler.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "rdc/rdc.h"
|
||||
|
||||
@@ -43,33 +45,21 @@ namespace rdc {
|
||||
* See metrics.xml in rocmtools for more info.
|
||||
* RDC_CALC fields are calculated over time by RDC.
|
||||
*/
|
||||
static const std::unordered_map<rdc_field_t, const char*> counter_map_k = {
|
||||
{RDC_FI_PROF_ELAPSED_CYCLES, "GRBM_COUNT"},
|
||||
{RDC_FI_PROF_ACTIVE_WAVES, "SQ_WAVES"},
|
||||
{RDC_FI_PROF_ACTIVE_CYCLES, "SQ_BUSY_CU_CYCLES"},
|
||||
{RDC_FI_PROF_CU_OCCUPANCY, "CU_OCCUPANCY"},
|
||||
{RDC_FI_PROF_CU_UTILIZATION, "CU_UTILIZATION"},
|
||||
{RDC_FI_PROF_FETCH_SIZE, "FETCH_SIZE"},
|
||||
{RDC_FI_PROF_WRITE_SIZE, "WRITE_SIZE"},
|
||||
{RDC_FI_PROF_FLOPS_16, "TOTAL_16_OPS"},
|
||||
{RDC_FI_PROF_FLOPS_32, "TOTAL_32_OPS"},
|
||||
{RDC_FI_PROF_FLOPS_64, "TOTAL_64_OPS"},
|
||||
// fields below require special handling
|
||||
{RDC_FI_PROF_GFLOPS_16, "TOTAL_16_OPS"},
|
||||
{RDC_FI_PROF_GFLOPS_32, "TOTAL_32_OPS"},
|
||||
{RDC_FI_PROF_GFLOPS_64, "TOTAL_64_OPS"},
|
||||
{RDC_FI_PROF_MEMR_BW_KBPNS, "FETCH_SIZE"},
|
||||
{RDC_FI_PROF_MEMW_BW_KBPNS, "WRITE_SIZE"},
|
||||
static const std::map<rdc_field_t, const char*> counter_map_k = {
|
||||
{RDC_FI_PROF_GPU_UTIL, "GPU_UTIL"},
|
||||
{RDC_FI_PROF_TA_BUSY_AVR, "TA_BUSY_avr"},
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
hsa_agent_t* agents;
|
||||
unsigned count;
|
||||
unsigned capacity;
|
||||
} hsa_agent_arr_t;
|
||||
|
||||
/// Common interface for RocP tests and samples
|
||||
class RdcRocpBase {
|
||||
static const int dev_count = 1;
|
||||
typedef std::pair<uint32_t, rdc_field_t> pair_gpu_field_t;
|
||||
typedef struct session_info_t {
|
||||
rocmtools_session_id_t id{};
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> start_time;
|
||||
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> stop_time;
|
||||
} session_info_t;
|
||||
|
||||
public:
|
||||
RdcRocpBase();
|
||||
@@ -90,43 +80,21 @@ class RdcRocpBase {
|
||||
*/
|
||||
rdc_status_t rocp_lookup(pair_gpu_field_t gpu_field, double* value);
|
||||
|
||||
/**
|
||||
* @brief Destroy ROCmTools session responsible for monitoring a given
|
||||
* field
|
||||
*
|
||||
* @details While rocmtools supports multiple fields per ID - it has a
|
||||
* limit to how many counters it can query internally.
|
||||
* To avoid concerning ourselves with said limit, we limit each session to
|
||||
* 1 field.
|
||||
* In the future this can be optimized to allow for multiple fields per
|
||||
* session.
|
||||
*
|
||||
* @param[in] field A field to start monitoring
|
||||
*
|
||||
* @retval ::ROCMTOOLS_STATUS_SUCCESS The function has been executed
|
||||
* successfully.
|
||||
*/
|
||||
rdc_status_t create_session(pair_gpu_field_t gpu_field);
|
||||
|
||||
/**
|
||||
* @brief Destroy ROCmTools session responsible for monitoring a given
|
||||
* field
|
||||
*
|
||||
* @param[in] field A field to stop monitoring
|
||||
*
|
||||
* @retval ::ROCMTOOLS_STATUS_SUCCESS The function has been executed
|
||||
* successfully.
|
||||
*/
|
||||
rdc_status_t destroy_session(pair_gpu_field_t gpu_field);
|
||||
|
||||
protected:
|
||||
private:
|
||||
std::map<pair_gpu_field_t, session_info_t> sessions;
|
||||
rocprofiler_t* contexts[dev_count] = {nullptr};
|
||||
static const int features_count = 1;
|
||||
std::map<const char*, double> metrics;
|
||||
rocprofiler_feature_t features[dev_count][features_count];
|
||||
void read_features(rocprofiler_t* context, const unsigned feature_count);
|
||||
int run_profiler(const char* feature_name, hsa_queue_t** queues);
|
||||
hsa_queue_t* queues[dev_count] = {nullptr};
|
||||
hsa_agent_arr_t agent_arr;
|
||||
|
||||
/**
|
||||
* @brief Convert from rocmtools status into RDC status
|
||||
*/
|
||||
rdc_status_t Rocp2RdcError(rocmtools_status_t rocm_status);
|
||||
rdc_status_t Rocp2RdcError(hsa_status_t rocm_status);
|
||||
};
|
||||
|
||||
} // namespace rdc
|
||||
|
||||
Reference in New Issue
Block a user