Comment corrections, debug output and assert added

Dieser Commit ist enthalten in:
Chris Freehill
2018-10-22 17:26:38 -05:00
Ursprung e046fbdddf
Commit b2f1ee1764
12 geänderte Dateien mit 147 neuen und 40 gelöschten Zeilen
+21 -23
Datei anzeigen
@@ -192,13 +192,19 @@ typedef uint64_t rsmi_bit_field;
* currently active.
*/
typedef struct {
//!< Which profiles are supported by this system
/**
* Which profiles are supported by this system
*/
rsmi_bit_field available_profiles;
//!< Which power profile is currently active
/**
* Which power profile is currently active
*/
rsmi_power_profile_preset_masks current;
//!< How many power profiles are available
/**
* How many power profiles are available
*/
uint32_t num_profiles;
} rsmi_power_profile_status;
@@ -448,10 +454,6 @@ rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len);
*
* @details Given a device index @p dv_ind, a 0-based sensor index
*
* @param sensor_ind, a metric @p metric and a pointer to an int64_t
* @p temperature, this function will write the temperature value for that
* metric in millidegrees Celcius to the int64_t pointed to by @p temperature.
*
* @param[in] dv_ind a device index
*
* @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0.
@@ -505,30 +507,26 @@ rsmi_status_t rsmi_dev_fan_rpms_get(uint32_t dv_ind, uint32_t sensor_ind,
int64_t *speed);
/**
* @brief Set the fan speed for the specfied device with the provided speed,
* in RPMs.
* @brief Get the fan speed for the specfied device in RPMs.
*
* @details Given a device index @p dv_ind and a integer value indicating
* speed @p speed, this function will attempt to set the fan speed to @p speed.
* An error will be returned if the specified speed is outside the allowable
* range for the device. The maximum value is RSMI_MAX_FAN_SPEED and the
* minimum is 0.
* @details Given a device index @p dv_ind
* this function will get the fan speed.
*
* @param[in] dv_ind a device index
*
* @details Given a device index @p dv_ind and a pointer to a uint32_t
* @p speed, this function will write the current fan speed (a value
* between 0 and 255) to the uint32_t pointed to by @p speed
* @details Given a device index @p dv_ind and a pointer to a uint32_t
* @p speed, this function will write the current fan speed (a value
* between 0 and 255) to the uint32_t pointed to by @p speed
*
* @param[in] dv_ind a device index
* @param[in] dv_ind a device index
*
* @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0.
* If a device has more than one sensor, it could be greater than 0.
* @param[in] sensor_ind a 0-based sensor index. Normally, this will be 0.
* If a device has more than one sensor, it could be greater than 0.
*
* @param[inout] speed a pointer to uint32_t to which the speed will be
* written
* @param[inout] speed a pointer to uint32_t to which the speed will be
* written
*
* @retval RSMI_STATUS_SUCCESS is returned upon successful call.
* @retval RSMI_STATUS_SUCCESS is returned upon successful call.
*
*/
rsmi_status_t rsmi_dev_fan_speed_get(uint32_t dv_ind,
+63
Datei anzeigen
@@ -0,0 +1,63 @@
/*
* =============================================================================
* ROC Runtime Conformance Release License
* =============================================================================
* The University of Illinois/NCSA
* Open Source License (NCSA)
*
* Copyright (c) 2018, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Developed by:
*
* AMD Research and AMD ROC Software Development
*
* Advanced Micro Devices, Inc.
*
* www.amd.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with 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:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimers.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimers in
* the documentation and/or other materials provided with the distribution.
* - Neither the names of <Name of Development Group, Name of Institution>,
* nor the names of its contributors may be used to endorse or promote
* products derived from this Software without specific prior written
* permission.
*
* 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 CONTRIBUTORS 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 WITH THE SOFTWARE.
*
*/
#ifndef ROCM_SMI_LIB_INCLUDE_ROCM_SMI_ROCM_SMI_COMMON_H_
#define ROCM_SMI_LIB_INCLUDE_ROCM_SMI_ROCM_SMI_COMMON_H_
#define DBG_FILE_ERROR(STR) \
if (env_->debug_output_bitfield & RSMI_DEBUG_SYSFS_FILE_PATHS) { \
std::cout << "*****" << __FUNCTION__ << std::endl; \
std::cout << "*****Opening file: " << (STR) << std::endl; \
std::cout << " at " << __FILE__ << ":" << __LINE__ << std::endl;\
}
// Add different debug filters here, as powers of 2; e.g, 1, 2, 4, 8, ...
#define RSMI_DEBUG_SYSFS_FILE_PATHS 1
struct RocmSMI_env_vars {
// Store env. variables here
uint32_t debug_output_bitfield;
};
#endif // ROCM_SMI_LIB_INCLUDE_ROCM_SMI_ROCM_SMI_COMMON_H_
+3 -1
Datei anzeigen
@@ -52,6 +52,7 @@
#include "rocm_smi/rocm_smi_monitor.h"
#include "rocm_smi/rocm_smi_power_mon.h"
#include "rocm_smi/rocm_smi_common.h"
namespace amd {
namespace smi {
@@ -67,7 +68,7 @@ enum DevInfoTypes {
class Device {
public:
explicit Device(std::string path);
explicit Device(std::string path, RocmSMI_env_vars const *e);
~Device(void);
void set_monitor(std::shared_ptr<Monitor> m) {monitor_ = m;}
@@ -89,6 +90,7 @@ class Device {
std::shared_ptr<PowerMon> power_monitor_;
std::string path_;
uint32_t index_;
const RocmSMI_env_vars *env_;
int readDevInfoStr(DevInfoTypes type, std::string *retStr);
int readDevInfoMultiLineStr(DevInfoTypes type,
std::vector<std::string> *retVec);
+3 -2
Datei anzeigen
@@ -55,6 +55,7 @@
#include "rocm_smi/rocm_smi_device.h"
#include "rocm_smi/rocm_smi_monitor.h"
#include "rocm_smi/rocm_smi_power_mon.h"
#include "rocm_smi/rocm_smi_common.h"
namespace amd {
namespace smi {
@@ -78,17 +79,17 @@ class RocmSMI {
std::function<bool(std::shared_ptr<Device>&, void *)> func, void *);
private:
// temporarily make public RocmSMI(void); // force use getInstance()
std::vector<std::shared_ptr<Device>> devices_;
std::vector<std::shared_ptr<Monitor>> monitors_;
std::vector<std::shared_ptr<PowerMon>> power_mons_;
std::set<std::string> amd_monitor_types_;
void AddToDeviceList(std::string dev_name);
void GetEnvVariables(void);
uint32_t DiscoverAMDMonitors(void);
static std::vector<std::shared_ptr<amd::smi::Device>> s_monitor_devices;
RocmSMI_env_vars env_vars_;
};
} // namespace smi
+4 -1
Datei anzeigen
@@ -48,6 +48,8 @@
#include <string>
#include <cstdint>
#include "rocm_smi/rocm_smi_common.h"
namespace amd {
namespace smi {
@@ -81,7 +83,7 @@ enum MonitorTypes {
class Monitor {
public:
explicit Monitor(std::string path);
explicit Monitor(std::string path, RocmSMI_env_vars const *e);
~Monitor(void);
const std::string path(void) const {return path_;}
int readMonitor(MonitorTypes type, uint32_t sensor_ind, std::string *val);
@@ -89,6 +91,7 @@ class Monitor {
private:
std::string MakeMonitorPath(MonitorTypes type, int32_t sensor_id);
std::string path_;
const RocmSMI_env_vars *env_;
};
} // namespace smi
+5 -2
Datei anzeigen
@@ -48,6 +48,8 @@
#include <string>
#include <cstdint>
#include "rocm_smi/rocm_smi_common.h"
namespace amd {
namespace smi {
@@ -59,7 +61,7 @@ enum PowerMonTypes {
class PowerMon {
public:
explicit PowerMon(std::string path);
explicit PowerMon(std::string path, RocmSMI_env_vars const *e);
~PowerMon(void);
const std::string path(void) const {return path_;}
@@ -68,8 +70,9 @@ class PowerMon {
int readPowerValue(PowerMonTypes type, uint64_t *power);
private:
uint32_t dev_index_;
std::string path_;
const RocmSMI_env_vars *env_;
uint32_t dev_index_;
};
} // namespace smi