Add event notification support and rdci timestamps

Also:
* print header line every 50 line on output
* print events that are being listened for with header
* cpplint clean-up

Change-Id: Ic049eb79156a9528b556e56f0fa43e1344f898cc
This commit is contained in:
Chris Freehill
2020-11-11 14:41:27 -06:00
parent 105675aeeb
commit b278cd379b
32 changed files with 766 additions and 109 deletions
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_RDCMODULEMGR_H_
#define RDC_LIB_RDCMODULEMGR_H_
#ifndef INCLUDE_RDC_LIB_RDCMODULEMGR_H_
#define INCLUDE_RDC_LIB_RDCMODULEMGR_H_
#include <memory>
#include "rdc_lib/rdc_common.h"
@@ -41,4 +41,4 @@ typedef std::shared_ptr<RdcModuleMgr> RdcModuleMgrPtr;
} // namespace amd
#endif // RDC_LIB_RDCMODULEMGR_H_
#endif // INCLUDE_RDC_LIB_RDCMODULEMGR_H_
+62
View File
@@ -0,0 +1,62 @@
/*
Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef INCLUDE_RDC_LIB_RDCNOTIFICATION_H_
#define INCLUDE_RDC_LIB_RDCNOTIFICATION_H_
#include <memory>
#include <vector>
#include "rdc_lib/rdc_common.h"
#include "rdc/rdc.h"
namespace amd {
namespace rdc {
extern const uint32_t kMaxRSMIEvents;
typedef struct {
uint32_t gpu_id;
rdc_field_value field;
} rdc_evnt_notification_t;
class RdcNotification {
public:
virtual bool is_notification_event(rdc_field_t field) const = 0;
virtual rdc_status_t
set_listen_events(const std::vector<RdcFieldKey> fk_arr) = 0;
// Blocking
virtual rdc_status_t
listen(rdc_evnt_notification_t *events, uint32_t *num_events,
uint32_t timeout_ms) = 0;
virtual rdc_status_t stop_listening(uint32_t gpu_id) = 0;
virtual ~RdcNotification() {}
};
typedef std::shared_ptr<RdcNotification> RdcNotificationPtr;
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_RDCNOTIFICATION_H_
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_RDCTELEMETRY_H_
#define RDC_LIB_RDCTELEMETRY_H_
#ifndef INCLUDE_RDC_LIB_RDCTELEMETRY_H_
#define INCLUDE_RDC_LIB_RDCTELEMETRY_H_
#include <memory>
#include "rdc/rdc.h"
@@ -54,4 +54,4 @@ typedef std::shared_ptr<RdcTelemetry> RdcTelemetryPtr;
} // namespace amd
#endif // RDC_LIB_RDCTELEMETRY_H_
#endif // INCLUDE_RDC_LIB_RDCTELEMETRY_H_
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
#define RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
#ifndef INCLUDE_RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
#define INCLUDE_RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
// The telemetry interface for libraries, for example, RAS.
#include <rdc/rdc.h>
@@ -65,4 +65,4 @@ rdc_status_t rdc_module_destroy();
}
#endif // RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
#endif // INCLUDE_RDC_LIB_RDCTELEMETRYLIBINTERFACE_H_
+1
View File
@@ -34,6 +34,7 @@ namespace rdc {
class RdcWatchTable {
public:
virtual rdc_status_t rdc_field_update_all() = 0;
virtual rdc_status_t rdc_field_listen_notif(uint32_t timeout_ms) = 0;
virtual rdc_status_t rdc_job_start_stats(rdc_gpu_group_t group_id,
const char job_id[64], uint64_t update_freq,
+5 -1
View File
@@ -35,9 +35,13 @@ THE SOFTWARE.
namespace amd {
namespace rdc {
// Note, the .cc code relies on RdcCacheEntry only having plain-old-data
// types and arrays (no pointers). If a pointer is added, make sure to update
// any code that copies this structure.
struct RdcCacheEntry {
uint64_t last_time;
int64_t value;
rdc_field_type_t type;
rdc_field_value_data value;
};
typedef std::map<RdcFieldKey, std::vector<RdcCacheEntry>> RdcCacheSamples;
+2 -1
View File
@@ -30,6 +30,7 @@ THE SOFTWARE.
#include "rdc_lib/RdcMetricsUpdater.h"
#include "rdc_lib/RdcWatchTable.h"
#include "rdc_lib/RdcModuleMgr.h"
#include "rdc_lib/RdcNotification.h"
namespace amd {
namespace rdc {
@@ -85,7 +86,6 @@ class RdcEmbeddedHandler: public RdcHandler {
uint64_t *next_since_time_stamp, rdc_field_value* value) override;
rdc_status_t rdc_field_unwatch(rdc_gpu_group_t group_id,
rdc_field_grp_t field_group_id) override;
// Control API
rdc_status_t rdc_field_update_all(uint32_t wait_for_update) override;
@@ -98,6 +98,7 @@ class RdcEmbeddedHandler: public RdcHandler {
RdcCacheManagerPtr cache_mgr_;
RdcMetricFetcherPtr metric_fetcher_;
RdcModuleMgrPtr rdc_module_mgr_;
RdcNotificationPtr rdc_notif_;
RdcWatchTablePtr watch_table_;
RdcMetricsUpdaterPtr metrics_updater_;
std::future<void> updater_;
@@ -40,6 +40,7 @@ class RdcMetricsUpdaterImpl: public RdcMetricsUpdater {
RdcWatchTablePtr watch_table_;
std::atomic<bool> started_;
std::future<void> updater_; // keep the future of updater
std::future<void> notif_updater_; // keep the future of notif updater
const uint32_t _check_frequency; // Check frequency in milliseconds
};
+3 -4
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
#define RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
#ifndef INCLUDE_RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
#define INCLUDE_RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
#include <memory>
#include "rdc_lib/RdcModuleMgr.h"
@@ -43,11 +43,10 @@ class RdcModuleMgrImpl: public RdcModuleMgr {
RdcRasLibPtr ras_lib_;
RdcMetricFetcherPtr fetcher_;
};
} // namespace rdc
} // namespace amd
#endif // RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
#endif // INCLUDE_RDC_LIB_IMPL_RDCMODULEMGRIMPL_H_
@@ -0,0 +1,61 @@
/*
Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef INCLUDE_RDC_LIB_IMPL_RDCNOTIFICATIONIMPL_H_
#define INCLUDE_RDC_LIB_IMPL_RDCNOTIFICATIONIMPL_H_
#include <memory>
#include <vector>
#include <map>
#include <mutex>
#include "rdc_lib/rdc_common.h"
#include "rdc_lib/RdcNotification.h"
#include "rdc/rdc.h"
namespace amd {
namespace rdc {
class RdcNotificationImpl : public RdcNotification {
public:
RdcNotificationImpl();
~RdcNotificationImpl();
bool is_notification_event(rdc_field_t field) const override;
rdc_status_t set_listen_events(
const std::vector<RdcFieldKey> fk_arr) override;
// Blocking
rdc_status_t listen(rdc_evnt_notification_t *events,
uint32_t *num_events, uint32_t timeout_ms) override;
rdc_status_t stop_listening(uint32_t gpu_id) override;
private:
std::map<uint32_t, uint64_t> gpu_evnt_notif_masks_;
std::mutex notif_mutex_;
};
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_IMPL_RDCNOTIFICATIONIMPL_H_
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_IMPL_RDCRASLIB_H_
#define RDC_LIB_IMPL_RDCRASLIB_H_
#ifndef INCLUDE_RDC_LIB_IMPL_RDCRASLIB_H_
#define INCLUDE_RDC_LIB_IMPL_RDCRASLIB_H_
#include <map>
#include <list>
@@ -74,4 +74,4 @@ typedef std::shared_ptr<RdcRasLib> RdcRasLibPtr;
} // namespace amd
#endif // RDC_LIB_IMPL_RDCRASLIB_H_
#endif // INCLUDE_RDC_LIB_IMPL_RDCRASLIB_H_
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_IMPL_RDCSMILIB_H_
#define RDC_LIB_IMPL_RDCSMILIB_H_
#ifndef INCLUDE_RDC_LIB_IMPL_RDCSMILIB_H_
#define INCLUDE_RDC_LIB_IMPL_RDCSMILIB_H_
#include <vector>
#include <memory>
@@ -55,4 +55,4 @@ class RdcSmiLib : public RdcTelemetry {
} // namespace rdc
} // namespace amd
#endif // RDC_LIB_IMPL_RDCSMILIB_H_
#endif // INCLUDE_RDC_LIB_IMPL_RDCSMILIB_H_
+3 -3
View File
@@ -19,8 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
#define RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
#ifndef INCLUDE_RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
#define INCLUDE_RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
#include <map>
#include <list>
@@ -69,4 +69,4 @@ typedef std::shared_ptr<RdcTelemetryModule> RdcTelemetryModulePtr;
} // namespace amd
#endif // RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
#endif // INCLUDE_RDC_LIB_IMPL_RDCTELEMETRYMODULE_H_
+7 -3
View File
@@ -34,6 +34,7 @@ THE SOFTWARE.
#include "rdc_lib/RdcCacheManager.h"
#include "rdc_lib/RdcMetricFetcher.h"
#include "rdc_lib/RdcModuleMgr.h"
#include "rdc_lib/RdcNotification.h"
#include "rocm_smi/rocm_smi.h"
namespace amd {
@@ -82,10 +83,12 @@ class RdcWatchTableImpl : public RdcWatchTable {
//!< is expensive. Internally, this function will throttle the cleanup to
//!< once per second.
rdc_status_t rdc_field_update_all() override;
rdc_status_t rdc_field_listen_notif(uint32_t timeout_ms) override;
RdcWatchTableImpl(const RdcGroupSettingsPtr& group_settings,
const RdcCacheManagerPtr& cache_mgr,
const RdcModuleMgrPtr& module_mgr);
const RdcModuleMgrPtr& module_mgr,
const RdcNotificationPtr& notif);
private:
//!< Helper function to Update the fields_in_table when unwatch tables
@@ -106,8 +109,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);
rdc_status_t rdc_notif_update_cache(rdc_evnt_notification_t *events,
uint32_t num_events);
//!< The function will be pass as the callback for bulk fetch
static rdc_status_t handle_fields(rdc_gpu_field_value_t* values,
uint32_t num_values, void* user_data);
@@ -115,6 +118,7 @@ class RdcWatchTableImpl : public RdcWatchTable {
RdcGroupSettingsPtr group_settings_;
RdcCacheManagerPtr cache_mgr_;
RdcModuleMgrPtr rdc_module_mgr_;
RdcNotificationPtr notifications_;
//!< The watch table to store the watch settings.
std::map<RdcFieldGroupKey, FieldSettings> watch_table_;
+37
View File
@@ -0,0 +1,37 @@
/*
Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef INCLUDE_RDC_LIB_IMPL_RSMIUTILS_H_
#define INCLUDE_RDC_LIB_IMPL_RSMIUTILS_H_
#include "rocm_smi/rocm_smi.h"
namespace amd {
namespace rdc {
rdc_status_t Rsmi2RdcError(rsmi_status_t rsmi);
} // namespace rdc
} // namespace amd
#endif // INCLUDE_RDC_LIB_IMPL_RSMIUTILS_H_