Add event counter support
Adds support for RSMI event counters. This also includes "macro" or "pseudo" events, in which an event value is obtained from RSMI, followed by some post processing before being displayed in rdci. Aside from the support of new fields, the main update here is to introduce an initialization and "shutdown" call for new fields that will require this. Also, includes some modifications to the rdci dmon list command: * in rdc_field_data.data, added the ability to specify whether a field should be hidden or not, by default. This will allow us to support many fields, even those that are not typically of interest (but sometimes may be), without confusing the user or unnecessary clutter. * added a --list-all option which lists all available field including the more obscure fields. Change-Id: I01dd0edea963c12f82c6e44f893a390711ef3e83
This commit is contained in:
@@ -29,6 +29,7 @@ THE SOFTWARE.
|
||||
#include <queue>
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rdc_lib/rdc_common.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -41,6 +42,21 @@ struct MetricValue {
|
||||
rdc_field_value value;
|
||||
};
|
||||
|
||||
// This union represents any RSMI handles require initialization and/or
|
||||
// shut down. There should only be one instance of this for each raw event
|
||||
// used. For example, if a field group includes a pseudo-event and the
|
||||
// underlying raw event, then only one FieldRSMIData should be created,
|
||||
// and it should be used by both events.
|
||||
struct FieldRSMIData {
|
||||
union {
|
||||
rsmi_event_handle_t evt_handle;
|
||||
};
|
||||
union {
|
||||
rsmi_counter_value_t counter_val;
|
||||
};
|
||||
~FieldRSMIData(){}
|
||||
FieldRSMIData() : evt_handle(0), counter_val{0, 0, 0}{}
|
||||
};
|
||||
|
||||
//!< The data structure to store the async fetch task
|
||||
class RdcMetricFetcherImpl;
|
||||
@@ -55,7 +71,13 @@ class RdcMetricFetcherImpl: public RdcMetricFetcher {
|
||||
rdc_field_t field_id, rdc_field_value* value) override;
|
||||
RdcMetricFetcherImpl();
|
||||
~RdcMetricFetcherImpl();
|
||||
|
||||
rdc_status_t acquire_rsmi_handle(RdcFieldKey fk) override;
|
||||
rdc_status_t delete_rsmi_handle(RdcFieldKey fk) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<FieldRSMIData> get_rsmi_data(RdcFieldKey key);
|
||||
|
||||
uint64_t now();
|
||||
void get_ecc_error(uint32_t gpu_index,
|
||||
rdc_field_t field_id, rdc_field_value* value);
|
||||
@@ -67,6 +89,7 @@ class RdcMetricFetcherImpl: public RdcMetricFetcher {
|
||||
|
||||
//!< Async metric retreive
|
||||
std::map<RdcFieldKey, MetricValue> async_metrics_;
|
||||
std::map<RdcFieldKey, std::shared_ptr<FieldRSMIData>> rsmi_data_;
|
||||
std::queue<MetricTask> updated_tasks_;
|
||||
std::mutex task_mutex_;
|
||||
std::future<void> updater_; // keep the future of updater
|
||||
@@ -74,6 +97,8 @@ class RdcMetricFetcherImpl: public RdcMetricFetcher {
|
||||
std::atomic<bool> task_started_;
|
||||
};
|
||||
|
||||
rdc_status_t Rsmi2RdcError(rsmi_status_t rsmi);
|
||||
|
||||
} // namespace rdc
|
||||
} // namespace amd
|
||||
|
||||
|
||||
@@ -29,10 +29,12 @@ THE SOFTWARE.
|
||||
#include <memory>
|
||||
#include <mutex> // NOLINT
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include "rdc_lib/RdcWatchTable.h"
|
||||
#include "rdc_lib/RdcGroupSettings.h"
|
||||
#include "rdc_lib/RdcCacheManager.h"
|
||||
#include "rdc_lib/RdcMetricFetcher.h"
|
||||
#include "rocm_smi/rocm_smi.h"
|
||||
|
||||
namespace amd {
|
||||
namespace rdc {
|
||||
@@ -51,6 +53,7 @@ struct JobWatchTableEntry {
|
||||
std::vector<RdcFieldKey> fields; //< store fields for faster query
|
||||
};
|
||||
|
||||
|
||||
class RdcWatchTableImpl : public RdcWatchTable {
|
||||
public:
|
||||
rdc_status_t rdc_job_start_stats(rdc_gpu_group_t group_id,
|
||||
@@ -103,6 +106,8 @@ class RdcWatchTableImpl : public RdcWatchTable {
|
||||
bool is_job_watch_field(uint32_t gpu_index, rdc_field_t field_id,
|
||||
std::string& job_id) const; // NOLINT
|
||||
|
||||
rdc_status_t initialize_rsmi_handles(RdcFieldKey fk);
|
||||
|
||||
RdcGroupSettingsPtr group_settings_;
|
||||
RdcCacheManagerPtr cache_mgr_;
|
||||
RdcMetricFetcherPtr metric_fetcher_;
|
||||
@@ -122,7 +127,6 @@ class RdcWatchTableImpl : public RdcWatchTable {
|
||||
|
||||
//!< The last clean up time
|
||||
std::atomic<uint64_t> last_cleanup_time_;
|
||||
|
||||
std::mutex watch_mutex_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user