diff --git a/projects/amdsmi/docs/ROCm_SMI_Manual.pdf b/projects/amdsmi/docs/ROCm_SMI_Manual.pdf index b809f8b20e..954af57023 100644 Binary files a/projects/amdsmi/docs/ROCm_SMI_Manual.pdf and b/projects/amdsmi/docs/ROCm_SMI_Manual.pdf differ diff --git a/projects/amdsmi/example/rocm_smi_example.cc b/projects/amdsmi/example/rocm_smi_example.cc index 5bec1a426d..5e881b5f70 100755 --- a/projects/amdsmi/example/rocm_smi_example.cc +++ b/projects/amdsmi/example/rocm_smi_example.cc @@ -80,7 +80,7 @@ static void print_test_header(const char *str, uint32_t dv_ind) { } static const char * -power_profile_string(rsmi_power_profile_preset_masks profile) { +power_profile_string(rsmi_power_profile_preset_masks_t profile) { switch (profile) { case RSMI_PWR_PROF_PRST_CUSTOM_MASK: return "CUSTOM"; @@ -100,7 +100,7 @@ power_profile_string(rsmi_power_profile_preset_masks profile) { } static const char * -perf_level_string(rsmi_dev_perf_level perf_lvl) { +perf_level_string(rsmi_dev_perf_level_t perf_lvl) { switch (perf_lvl) { case RSMI_DEV_PERF_LEVEL_AUTO: return "AUTO"; @@ -117,7 +117,7 @@ perf_level_string(rsmi_dev_perf_level perf_lvl) { static rsmi_status_t test_power_profile(uint32_t dv_ind) { rsmi_status_t ret; - rsmi_power_profile_status status; + rsmi_power_profile_status_t status; print_test_header("Power Profile", dv_ind); @@ -130,7 +130,7 @@ static rsmi_status_t test_power_profile(uint32_t dv_ind) { while (tmp <= RSMI_PWR_PROF_PRST_LAST) { if ((tmp & status.available_profiles) == tmp) { std::cout << "\t" << - power_profile_string((rsmi_power_profile_preset_masks)tmp) << std::endl; + power_profile_string((rsmi_power_profile_preset_masks_t)tmp) << std::endl; } tmp = tmp << 1; } @@ -138,8 +138,8 @@ static rsmi_status_t test_power_profile(uint32_t dv_ind) { power_profile_string(status.current) << std::endl; // Try setting the profile to a different power profile - rsmi_bit_field diff_profiles; - rsmi_power_profile_preset_masks new_prof; + rsmi_bit_field_t diff_profiles; + rsmi_power_profile_preset_masks_t new_prof; diff_profiles = status.available_profiles & (~status.current); if (diff_profiles & RSMI_PWR_PROF_PRST_COMPUTE_MASK) { @@ -162,7 +162,7 @@ static rsmi_status_t test_power_profile(uint32_t dv_ind) { ret = rsmi_dev_power_profile_set(dv_ind, 0, new_prof); CHK_RSMI_RET(ret) std::cout << "Done." << std::endl; - rsmi_dev_perf_level pfl; + rsmi_dev_perf_level_t pfl; ret = rsmi_dev_perf_level_get(dv_ind, &pfl); CHK_RSMI_RET(ret) std::cout << "Performance Level is now " << @@ -305,7 +305,7 @@ static rsmi_status_t test_set_fan_speed(uint32_t dv_ind) { static rsmi_status_t test_set_perf_level(uint32_t dv_ind) { rsmi_status_t ret; - rsmi_dev_perf_level pfl, orig_pfl; + rsmi_dev_perf_level_t pfl, orig_pfl; print_test_header("Performance Level Control", dv_ind); @@ -314,7 +314,8 @@ static rsmi_status_t test_set_perf_level(uint32_t dv_ind) { std::cout << "\t**Original Perf Level:" << perf_level_string(orig_pfl) << std::endl; - pfl = (rsmi_dev_perf_level)((orig_pfl + 1) % (RSMI_DEV_PERF_LEVEL_LAST + 1)); + pfl = + (rsmi_dev_perf_level_t)((orig_pfl + 1) % (RSMI_DEV_PERF_LEVEL_LAST + 1)); std::cout << "Set Performance Level to " << (uint32_t)pfl << " ..." << std::endl; @@ -334,7 +335,7 @@ static rsmi_status_t test_set_perf_level(uint32_t dv_ind) { static rsmi_status_t test_set_freq(uint32_t dv_ind) { rsmi_status_t ret; - rsmi_frequencies f; + rsmi_frequencies_t f; uint32_t freq_bitmask; rsmi_clk_type rsmi_clk; @@ -379,7 +380,7 @@ static rsmi_status_t test_set_freq(uint32_t dv_ind) { return RSMI_STATUS_SUCCESS; } -static void print_frequencies(rsmi_frequencies *f) { +static void print_frequencies(rsmi_frequencies_t *f) { assert(f != nullptr); for (uint32_t j = 0; j < f->num_supported; ++j) { std::cout << "\t** " << j << ": " << f->frequency[j]; @@ -400,8 +401,8 @@ int main() { uint64_t val_ui64, val2_ui64; int64_t val_i64; uint32_t val_ui32; - rsmi_dev_perf_level pfl; - rsmi_frequencies f; + rsmi_dev_perf_level_t pfl; + rsmi_frequencies_t f; uint32_t num_monitor_devs = 0; rsmi_num_monitor_devices(&num_monitor_devs); diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/include/rocm_smi/rocm_smi.h index 6fc2a41644..7e8cf64e0d 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi.h @@ -135,8 +135,10 @@ typedef enum { RSMI_DEV_PERF_LEVEL_LAST = RSMI_DEV_PERF_LEVEL_STABLE_MIN_SCLK, RSMI_DEV_PERF_LEVEL_UNKNOWN = 0x100 //!< Unknown performance level -} rsmi_dev_perf_level; - +} rsmi_dev_perf_level_t; +/// \cond Ignore in docs. +typedef rsmi_dev_perf_level_t rsmi_dev_perf_level; +/// \endcond /** * @brief Available clock types. */ @@ -146,7 +148,10 @@ typedef enum { RSMI_CLK_TYPE_MEM, //!< Memory clock RSMI_CLK_TYPE_LAST = RSMI_CLK_TYPE_MEM -} rsmi_clk_type; +} rsmi_clk_type_t; +/// \cond Ignore in docs. +typedef rsmi_clk_type_t rsmi_clk_type; +/// \endcond /** * @brief Temperature Metrics. This enum is used to identify various @@ -182,11 +187,14 @@ typedef enum { RSMI_TEMP_HIGHEST, //!< Historical maximum temperature. RSMI_TEMP_LAST = RSMI_TEMP_HIGHEST -} rsmi_temperature_metric; +} rsmi_temperature_metric_t; +/// \cond Ignore in docs. +typedef rsmi_temperature_metric_t rsmi_temperature_metric; +/// \endcond /** * @brief Pre-set Profile Selections. These bitmasks can be AND'd with the - * ::rsmi_power_profile_status.available_profiles returned from + * ::rsmi_power_profile_status_t.available_profiles returned from * ::rsmi_dev_power_profile_presets_get() to determine which power profiles * are supported by the system. */ @@ -204,17 +212,64 @@ typedef enum { //!< Invalid power profile RSMI_PWR_PROF_PRST_INVALID = 0xFFFFFFFFFFFFFFFF -} rsmi_power_profile_preset_masks; +} rsmi_power_profile_preset_masks_t; +/// \cond Ignore in docs. +typedef rsmi_power_profile_preset_masks_t rsmi_power_profile_preset_masks; +/// \endcond + +/** + * @brief This enum is used to identify different GPU blocks. + */ +typedef enum { + RSMI_GPU_BLOCK_FIRST = 0, + + RSMI_GPU_BLOCK_UMC = RSMI_GPU_BLOCK_FIRST, + RSMI_GPU_BLOCK_SDMA, + RSMI_GPU_BLOCK_GFX, + + RSMI_GPU_BLOCK_LAST = RSMI_GPU_BLOCK_GFX +} rsmi_gpu_block_t; +/// \cond Ignore in docs. +typedef rsmi_gpu_block_t rsmi_gpu_block; +/// \endcond + +/** + * @brief Types of memory + */ +typedef enum { + RSMI_MEM_TYPE_FIRST = 0, + + RSMI_MEM_TYPE_VRAM = RSMI_MEM_TYPE_FIRST, //!< VRAM memory + RSMI_MEM_TYPE_VIS_VRAM, //!< VRAM memory that is visible + RSMI_MEM_TYPE_GTT, //!< GTT memory + + RSMI_MEM_TYPE_LAST = RSMI_MEM_TYPE_GTT +} rsmi_memory_type_t; + +/** + * @brief This values of this enum are used as frequency identifiers. + */ +typedef enum { + RSMI_FREQ_IND_MIN = 0, //!< Index used for the minimum frequency value + RSMI_FREQ_IND_MAX = 1, //!< Index used for the maximum frequency value + RSMI_FREQ_IND_INVALID = 0xFFFFFFFF //!< An invalid frequency index +} rsmi_freq_ind_t; +/// \cond Ignore in docs. +typedef rsmi_freq_ind_t rsmi_freq_ind; +/// \endcond /** * @brief Bitfield used in various RSMI calls */ -typedef uint64_t rsmi_bit_field; +typedef uint64_t rsmi_bit_field_t; +/// \cond Ignore in docs. +typedef rsmi_bit_field_t rsmi_bit_field; +/// \endcond /** * @brief Number of possible power profiles that a system could support */ -#define RSMI_MAX_NUM_POWER_PROFILES (sizeof(rsmi_bit_field) * 8) +#define RSMI_MAX_NUM_POWER_PROFILES (sizeof(rsmi_bit_field_t) * 8) /** * @brief This structure contains information about which power profiles are @@ -225,18 +280,21 @@ typedef struct { /** * Which profiles are supported by this system */ - rsmi_bit_field available_profiles; + rsmi_bit_field_t available_profiles; /** * Which power profile is currently active */ - rsmi_power_profile_preset_masks current; + rsmi_power_profile_preset_masks_t current; /** * How many power profiles are available */ uint32_t num_profiles; -} rsmi_power_profile_status; +} rsmi_power_profile_status_t; +/// \cond Ignore in docs. +typedef rsmi_power_profile_status_t rsmi_power_profile_status; +/// \endcond /** * @brief This structure holds information about clock frequencies. @@ -257,7 +315,10 @@ typedef struct { * Only the first num_supported frequencies are valid. */ uint64_t frequency[RSMI_MAX_NUM_FREQUENCIES]; -} rsmi_frequencies; +} rsmi_frequencies_t; +/// \cond Ignore in docs. +typedef rsmi_frequencies_t rsmi_frequencies; +/// \endcond /** * @brief This structure holds information about the possible PCIe @@ -268,14 +329,18 @@ typedef struct { /** * Transfer rates (T/s) that are possible */ - rsmi_frequencies transfer_rate; + rsmi_frequencies_t transfer_rate; /** * List of lanes for corresponding transfer rate. * Only the first num_supported bandwidths are valid. */ uint32_t lanes[RSMI_MAX_NUM_FREQUENCIES]; -} rsmi_pcie_bandwidth; +} rsmi_pcie_bandwidth_t; + +/// \cond Ignore in docs. +typedef rsmi_pcie_bandwidth_t rsmi_pcie_bandwidth; +/// \endcond /** * @brief This structure holds version information. @@ -285,15 +350,20 @@ typedef struct { uint32_t minor; //!< Minor version uint32_t patch; //!< Patch, build or stepping version const char *build; //!< Build string -} rsmi_version; - +} rsmi_version_t; +/// \cond Ignore in docs. +typedef rsmi_version_t rsmi_version; +/// \endcond /** * @brief This structure represents a range (e.g., frequencies or voltages). */ typedef struct { uint64_t lower_bound; //!< Lower bound of range uint64_t upper_bound; //!< Upper bound of range -} rsmi_range; +} rsmi_range_t; +/// \cond Ignore in docs. +typedef rsmi_range_t rsmi_range; +/// \endcond /** * @brief This structure represents a point on the frequency-voltage plane. @@ -301,55 +371,72 @@ typedef struct { typedef struct { uint64_t frequency; //!< Frequency coordinate (in Hz) uint64_t voltage; //!< Voltage coordinate (in mV) -} rsmi_od_vddc_point; +} rsmi_od_vddc_point_t; +/// \cond Ignore in docs. +typedef rsmi_od_vddc_point_t rsmi_od_vddc_point; +/// \endcond /** - * @brief This structure holds 2 ::rsmi_range's, one for frequency and one for + * @brief This structure holds 2 ::rsmi_range_t's, one for frequency and one for * voltage. These 2 ranges indicate the range of possible values for the - * corresponding ::rsmi_od_vddc_point. + * corresponding ::rsmi_od_vddc_point_t. */ typedef struct { - rsmi_range freq_range; //!< The frequency range for this VDDC Curve point - rsmi_range volt_range; //!< The voltage range for this VDDC Curve point -} rsmi_freq_volt_region; + rsmi_range_t freq_range; //!< The frequency range for this VDDC Curve point + rsmi_range_t volt_range; //!< The voltage range for this VDDC Curve point +} rsmi_freq_volt_region_t; +/// \cond Ignore in docs. +typedef rsmi_freq_volt_region_t rsmi_freq_volt_region; +/// \endcond /** - * ::RSMI_NUM_VOLTAGE_CURVE_POINTS number of ::rsmi_od_vddc_point's + * ::RSMI_NUM_VOLTAGE_CURVE_POINTS number of ::rsmi_od_vddc_point_t's */ typedef struct { /** - * Array of ::RSMI_NUM_VOLTAGE_CURVE_POINTS ::rsmi_od_vddc_point's that + * Array of ::RSMI_NUM_VOLTAGE_CURVE_POINTS ::rsmi_od_vddc_point_t's that * make up the voltage frequency curve points. */ - rsmi_od_vddc_point vc_points[RSMI_NUM_VOLTAGE_CURVE_POINTS]; -} rsmi_od_volt_curve; + rsmi_od_vddc_point_t vc_points[RSMI_NUM_VOLTAGE_CURVE_POINTS]; +} rsmi_od_volt_curve_t; +/// \cond Ignore in docs. +typedef rsmi_od_volt_curve_t rsmi_od_volt_curve; +/// \endcond /** * @brief This structure holds the frequency-voltage values for a device. */ typedef struct { - rsmi_range curr_sclk_range; //!< The current SCLK frequency range - rsmi_range curr_mclk_range; //!< The current MCLK frequency range; + rsmi_range_t curr_sclk_range; //!< The current SCLK frequency range + rsmi_range_t curr_mclk_range; //!< The current MCLK frequency range; //!< (upper bound only) - rsmi_range sclk_freq_limits; //!< The range possible of SCLK values - rsmi_range mclk_freq_limits; //!< The range possible of MCLK values + rsmi_range_t sclk_freq_limits; //!< The range possible of SCLK values + rsmi_range_t mclk_freq_limits; //!< The range possible of MCLK values /** * @brief The current voltage curve */ - rsmi_od_volt_curve curve; + rsmi_od_volt_curve_t curve; uint32_t num_regions; //!< The number of voltage curve regions -} rsmi_od_volt_freq_data; +} rsmi_od_volt_freq_data_t; +/// \cond Ignore in docs. +typedef rsmi_od_volt_freq_data_t rsmi_od_volt_freq_data; +/// \endcond /** - * @brief This values of this enum are used as frequency identifiers. + * @brief This structure holds error counts. */ -typedef enum { - RSMI_FREQ_IND_MIN = 0, //!< Index used for the minimum frequency value - RSMI_FREQ_IND_MAX = 1, //!< Index used for the maximum frequency value - RSMI_FREQ_IND_INVALID = 0xFFFFFFFF //!< An invalid frequency index -} rsmi_freq_ind; +typedef struct { + uint64_t correctable_err; //!< Accumulated correctable errors + uint64_t uncorrectable_err; //!< Accumulated uncorrectable errors +} rsmi_error_count_t; +/*****************************************************************************/ +/** @defgroup InitShutAdmin Initialization and Shutdown + * These functions are used for initialization of ROCm SMI and clean up when + * done. + * @{ + */ /** * @brief Initialize ROCm SMI. * @@ -370,6 +457,13 @@ rsmi_status_t rsmi_init(uint64_t init_flags); */ rsmi_status_t rsmi_shut_down(void); +/** @} */ // end of InitShut + +/*****************************************************************************/ +/** @defgroup IDQuer Identifier Queries + * These functions provide identification information. + * @{ + */ /** * @brief Get the number of devices that have monitor information. * @@ -384,71 +478,73 @@ rsmi_status_t rsmi_shut_down(void); */ rsmi_status_t rsmi_num_monitor_devices(uint32_t *num_devices); +/** + * @brief Get the device id associated with the device with provided device + * index. + * + * @details Given a device index @p dv_ind and a pointer to a uint32_t @p id, + * this function will write the device id value to the uint64_t pointed to by + * @p id. This ID is an identification of the type of device, so calling this + * function for different devices will give the same value if they are kind + * of device. Consequently, this function should not be used to distinguish + * one device from another. rsmi_dev_pci_id_get() should be used to get a + * unique identifier. + * + * @param[in] dv_ind a device index + * + * @param[inout] id a pointer to uint64_t to which the device id will be + * written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint64_t *id); + +/** + * @brief Get the name of a gpu device. + * + * @details Given a device index @p dv_ind, a pointer to a caller provided + * char buffer @p name, and a length of this buffer @p len, this function + * will write the name of the device (up to @p len characters) buffer @p name. + * + * @param[in] dv_ind a device index + * + * @param[inout] name a pointer to a caller provided char buffer to which the + * name will be written + * + * @param[in] len the length of the caller provided buffer @p name. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len); + +/** @} */ // end of IDQuer + +/*****************************************************************************/ +/** @defgroup PCIeQuer PCIe Queries + * These functions provide information about PCIe. + * @{ + */ /** * @brief Get the list of possible PCIe bandwidths that are available. * * @details Given a device index @p dv_ind and a pointer to a to an - * ::rsmi_pcie_bandwidth structure @p bandwidth, this function will fill in + * ::rsmi_pcie_bandwidth_t structure @p bandwidth, this function will fill in * @p bandwidth with the possible T/s values and associated number of lanes, * and indication of the current selection. * * @param[in] dv_ind a device index * * @param[inout] bandwidth a pointer to a caller provided - * ::rsmi_pcie_bandwidth structure to which the frequency information will be + * ::rsmi_pcie_bandwidth_t structure to which the frequency information will be * written * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. * */ rsmi_status_t -rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth *bandwidth); - -/** - * @brief Get percentage of time device is busy doing any processing - * - * @details Given a device index @p dv_ind, this function returns the - * percentage of time that the specified device is busy. The device is - * considered busy if any one or more of its sub-blocks are working, and idle - * if none of the sub-blocks are working. - * - * @param[in] dv_ind a device index - * - * @param[inout] busy_percent a pointer to the uint32_t to which the busy - * percent will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call - * - */ -rsmi_status_t -rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent); - -/** - * @brief Control the set of allowed PCIe bandwidths that can be used. - * - * @details Given a device index @p dv_ind and a 64 bit bitmask @p bw_bitmask, - * this function will limit the set of allowable bandwidths. If a bit in @p - * bw_bitmask has a value of 1, then the frequency (as ordered in an - * ::rsmi_frequencies returned by ::rsmi_dev_gpu_clk_freq_get()) corresponding - * to that bit index will be allowed. - * - * This function will change the performance level to - * ::RSMI_DEV_PERF_LEVEL_MANUAL in order to modify the set of allowable - * band_widths. Caller will need to set to ::RSMI_DEV_PERF_LEVEL_AUTO in order - * to get back to default state. - * - * All bits with indices greater than or equal to the value of the - * ::rsmi_frequencies::num_supported field of ::rsmi_pcie_bandwidth will be - * ignored. - * - * @param[in] dv_ind a device index - * - * @param[in] bw_bitmask A bitmask indicating the indices of the - * bandwidths that are to be enabled (1) and disabled (0). Only the lowest - * ::rsmi_frequencies::num_supported (of ::rsmi_pcie_bandwidth) bits of - * this mask are relevant. - */ -rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask); +rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *bandwidth); /** * @brief Get the unique PCI device identifier associated for a device @@ -475,7 +571,7 @@ rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid); * sent, @p received and @p max_pkt_sz, this function will write the number * of bytes sent and received in 1 second to @p sent and @p received, * respectively. The maximum possible packet size will be written to - * @max_pkt_size. + * @p max_pkt_sz. * * @param[in] dv_ind a device index * @@ -487,237 +583,236 @@ rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid); * * @param[inout] max_pkt_sz a pointer to uint64_t to which the maximum packet * size will be written. If pointer is NULL, it will be ignored. - * + * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - */ rsmi_status_t rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent, uint64_t *received, uint64_t *max_pkt_sz); +/** @} */ // end of PCIeQuer +/*****************************************************************************/ +/** @defgroup PCIeCont PCIe Control + * These functions provide some control over PCIe. + * @{ + */ + /** - * @brief Get the device id associated with the device with provided device - * index. + * @brief Control the set of allowed PCIe bandwidths that can be used. * - * @details Given a device index @p dv_ind and a pointer to a uint32_t @p id, - * this function will write the device id value to the uint64_t pointed to by - * @p id. This ID is an identification of the type of device, so calling this - * function for different devices will give the same value if they are kind - * of device. Consequently, this function should not be used to distinguish - * one device from another. rsmi_dev_pci_id_get() should be used to get a - * unique identifier. + * @details Given a device index @p dv_ind and a 64 bit bitmask @p bw_bitmask, + * this function will limit the set of allowable bandwidths. If a bit in @p + * bw_bitmask has a value of 1, then the frequency (as ordered in an + * ::rsmi_frequencies_t returned by ::rsmi_dev_gpu_clk_freq_get()) corresponding + * to that bit index will be allowed. + * + * This function will change the performance level to + * ::RSMI_DEV_PERF_LEVEL_MANUAL in order to modify the set of allowable + * band_widths. Caller will need to set to ::RSMI_DEV_PERF_LEVEL_AUTO in order + * to get back to default state. + * + * All bits with indices greater than or equal to the value of the + * ::rsmi_frequencies_t::num_supported field of ::rsmi_pcie_bandwidth_t will be + * ignored. * * @param[in] dv_ind a device index * - * @param[inout] id a pointer to uint64_t to which the device id will be - * written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * + * @param[in] bw_bitmask A bitmask indicating the indices of the + * bandwidths that are to be enabled (1) and disabled (0). Only the lowest + * ::rsmi_frequencies_t::num_supported (of ::rsmi_pcie_bandwidth_t) bits of + * this mask are relevant. */ -rsmi_status_t rsmi_dev_id_get(uint32_t dv_ind, uint64_t *id); +rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask); +/** @} */ // end of PCIeCont +/*****************************************************************************/ +/** @defgroup PowerQuer Power Queries + * These functions provide information about power usage. + * @{ + */ /** - * @brief Get the performance level of the device with provided + * @brief Get the average power consumption of the device with provided * device index. * - * @details Given a device index @p dv_ind and a pointer to a uint32_t @p - * perf, this function will write the ::rsmi_dev_perf_level to the uint32_t - * pointed to by @p perf - * - * @param[in] dv_ind a device index - * - * @param[inout] perf a pointer to ::rsmi_dev_perf_level to which the - * performance level will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t rsmi_dev_perf_level_get(uint32_t dv_ind, - rsmi_dev_perf_level *perf); - -/** - * @brief Set the PowerPlay performance level associated with the device with - * provided device index with the provided value. - * - * @details Given a device index @p dv_ind and an ::rsmi_dev_perf_level @p - * perf_level, this function will set the PowerPlay performance level for the - * device to the value @p perf_lvl. - * - * @param[in] dv_ind a device index - * - * @param[in] perf_lvl the value to which the performance level should be set - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t -rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level perf_lvl); - -/** - * @brief Get the overdrive percent associated with the device with provided - * device index. - * - * @details Given a device index @p dv_ind and a pointer to a uint32_t @p od, - * this function will write the overdrive percentage to the uint32_t pointed - * to by @p od - * - * @param[in] dv_ind a device index - * - * @param[inout] od a pointer to uint32_t to which the overdrive percentage - * will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od); - - -/** - * @brief Set the overdrive percent associated with the device with provided - * device index with the provided value. See details for WARNING. - * - * @details Given a device index @p dv_ind and an overdrive level @p od, - * this function will set the overdrive level for the device to the value - * @p od. The overdrive level is an integer value between 0 and 20, inclusive, - * which represents the overdrive percentage; e.g., a value of 5 specifies - * an overclocking of 5%. - * - * The overdrive level is specific to the gpu system clock. - * - * The overdrive level is the percentage above the maximum Performance Level - * to which overclocking will be limited. The overclocking percentage does - * not apply to clock speeds other than the maximum. This percentage is - * limited to 20%. - * - * ******WARNING****** - * Operating your AMD GPU outside of official AMD specifications or outside of - * factory settings, including but not limited to the conducting of - * overclocking (including use of this overclocking software, even if such - * software has been directly or indirectly provided by AMD or otherwise - * affiliated in any way with AMD), may cause damage to your AMD GPU, system - * components and/or result in system failure, as well as cause other problems. - * DAMAGES CAUSED BY USE OF YOUR AMD GPU OUTSIDE OF OFFICIAL AMD SPECIFICATIONS - * OR OUTSIDE OF FACTORY SETTINGS ARE NOT COVERED UNDER ANY AMD PRODUCT - * WARRANTY AND MAY NOT BE COVERED BY YOUR BOARD OR SYSTEM MANUFACTURER'S - * WARRANTY. Please use this utility with caution. - * - * @param[in] dv_ind a device index - * - * @param[in] od the value to which the overdrive level should be set - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t rsmi_dev_overdrive_level_set(int32_t dv_ind, uint32_t od); - -/** - * @brief Get the list of possible system clock speeds of device for a - * specified clock type. - * - * @details Given a device index @p dv_ind, a clock type @p clk_type, and a - * pointer to a to an ::rsmi_frequencies structure @p f, this function will - * fill in @p f with the possible clock speeds, and indication of the current - * clock speed selection. - * - * @param[in] dv_ind a device index - * - * @param[in] clk_type the type of clock for which the frequency is desired - * - * @param[inout] f a pointer to a caller provided ::rsmi_frequencies structure - * to which the frequency information will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, - rsmi_clk_type clk_type, rsmi_frequencies *f); - -/** - * @brief Control the set of allowed frequencies that can be used for the - * specified clock. - * - * @details Given a device index @p dv_ind, a clock type @p clk_type, and a - * 64 bit bitmask @p freq_bitmask, this function will limit the set of - * allowable frequencies. If a bit in @p freq_bitmask has a value of 1, then - * the frequency (as ordered in an ::rsmi_frequencies returned by - * rsmi_dev_gpu_clk_freq_get()) corresponding to that bit index will be - * allowed. - * - * This function will change the performance level to - * ::RSMI_DEV_PERF_LEVEL_MANUAL in order to modify the set of allowable - * frequencies. Caller will need to set to ::RSMI_DEV_PERF_LEVEL_AUTO in order - * to get back to default state. - * - * All bits with indices greater than or equal to - * ::rsmi_frequencies::num_supported will be ignored. - * - * @param[in] dv_ind a device index - * - * @param[in] clk_type the type of clock for which the set of frequencies - * will be modified - * - * @param[in] freq_bitmask A bitmask indicating the indices of the - * frequencies that are to be enabled (1) and disabled (0). Only the lowest - * ::rsmi_frequencies.num_supported bits of this mask are relevant. - */ -rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind, - rsmi_clk_type clk_type, uint64_t freq_bitmask); -/** - * @brief Get the name of a gpu device. - * - * @details Given a device index @p dv_ind, a pointer to a caller provided - * char buffer @p name, and a length of this buffer @p len, this function - * will write the name of the device (up to @p len characters) buffer @p name. - * - * @param[in] dv_ind a device index - * - * @param[inout] name a pointer to a caller provided char buffer to which the - * name will be written - * - * @param[in] len the length of the caller provided buffer @p name. - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len); - -/** - * @brief Get the temperature metric value for the specified metric, from the - * specified temperature sensor on the specified device. - * - * @details Given a device index @p dv_ind, a 0-based sensor index + * @details Given a device index @p dv_ind and a pointer to a uint64_t + * @p power, this function will write the current average power consumption to + * the uint64_t in microwatts pointed to by @p power. This function requires + * root privilege. * * @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] metric enum indicated which temperature value should be - * retrieved - * - * @param[inout] temperature a pointer to int64_t to which the temperature - * will be written, in millidegrees Celcius. + * @param[inout] power a pointer to uint64_t to which the average power + * consumption will be written * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. * */ -rsmi_status_t rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_temperature_metric metric, int64_t *temperature); +rsmi_status_t +rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power); + /** - * @brief Reset the fan to automatic driver control + * @brief Get the cap on power which, when reached, causes the system to take + * action to reduce power. * - * @details This function returns control of the fan to the system + * @details When power use rises above the value @p power, the system will + * take action to reduce power use. The power level returned through + * @p power will be in microWatts. + * + * @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[inout] cap a pointer to a uint64_t that indicates the power cap, + * in microwatts + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t +rsmi_dev_power_cap_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *cap); + +/** + * @brief Get the range of valid values for the power cap + * + * @details This function will return the maximum possible valid power cap + * @p max and the minimum possible valid power cap @p min + * + * @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[inout] max a pointer to a uint64_t that indicates the maximum + * possible power cap, in microwatts + * + * @param[inout] min a pointer to a uint64_t that indicates the minimum + * possible power cap, in microwatts + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t +rsmi_dev_power_cap_range_get(uint32_t dv_ind, uint32_t sensor_ind, + uint64_t *max, uint64_t *min); + +/** @} */ // end of PowerQuer + +/*****************************************************************************/ +/** @defgroup PowerCont Power Control + * These functions provide ways to control power usage. + * @{ + */ +/** + * @brief Set the power cap value + * + * @details This function will set the power cap to the provided value @p cap. + * @p cap must be between the minimum and maximum power cap values set by the + * system, which can be obtained from ::rsmi_dev_power_cap_range_get. + * + * @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[inout] cap a uint64_t that indicates the desired power cap, in + * microwatts + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t +rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap); + +/** + * @brief Set the power profile + * + * @details Given a device index @p dv_ind, a sensor index sensor_ind, and a + * @p profile, this function will attempt to set the current profile to the + * provided profile. The provided profile must be one of the currently + * supported profiles, as indicated by a call to + * ::rsmi_dev_power_profile_presets_get() * * @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] profile a ::rsmi_power_profile_preset_masks_t that hold the mask + * of the desired new power profile + * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * */ -rsmi_status_t rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind); +rsmi_status_t +rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t sensor_ind, + rsmi_power_profile_preset_masks_t profile); +/** @} */ // end of PowerCont +/*****************************************************************************/ + + +/*****************************************************************************/ +/** @defgroup MemQuer Memory Queries + * These functions provide information about memory systems. + * @{ + */ + +/** + * @brief Get the total amount of memory that exists + * + * @details Given a device index @p dv_ind, a type of memory @p mem_type, and + * a pointer to a uint64_t @p total, this function will write the total amount + * of @p mem_type memory that exists to the location pointed to by @p total. + * + * @param[in] dv_ind a device index + * + * @param[in] mem_type The type of memory for which the total amount will be + * found + * + * @param[inout] total a pointer to uint64_t to which the total amount of + * memory will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t +rsmi_dev_memory_total_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, + uint64_t *total); + +/** + * @brief Get the current memory usage + * + * @details Given a device index @p dv_ind, a type of memory @p mem_type, and + * a pointer to a uint64_t @p usage, this function will write the amount of + * @p mem_type memory that that is currently being used to the location + * pointed to by @p total. + * + * @param[in] dv_ind a device index + * + * @param[in] mem_type The type of memory for which the amount being used will + * be found + * + * @param[inout] used a pointer to uint64_t to which the amount of memory + * currently being used will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t +rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, + uint64_t *used); + +/** @} */ // end of MemQuer + +/** @defgroup PhysQuer Physcial State Queries + * These functions provide information about the physical characteristics of + * the device. + * @{ + */ /** * @brief Get the fan speed in RPMs of the device with the specified device * index and 0-based sensor index. @@ -787,6 +882,52 @@ rsmi_status_t rsmi_dev_fan_speed_get(uint32_t dv_ind, rsmi_status_t rsmi_dev_fan_speed_max_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *max_speed); +/** + * @brief Get the temperature metric value for the specified metric, from the + * specified temperature sensor on the specified device. + * + * @details Given a device index @p dv_ind, a 0-based sensor index + * @p sensor_ind, a ::rsmi_temperature_metric_t @p metric and a pointer to an + * int64_t @p temperature, this function will write the value of the metric + * indicated by @p metric to the memory location @p temperature. + * + * @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] metric enum indicated which temperature value should be + * retrieved + * + * @param[inout] temperature a pointer to int64_t to which the temperature + * will be written, in millidegrees Celcius. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_ind, + rsmi_temperature_metric_t metric, int64_t *temperature); +/** @} */ // end of PhysQuer + +/*****************************************************************************/ +/** @defgroup PhysCont Physcial State Control + * These functions provide control over the physical state of a device. + * @{ + */ +/** + * @brief Reset the fan to automatic driver control + * + * @details This function returns control of the fan to the system + * + * @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. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + */ +rsmi_status_t rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind); + /** * @brief Set the fan speed for the specified device with the provided speed, * in RPMs. @@ -808,51 +949,118 @@ rsmi_status_t rsmi_dev_fan_speed_max_get(uint32_t dv_ind, rsmi_status_t rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t speed); +/** @} */ // end of PhysCont +/*****************************************************************************/ +/** @defgroup PerfQuer Clock, Power and Performance Queries + * These functions provide information about clock frequencies and + * performance. + * @{ + */ + +/** + * @brief Get percentage of time device is busy doing any processing + * + * @details Given a device index @p dv_ind, this function returns the + * percentage of time that the specified device is busy. The device is + * considered busy if any one or more of its sub-blocks are working, and idle + * if none of the sub-blocks are working. + * + * @param[in] dv_ind a device index + * + * @param[inout] busy_percent a pointer to the uint32_t to which the busy + * percent will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * + */ +rsmi_status_t +rsmi_dev_busy_percent_get(uint32_t dv_ind, uint32_t *busy_percent); + +/** + * @brief Get the performance level of the device with provided + * device index. + * + * @details Given a device index @p dv_ind and a pointer to a uint32_t @p + * perf, this function will write the ::rsmi_dev_perf_level_t to the uint32_t + * pointed to by @p perf + * + * @param[in] dv_ind a device index + * + * @param[inout] perf a pointer to ::rsmi_dev_perf_level_t to which the + * performance level will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_perf_level_get(uint32_t dv_ind, + rsmi_dev_perf_level_t *perf); + +/** + * @brief Get the overdrive percent associated with the device with provided + * device index. + * + * @details Given a device index @p dv_ind and a pointer to a uint32_t @p od, + * this function will write the overdrive percentage to the uint32_t pointed + * to by @p od + * + * @param[in] dv_ind a device index + * + * @param[inout] od a pointer to uint32_t to which the overdrive percentage + * will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_overdrive_level_get(uint32_t dv_ind, uint32_t *od); + +/** + * @brief Get the list of possible system clock speeds of device for a + * specified clock type. + * + * @details Given a device index @p dv_ind, a clock type @p clk_type, and a + * pointer to a to an ::rsmi_frequencies_t structure @p f, this function will + * fill in @p f with the possible clock speeds, and indication of the current + * clock speed selection. + * + * @param[in] dv_ind a device index + * + * @param[in] clk_type the type of clock for which the frequency is desired + * + * @param[inout] f a pointer to a caller provided ::rsmi_frequencies_t structure + * to which the frequency information will be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, + rsmi_clk_type_t clk_type, rsmi_frequencies_t *f); + /** * @brief This function retrieves the voltage/frequency curve information * * @details Given a device index @p dv_ind and a pointer to a - * ::rsmi_od_volt_freq_data structure @p odv, this function will populate @p - * odv. See ::rsmi_od_volt_freq_data for more details. + * ::rsmi_od_volt_freq_data_t structure @p odv, this function will populate @p + * odv. See ::rsmi_od_volt_freq_data_t for more details. * * @param[in] dv_ind a device index * - * @param[in] odv a pointer to an ::rsmi_od_volt_freq_data structure + * @param[in] odv a pointer to an ::rsmi_od_volt_freq_data_t structure * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. */ rsmi_status_t rsmi_dev_od_volt_info_get(uint32_t dv_ind, - rsmi_od_volt_freq_data *odv); - -/** - * @brief Set the frequency limits for the specified clock - * - * @details Given a device index @p dv_ind, a clock type (::rsmi_clk_type) - * @p clk, and a pointer to a ::rsmi_range @p range containing the desired - * upper and lower frequency limits, this function will attempt to set the - * frequency limits to those specified in @p range. - * - * @param[in] dv_ind a device index - * - * @param[in] clk The clock type for which the limits should be imposed. - * - * @param[in] range A pointer to the ::rsmi_range containing the desired limits - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - */ -rsmi_status_t rsmi_dev_od_freq_range_set(uint32_t dv_ind, rsmi_clk_type clk, - rsmi_range *range); + rsmi_od_volt_freq_data_t *odv); /** * @brief This function will retrieve the current valid regions in the * frequency/voltage space. * * @details Given a device index @p dv_ind, a pointer to an unsigned integer - * @p num_regions and a buffer of ::rsmi_freq_volt_region structures, @p + * @p num_regions and a buffer of ::rsmi_freq_volt_region_t structures, @p * buffer, this function will populate @p buffer with the current * frequency-volt space regions. The caller should assign @p buffer to memory * that can be written to by this function. The caller should also - * indicate the number of ::rsmi_freq_volt_region structures that can safely + * indicate the number of ::rsmi_freq_volt_region_t structures that can safely * be written to @p buffer in @p num_regions. * * The number of regions to expect this function provide (@p num_regions) can @@ -861,132 +1069,41 @@ rsmi_status_t rsmi_dev_od_freq_range_set(uint32_t dv_ind, rsmi_clk_type clk, * @param[in] dv_ind a device index * * @param[inout] num_regions As input, this is the number of - * ::rsmi_freq_volt_region structures that can be written to @p buffer. As - * output, this is the number of ::rsmi_freq_volt_region structures that were + * ::rsmi_freq_volt_region_t structures that can be written to @p buffer. As + * output, this is the number of ::rsmi_freq_volt_region_t structures that were * actually written. * * @param[inout] buffer a caller provided buffer to which - * ::rsmi_freq_volt_region structures will be written + * ::rsmi_freq_volt_region_t structures will be written * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. */ rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, - uint32_t *num_regions, rsmi_freq_volt_region *buffer); - -/** - * @brief Get the average power consumption of the device with provided - * device index. - * - * @details Given a device index @p dv_ind and a pointer to a uint64_t - * @p power, this function will write the current average power consumption to - * the uint64_t in microwatts pointed to by @p power. This function requires - * root privilege. - * - * @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[inout] power a pointer to uint64_t to which the average power - * consumption will be written - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t -rsmi_dev_power_ave_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *power); - -/** - * @brief Get the cap on power which, when reached, causes the system to take - * action to reduce power. - * - * @details When power use rises above the value @p power, the system will - * take action to reduce power use. The power level returned through - * @p power will be in microWatts. - * - * @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[inout] cap a pointer to a uint64_t that indicates the power cap, - * in microwatts - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t -rsmi_dev_power_cap_get(uint32_t dv_ind, uint32_t sensor_ind, uint64_t *cap); - -/** - * @brief Get the range of valid values for the power cap - * - * @details This function will return the maximum possible valid power cap - * @p max and the minimum possible valid power cap @p min - * - * @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[inout] max a pointer to a uint64_t that indicates the maximum - * possible power cap, in microwatts - * - * @param[inout] min a pointer to a uint64_t that indicates the minimum - * possible power cap, in microwatts - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t -rsmi_dev_power_cap_range_get(uint32_t dv_ind, uint32_t sensor_ind, - uint64_t *max, uint64_t *min); - -/** - * @brief Set the power cap value - * - * @details This function will set the power cap to the provided value @p cap. - * @p cap must be between the minimum and maximum power cap values set by the - * system, which can be obtained from ::rsmi_dev_power_cap_range_get. - * - * @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[inout] cap a uint64_t that indicates the desired power cap, in - * microwatts - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. - * - */ -rsmi_status_t -rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap); - + uint32_t *num_regions, rsmi_freq_volt_region_t *buffer); /** * @brief Get the list of available preset power profiles and an indication of * which profile is currently active. * * @details Given a device index @p dv_ind and a pointer to a - * ::rsmi_power_profile_status @p status, this function will set the bits of - * the ::rsmi_power_profile_status.available_profiles bit field of @p status to + * ::rsmi_power_profile_status_t @p status, this function will set the bits of + * the ::rsmi_power_profile_status_t.available_profiles bit field of @p status to * 1 if the profile corresponding to the respective - * ::rsmi_power_profile_preset_masks profiles are enabled. For example, if both + * ::rsmi_power_profile_preset_masks_t profiles are enabled. For example, if both * the VIDEO and VR power profiles are available selections, then * ::RSMI_PWR_PROF_PRST_VIDEO_MASK AND'ed with - * ::rsmi_power_profile_status.available_profiles will be non-zero as will + * ::rsmi_power_profile_status_t.available_profiles will be non-zero as will * ::RSMI_PWR_PROF_PRST_VR_MASK AND'ed with - * ::rsmi_power_profile_status.available_profiles. Additionally, - * ::rsmi_power_profile_status.current will be set to the - * ::rsmi_power_profile_preset_masks of the profile that is currently active. + * ::rsmi_power_profile_status_t.available_profiles. Additionally, + * ::rsmi_power_profile_status_t.current will be set to the + * ::rsmi_power_profile_preset_masks_t of the profile that is currently active. * * @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[inout] status a pointer to ::rsmi_power_profile_status that will be + * @param[inout] status a pointer to ::rsmi_power_profile_status_t that will be * populated by a call to this function * * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. @@ -994,31 +1111,145 @@ rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap); */ rsmi_status_t rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_power_profile_status *status); + rsmi_power_profile_status_t *status); +/** @} */ // end of PerfQuer +/*****************************************************************************/ + +/** @defgroup PerfCont Clock, Power and Performance Control + * These functions provide control over clock frequencies, power and + * performance. + * @{ + */ /** - * @brief Set the power profile + * @brief Set the PowerPlay performance level associated with the device with + * provided device index with the provided value. * - * @details Given a device index @p dv_ind, a sensor index sensor_ind, and a - * @p profile, this function will attempt to set the current profile to the - * provided profile. The provided profile must be one of the currently - * supported profiles, as indicated by a call to - * ::rsmi_dev_power_profile_presets_get() + * @details Given a device index @p dv_ind and an ::rsmi_dev_perf_level_t @p + * perf_level, this function will set the PowerPlay performance level for the + * device to the value @p perf_lvl. * - * @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] perf_lvl the value to which the performance level should be set * - * @param[in] profile a ::rsmi_power_profile_preset_masks that hold the mask - * of the desired new power profile - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. * */ rsmi_status_t -rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_power_profile_preset_masks profile); +rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level_t perf_lvl); + +/** + * @brief Set the overdrive percent associated with the device with provided + * device index with the provided value. See details for WARNING. + * + * @details Given a device index @p dv_ind and an overdrive level @p od, + * this function will set the overdrive level for the device to the value + * @p od. The overdrive level is an integer value between 0 and 20, inclusive, + * which represents the overdrive percentage; e.g., a value of 5 specifies + * an overclocking of 5%. + * + * The overdrive level is specific to the gpu system clock. + * + * The overdrive level is the percentage above the maximum Performance Level + * to which overclocking will be limited. The overclocking percentage does + * not apply to clock speeds other than the maximum. This percentage is + * limited to 20%. + * + * ******WARNING****** + * Operating your AMD GPU outside of official AMD specifications or outside of + * factory settings, including but not limited to the conducting of + * overclocking (including use of this overclocking software, even if such + * software has been directly or indirectly provided by AMD or otherwise + * affiliated in any way with AMD), may cause damage to your AMD GPU, system + * components and/or result in system failure, as well as cause other problems. + * DAMAGES CAUSED BY USE OF YOUR AMD GPU OUTSIDE OF OFFICIAL AMD SPECIFICATIONS + * OR OUTSIDE OF FACTORY SETTINGS ARE NOT COVERED UNDER ANY AMD PRODUCT + * WARRANTY AND MAY NOT BE COVERED BY YOUR BOARD OR SYSTEM MANUFACTURER'S + * WARRANTY. Please use this utility with caution. + * + * @param[in] dv_ind a device index + * + * @param[in] od the value to which the overdrive level should be set + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_overdrive_level_set(int32_t dv_ind, uint32_t od); + +/** + * @brief Control the set of allowed frequencies that can be used for the + * specified clock. + * + * @details Given a device index @p dv_ind, a clock type @p clk_type, and a + * 64 bit bitmask @p freq_bitmask, this function will limit the set of + * allowable frequencies. If a bit in @p freq_bitmask has a value of 1, then + * the frequency (as ordered in an ::rsmi_frequencies_t returned by + * rsmi_dev_gpu_clk_freq_get()) corresponding to that bit index will be + * allowed. + * + * This function will change the performance level to + * ::RSMI_DEV_PERF_LEVEL_MANUAL in order to modify the set of allowable + * frequencies. Caller will need to set to ::RSMI_DEV_PERF_LEVEL_AUTO in order + * to get back to default state. + * + * All bits with indices greater than or equal to + * ::rsmi_frequencies_t::num_supported will be ignored. + * + * @param[in] dv_ind a device index + * + * @param[in] clk_type the type of clock for which the set of frequencies + * will be modified + * + * @param[in] freq_bitmask A bitmask indicating the indices of the + * frequencies that are to be enabled (1) and disabled (0). Only the lowest + * ::rsmi_frequencies_t.num_supported bits of this mask are relevant. + */ +rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind, + rsmi_clk_type_t clk_type, uint64_t freq_bitmask); + +/** + * @brief Set the frequency limits for the specified clock + * + * @details Given a device index @p dv_ind, a clock type (::rsmi_clk_type_t) + * @p clk, and a pointer to a ::rsmi_range_t @p range containing the desired + * upper and lower frequency limits, this function will attempt to set the + * frequency limits to those specified in @p range. + * + * @param[in] dv_ind a device index + * + * @param[in] clk The clock type for which the limits should be imposed. + * + * @param[in] range A pointer to the ::rsmi_range_t containing the desired limits + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + */ +rsmi_status_t rsmi_dev_od_freq_range_set(uint32_t dv_ind, rsmi_clk_type_t clk, + rsmi_range_t *range); + +/** @} */ // end of PerfCont + +/*****************************************************************************/ +/** @defgroup VersQuer Version Queries + * These functions provide version information about various subsystems. + * @{ + */ + +/** + * @brief Get the build version information for the currently running build of + * RSMI. + * + * @details Get the major, minor, patch and build string for RSMI build + * currently in use through @p version + * + * @param[inout] version A pointer to an ::rsmi_version_t structure that will + * be updated with the version information upon return. + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call + * + */ +rsmi_status_t +rsmi_version_get(rsmi_version_t *version); /** * @brief Get the VBIOS identifer string @@ -1042,6 +1273,36 @@ rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t sensor_ind, rsmi_status_t rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len); +/** @} */ // end of VersQuer + +/*****************************************************************************/ +/** @defgroup ErrQuer Error Queries + * These functions provide error information about RSMI calls as well as + * device errors. + * @{ + */ + +/** + * @brief Retrieve the error counts for a GPU block + * + * @details Given a device index @p dv_ind, an ::rsmi_gpu_block_t @p block and a + * pointer to an ::rsmi_error_count_t @p ec, this function will write the error + * count values for the GPU block indicated by @p block to memory pointed to by + * @p ec. + * + * @param[in] dv_ind a device index + * + * @param[in] block The block for which error counts should be retrieved + * + * @param[inout] ec A pointer to an ::rsmi_error_count_t to which the error + * counts should be written + * + * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call. + * + */ +rsmi_status_t rsmi_dev_error_count_get(uint32_t dv_ind, + rsmi_gpu_block_t block, rsmi_error_count_t *ec); + /** * @brief Get a description of a provided RSMI error status * @@ -1059,21 +1320,7 @@ rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len); rsmi_status_t rsmi_status_string(rsmi_status_t status, const char **status_string); -/** - * @brief Get the build version information for the currently running build of - * RSMI. - * - * @details Get the major, minor, patch and build string for RSMI build - * currently in use through @p version - * - * @param[inout] version A pointer to an ::rsmi_version structure that will - * be updated with the version information upon return. - * - * @retval ::RSMI_STATUS_SUCCESS is returned upon successful call - * - */ -rsmi_status_t -rsmi_version_get(rsmi_version *version); +/** @} */ // end of ErrQuer #ifdef __cplusplus } diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi_device.h b/projects/amdsmi/include/rocm_smi/rocm_smi_device.h index 426c326832..902c14897d 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi_device.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi_device.h @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) @@ -70,6 +68,15 @@ enum DevInfoTypes { kDevPowerODVoltage, kDevVBiosVer, kDevPCIEThruPut, + kDevErrCntSDMA, + kDevErrCntUMC, + kDevErrCntGFX, + kDevMemTotGTT, + kDevMemTotVisVRAM, + kDevMemTotVRAM, + kDevMemUsedGTT, + kDevMemUsedVisVRAM, + kDevMemUsedVRAM, }; class Device { @@ -83,9 +90,7 @@ class Device { const std::shared_ptr& power_monitor() {return power_monitor_;} void set_power_monitor(std::shared_ptr pm) {power_monitor_ = pm;} -#if 0 // This is not being used right now. - int readDevInfo(DevInfoTypes type, uint32_t *val); -#endif + int readDevInfo(DevInfoTypes type, uint64_t *val); int readDevInfoLine(DevInfoTypes type, std::string *line); int readDevInfo(DevInfoTypes type, std::string *val); int readDevInfo(DevInfoTypes type, std::vector *retVec); diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h b/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h index 57c0754536..15bae95e14 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) diff --git a/projects/amdsmi/src/rocm_smi.cc b/projects/amdsmi/src/rocm_smi.cc index 44449fa1bc..85819ad65c 100755 --- a/projects/amdsmi/src/rocm_smi.cc +++ b/projects/amdsmi/src/rocm_smi.cc @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) @@ -177,7 +175,7 @@ static uint64_t freq_string_to_int(const std::vector &freq_lines, } static void freq_volt_string_to_point(std::string in_line, - rsmi_od_vddc_point *pt) { + rsmi_od_vddc_point_t *pt) { std::istringstream fs_vlt(in_line); assert(pt != nullptr); @@ -206,7 +204,7 @@ static void freq_volt_string_to_point(std::string in_line, return; } -static void od_value_pair_str_to_range(std::string in_line, rsmi_range *rg) { +static void od_value_pair_str_to_range(std::string in_line, rsmi_range_t *rg) { std::istringstream fs_rng(in_line); assert(rg != nullptr); @@ -244,7 +242,7 @@ power_prof_string_to_int(std::string pow_prof_line, bool *is_curr, std::string mode; size_t tmp; - rsmi_power_profile_preset_masks ret = RSMI_PWR_PROF_PRST_INVALID; + rsmi_power_profile_preset_masks_t ret = RSMI_PWR_PROF_PRST_INVALID; fs >> *prof_ind; fs >> mode; @@ -289,6 +287,13 @@ static rsmi_status_t get_dev_value_str(amd::smi::DevInfoTypes type, return errno_to_rsmi_status(ret); } +static rsmi_status_t get_dev_value_int(amd::smi::DevInfoTypes type, + uint32_t dv_ind, uint64_t *val_int) { + GET_DEV_FROM_INDX + int ret = dev->readDevInfo(type, val_int); + + return errno_to_rsmi_status(ret); +} static rsmi_status_t get_dev_value_line(amd::smi::DevInfoTypes type, uint32_t dv_ind, std::string *val_str) { @@ -433,6 +438,62 @@ rsmi_num_monitor_devices(uint32_t *num_devices) { CATCH } +rsmi_status_t +rsmi_dev_error_count_get(uint32_t dv_ind, rsmi_gpu_block_t block, + rsmi_error_count_t *ec) { + std::vector val_vec; + rsmi_status_t ret; + + TRY + if (ec == nullptr || block > RSMI_GPU_BLOCK_LAST) { + return RSMI_STATUS_INVALID_ARGS; + } + + amd::smi::DevInfoTypes type; + switch (block) { + case RSMI_GPU_BLOCK_UMC: + type = amd::smi::kDevErrCntUMC; + break; + + case RSMI_GPU_BLOCK_SDMA: + type = amd::smi::kDevErrCntSDMA; + break; + + case RSMI_GPU_BLOCK_GFX: + type = amd::smi::kDevErrCntGFX; + break; + + default: + assert(!"Unsupported block provided to rsmi_dev_error_count_get()"); + return RSMI_STATUS_NOT_SUPPORTED; + } + ret = get_dev_value_vec(type, dv_ind, &val_vec); + + if (ret == RSMI_STATUS_FILE_ERROR) { + return RSMI_STATUS_NOT_SUPPORTED; + } + if (ret != RSMI_STATUS_SUCCESS) { + return ret; + } + + assert(val_vec.size() == 2); + + std::string junk; + std::istringstream fs1(val_vec[0]); + + fs1 >> junk; + assert(junk == "ue:"); + fs1 >> ec->uncorrectable_err; + + std::istringstream fs2(val_vec[1]); + + fs2 >> junk; + assert(junk == "ce:"); + fs2 >> ec->correctable_err; + + return ret; + CATCH +} rsmi_status_t rsmi_dev_pci_id_get(uint32_t dv_ind, uint64_t *bdfid) { TRY @@ -466,7 +527,7 @@ rsmi_dev_id_get(uint32_t dv_ind, uint64_t *id) { } rsmi_status_t -rsmi_dev_perf_level_get(uint32_t dv_ind, rsmi_dev_perf_level *perf) { +rsmi_dev_perf_level_get(uint32_t dv_ind, rsmi_dev_perf_level_t *perf) { TRY std::string val_str; rsmi_status_t ret = get_dev_value_str(amd::smi::kDevPerfLevel, dv_ind, @@ -511,7 +572,7 @@ rsmi_dev_overdrive_level_set(int32_t dv_ind, uint32_t od) { } rsmi_status_t -rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level perf_level) { +rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level_t perf_level) { TRY if (perf_level > RSMI_DEV_PERF_LEVEL_LAST) { return RSMI_STATUS_INVALID_ARGS; @@ -522,7 +583,7 @@ rsmi_dev_perf_level_set(int32_t dv_ind, rsmi_dev_perf_level perf_level) { } static rsmi_status_t get_frequencies(amd::smi::DevInfoTypes type, - uint32_t dv_ind, rsmi_frequencies *f, uint32_t *lanes = nullptr) { + uint32_t dv_ind, rsmi_frequencies_t *f, uint32_t *lanes = nullptr) { TRY std::vector val_vec; rsmi_status_t ret; @@ -571,8 +632,8 @@ static rsmi_status_t get_frequencies(amd::smi::DevInfoTypes type, } static rsmi_status_t get_power_profiles(uint32_t dv_ind, - rsmi_power_profile_status *p, - std::map *ind_map) { + rsmi_power_profile_status_t *p, + std::map *ind_map) { TRY std::vector val_vec; rsmi_status_t ret; @@ -592,7 +653,7 @@ static rsmi_status_t get_power_profiles(uint32_t dv_ind, p->current = RSMI_PWR_PROF_PRST_INVALID; // init to an invalid value p->available_profiles = 0; - rsmi_power_profile_preset_masks prof; + rsmi_power_profile_preset_masks_t prof; uint32_t prof_ind; for (uint32_t i = 1; i < val_vec.size(); ++i) { @@ -652,7 +713,7 @@ static const uint32_t kOD_VDDC_CURVE_num_lines = kOD_VDDC_CURVE_start_index + 4; static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, - rsmi_od_volt_freq_data *p) { + rsmi_od_volt_freq_data_t *p) { TRY std::vector val_vec; rsmi_status_t ret; @@ -708,7 +769,7 @@ static rsmi_status_t get_od_clk_volt_info(uint32_t dv_ind, } static void get_vc_region(uint32_t start_ind, - std::vector *val_vec, rsmi_freq_volt_region *p) { + std::vector *val_vec, rsmi_freq_volt_region_t *p) { assert(p != nullptr); assert(val_vec != nullptr); // There must be at least 1 region to read in @@ -729,7 +790,7 @@ static void get_vc_region(uint32_t start_ind, * *num_regions regions. On */ static rsmi_status_t get_od_clk_volt_curve_regions(uint32_t dv_ind, - uint32_t *num_regions, rsmi_freq_volt_region *p) { + uint32_t *num_regions, rsmi_freq_volt_region_t *p) { TRY std::vector val_vec; rsmi_status_t ret; @@ -766,18 +827,19 @@ static bool is_power_of_2(uint64_t n) { return n && !(n & (n - 1)); } static rsmi_status_t set_power_profile(uint32_t dv_ind, - rsmi_power_profile_preset_masks profile) { + rsmi_power_profile_preset_masks_t profile) { TRY rsmi_status_t ret; - rsmi_power_profile_status avail_profiles = {0, RSMI_PWR_PROF_PRST_INVALID, 0}; + rsmi_power_profile_status_t avail_profiles = + {0, RSMI_PWR_PROF_PRST_INVALID, 0}; // Determine if the provided profile is valid if (!is_power_of_2(profile)) { return RSMI_STATUS_INPUT_OUT_OF_BOUNDS; } - std::map ind_map; + std::map ind_map; ret = get_power_profiles(dv_ind, &avail_profiles, &ind_map); if (ret != RSMI_STATUS_SUCCESS) { @@ -804,8 +866,8 @@ static rsmi_status_t set_power_profile(uint32_t dv_ind, } rsmi_status_t -rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, rsmi_clk_type clk_type, - rsmi_frequencies *f) { +rsmi_dev_gpu_clk_freq_get(uint32_t dv_ind, rsmi_clk_type_t clk_type, + rsmi_frequencies_t *f) { TRY switch (clk_type) { case RSMI_CLK_TYPE_SYS: @@ -836,9 +898,9 @@ static std::string bitfield_to_freq_string(uint64_t bitf, rsmi_status_t rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind, - rsmi_clk_type clk_type, uint64_t freq_bitmask) { + rsmi_clk_type_t clk_type, uint64_t freq_bitmask) { rsmi_status_t ret; - rsmi_frequencies freqs; + rsmi_frequencies_t freqs; TRY ret = rsmi_dev_gpu_clk_freq_get(dv_ind, clk_type, &freqs); @@ -911,7 +973,7 @@ rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len) { } rsmi_status_t -rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth *b) { +rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *b) { TRY assert(b != nullptr); @@ -928,7 +990,7 @@ rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth *b) { rsmi_status_t rsmi_dev_pci_bandwidth_set(uint32_t dv_ind, uint64_t bw_bitmask) { rsmi_status_t ret; - rsmi_pcie_bandwidth bws; + rsmi_pcie_bandwidth_t bws; TRY ret = rsmi_dev_pci_bandwidth_get(dv_ind, &bws); @@ -995,7 +1057,7 @@ rsmi_dev_pci_throughput_get(uint32_t dv_ind, uint64_t *sent, rsmi_status_t rsmi_dev_temp_metric_get(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_temperature_metric metric, int64_t *temperature) { + rsmi_temperature_metric_t metric, int64_t *temperature) { TRY if (temperature == nullptr) { @@ -1174,7 +1236,7 @@ rsmi_dev_fan_speed_max_get(uint32_t dv_ind, uint32_t sensor_ind, } rsmi_status_t -rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data *odv) { +rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data_t *odv) { TRY rsmi_status_t ret = get_od_clk_volt_info(dv_ind, odv); @@ -1183,7 +1245,7 @@ rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data *odv) { } rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, - uint32_t *num_regions, rsmi_freq_volt_region *buffer) { + uint32_t *num_regions, rsmi_freq_volt_region_t *buffer) { TRY if (buffer == nullptr || num_regions == nullptr || *num_regions == 0) { @@ -1298,7 +1360,7 @@ rsmi_dev_power_cap_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t cap) { rsmi_status_t rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_power_profile_status *status) { + rsmi_power_profile_status_t *status) { TRY ++sensor_ind; // power sysfs files have 1-based indices @@ -1310,7 +1372,7 @@ rsmi_dev_power_profile_presets_get(uint32_t dv_ind, uint32_t sensor_ind, rsmi_status_t rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t sensor_ind, - rsmi_power_profile_preset_masks profile) { + rsmi_power_profile_preset_masks_t profile) { TRY ++sensor_ind; // power sysfs files have 1-based indices @@ -1319,6 +1381,73 @@ rsmi_dev_power_profile_set(uint32_t dv_ind, uint32_t sensor_ind, CATCH } +rsmi_status_t +rsmi_dev_memory_total_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, + uint64_t *total) { + TRY + rsmi_status_t ret; + amd::smi::DevInfoTypes mem_type_file; + + if (total == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } + + switch (mem_type) { + case RSMI_MEM_TYPE_GTT: + mem_type_file = amd::smi::kDevMemTotGTT; + break; + + case RSMI_MEM_TYPE_VIS_VRAM: + mem_type_file = amd::smi::kDevMemTotVisVRAM; + break; + + case RSMI_MEM_TYPE_VRAM: + mem_type_file = amd::smi::kDevMemTotVRAM; + break; + + default: + assert(!"Unexpected memory type"); + return RSMI_STATUS_INVALID_ARGS; + } + ret = get_dev_value_int(mem_type_file, dv_ind, total); + + return ret; + CATCH +} +rsmi_status_t +rsmi_dev_memory_usage_get(uint32_t dv_ind, rsmi_memory_type_t mem_type, + uint64_t *used) { + TRY + rsmi_status_t ret; + amd::smi::DevInfoTypes mem_type_file; + + if (used == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } + + switch (mem_type) { + case RSMI_MEM_TYPE_GTT: + mem_type_file = amd::smi::kDevMemUsedGTT; + break; + + case RSMI_MEM_TYPE_VIS_VRAM: + mem_type_file = amd::smi::kDevMemUsedVisVRAM; + break; + + case RSMI_MEM_TYPE_VRAM: + mem_type_file = amd::smi::kDevMemUsedVRAM; + break; + + default: + assert(!"Unexpected memory type"); + return RSMI_STATUS_INVALID_ARGS; + } + ret = get_dev_value_int(mem_type_file, dv_ind, used); + + return ret; + CATCH +} + rsmi_status_t rsmi_status_string(rsmi_status_t status, const char **status_string) { TRY @@ -1427,7 +1556,7 @@ rsmi_dev_vbios_version_get(uint32_t dv_ind, char *vbios, uint32_t len) { } rsmi_status_t -rsmi_version_get(rsmi_version *version) { +rsmi_version_get(rsmi_version_t *version) { TRY if (version == nullptr) { diff --git a/projects/amdsmi/src/rocm_smi_device.cc b/projects/amdsmi/src/rocm_smi_device.cc index 47bcacbb9e..4c21dc04ab 100755 --- a/projects/amdsmi/src/rocm_smi_device.cc +++ b/projects/amdsmi/src/rocm_smi_device.cc @@ -1,4 +1,4 @@ -/* ROC Runtime Conformance Release License +/* * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) @@ -59,6 +59,7 @@ namespace amd { namespace smi { +// Sysfs file names static const char *kDevPerfLevelFName = "power_dpm_force_performance_level"; static const char *kDevDevIDFName = "device"; static const char *kDevOverDriveLevelFName = "pp_sclk_od"; @@ -70,6 +71,17 @@ static const char *kDevPowerODVoltageFName = "pp_od_clk_voltage"; static const char *kDevUsageFName = "gpu_busy_percent"; static const char *kDevVBiosVerFName = "vbios_version"; static const char *kDevPCIEThruPutFName = "pcie_bw"; +static const char *kDevErrCntSDMAFName = "ras/sdma_err_count"; +static const char *kDevErrCntUMCFName = "ras/umc_err_count"; +static const char *kDevErrCntGFXFName = "ras/gfx_err_count"; +static const char *kDevMemTotGTTFName = "mem_info_gtt_total"; +static const char *kDevMemTotVisVRAMFName = "mem_info_vis_vram_total"; +static const char *kDevMemTotVRAMFName = "mem_info_vram_total"; +static const char *kDevMemUsedGTTFName = "mem_info_gtt_used"; +static const char *kDevMemUsedVisVRAMFName = "mem_info_vis_vram_used"; +static const char *kDevMemUsedVRAMFName = "mem_info_vram_used"; + +// Strings that are found within sysfs files static const char *kDevPerfLevelAutoStr = "auto"; static const char *kDevPerfLevelLowStr = "low"; static const char *kDevPerfLevelHighStr = "high"; @@ -92,6 +104,15 @@ static const std::map kDevAttribNameMap = { {kDevPowerODVoltage, kDevPowerODVoltageFName}, {kDevVBiosVer, kDevVBiosVerFName}, {kDevPCIEThruPut, kDevPCIEThruPutFName}, + {kDevErrCntSDMA, kDevErrCntSDMAFName}, + {kDevErrCntUMC, kDevErrCntUMCFName}, + {kDevErrCntGFX, kDevErrCntGFXFName}, + {kDevMemTotGTT, kDevMemTotGTTFName}, + {kDevMemTotVisVRAM, kDevMemTotVisVRAMFName}, + {kDevMemTotVRAM, kDevMemTotVRAMFName}, + {kDevMemUsedGTT, kDevMemUsedGTTFName}, + {kDevMemUsedVisVRAM, kDevMemUsedVisVRAMFName}, + {kDevMemUsedVRAM, kDevMemUsedVRAMFName}, }; static const std::map kDevPerfLvlMap = { @@ -287,8 +308,7 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type, return 0; } -#if 0 -int Device::readDevInfo(DevInfoTypes type, uint32_t *val) { +int Device::readDevInfo(DevInfoTypes type, uint64_t *val) { assert(val != nullptr); std::string tempStr; @@ -302,9 +322,15 @@ int Device::readDevInfo(DevInfoTypes type, uint32_t *val) { case kDevUsage: case kDevOverDriveLevel: + case kDevMemTotGTT: + case kDevMemTotVisVRAM: + case kDevMemTotVRAM: + case kDevMemUsedGTT: + case kDevMemUsedVisVRAM: + case kDevMemUsedVRAM: ret = readDevInfoStr(type, &tempStr); RET_IF_NONZERO(ret); - *val = std::stoi(tempStr, 0); + *val = std::stoul(tempStr, 0); break; default: @@ -312,7 +338,7 @@ int Device::readDevInfo(DevInfoTypes type, uint32_t *val) { } return 0; } -#endif + int Device::readDevInfo(DevInfoTypes type, std::vector *val) { assert(val != nullptr); @@ -322,6 +348,9 @@ int Device::readDevInfo(DevInfoTypes type, std::vector *val) { case kDevPCIEClk: case kDevPowerProfileMode: case kDevPowerODVoltage: + case kDevErrCntSDMA: + case kDevErrCntUMC: + case kDevErrCntGFX: return readDevInfoMultiLineStr(type, val); break; diff --git a/projects/amdsmi/src/rocm_smi_main.cc b/projects/amdsmi/src/rocm_smi_main.cc index fc78e77d40..4c7d5f96d5 100755 --- a/projects/amdsmi/src/rocm_smi_main.cc +++ b/projects/amdsmi/src/rocm_smi_main.cc @@ -1,7 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License - * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) * diff --git a/projects/amdsmi/src/rocm_smi_monitor.cc b/projects/amdsmi/src/rocm_smi_monitor.cc index e14de9f40d..26c137cd74 100755 --- a/projects/amdsmi/src/rocm_smi_monitor.cc +++ b/projects/amdsmi/src/rocm_smi_monitor.cc @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) diff --git a/projects/amdsmi/src/rocm_smi_power_mon.cc b/projects/amdsmi/src/rocm_smi_power_mon.cc index 963a3723f0..cc8c177ce1 100755 --- a/projects/amdsmi/src/rocm_smi_power_mon.cc +++ b/projects/amdsmi/src/rocm_smi_power_mon.cc @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) diff --git a/projects/amdsmi/src/rocm_smi_utils.cc b/projects/amdsmi/src/rocm_smi_utils.cc index d44524325d..a069dfd822 100755 --- a/projects/amdsmi/src/rocm_smi_utils.cc +++ b/projects/amdsmi/src/rocm_smi_utils.cc @@ -1,6 +1,4 @@ /* - * ============================================================================= - * ROC Runtime Conformance Release License * ============================================================================= * The University of Illinois/NCSA * Open Source License (NCSA) diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.cc new file mode 100755 index 0000000000..15b90da948 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.cc @@ -0,0 +1,115 @@ +/* + * ============================================================================= + * The University of Illinois/NCSA + * Open Source License (NCSA) + * + * Copyright (c) 2019, 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 , + * 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. + * + */ + +#include +#include + +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/err_cnt_read.h" +#include "rocm_smi_test/test_common.h" + +TestErrCntRead::TestErrCntRead() : TestBase() { + set_title("RSMI Error Count Read Test"); + set_description("The Error Count Read tests verifies that error counts" + " can be read properly."); +} + +TestErrCntRead::~TestErrCntRead(void) { +} + +void TestErrCntRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestErrCntRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestErrCntRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestErrCntRead::Close() { + // This will close handles opened within rsmitst utility calls and call + // rsmi_shut_down(), so it should be done after other hsa cleanup + TestBase::Close(); +} + + +void TestErrCntRead::Run(void) { + rsmi_status_t err; + rsmi_error_count_t ec; + + TestBase::Run(); + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + for (uint32_t b = RSMI_GPU_BLOCK_FIRST; b <= RSMI_GPU_BLOCK_LAST; ++b) { + err = rsmi_dev_error_count_get(i, static_cast(b), &ec); + + if (err == RSMI_STATUS_NOT_SUPPORTED) { + std::cout << "\t**Error Count for " << + GetBlockNameStr(static_cast(b)) << + ": Not supported on this machine" << std::endl; + } else { + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Error counts for " << + GetBlockNameStr(static_cast(b)) << " block: " + << std::endl; + std::cout << "\t\tCorrectable errors: " << ec.correctable_err + << std::endl; + std::cout << "\t\tUncorrectable errors: " << ec.uncorrectable_err + << std::endl; + } + } + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.h new file mode 100755 index 0000000000..3653ebebe0 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/err_cnt_read.h @@ -0,0 +1,71 @@ +/* + * ============================================================================= + * The University of Illinois/NCSA + * Open Source License (NCSA) + * + * Copyright (c) 2019, 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 , + * 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 TESTS_ROCM_SMI_TEST_FUNCTIONAL_ERR_CNT_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_ERR_CNT_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestErrCntRead : public TestBase { + public: + TestErrCntRead(); + + // @Brief: Destructor for test case of TestErrCntRead + virtual ~TestErrCntRead(); + + // @Brief: Setup the environment for measurement + virtual void SetUp(); + + // @Brief: Core measurement execution + virtual void Run(); + + // @Brief: Clean up and retrive the resource + virtual void Close(); + + // @Brief: Display results + virtual void DisplayResults() const; + + // @Brief: Display information about what this test does + virtual void DisplayTestInfo(void); +}; + +#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_ERR_CNT_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc index bcdc68f39c..755cfb5901 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read.cc @@ -85,7 +85,7 @@ void TestFrequenciesRead::Close() { } -static void print_frequencies(rsmi_frequencies *f, uint32_t *l = nullptr) { +static void print_frequencies(rsmi_frequencies_t *f, uint32_t *l = nullptr) { assert(f != nullptr); for (uint32_t j = 0; j < f->num_supported; ++j) { std::cout << "\t** " << j << ": " << f->frequency[j]; @@ -104,8 +104,8 @@ static void print_frequencies(rsmi_frequencies *f, uint32_t *l = nullptr) { void TestFrequenciesRead::Run(void) { rsmi_status_t err; - rsmi_frequencies f; - rsmi_pcie_bandwidth b; + rsmi_frequencies_t f; + rsmi_pcie_bandwidth_t b; TestBase::Run(); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc index c52357aa27..3b8f8999f1 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/frequencies_read_write.cc @@ -91,7 +91,7 @@ void TestFrequenciesReadWrite::Close() { void TestFrequenciesReadWrite::Run(void) { rsmi_status_t ret; - rsmi_frequencies f; + rsmi_frequencies_t f; uint32_t freq_bitmask; rsmi_clk_type rsmi_clk; diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.cc new file mode 100755 index 0000000000..99cb017cd3 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.cc @@ -0,0 +1,140 @@ +/* + * ============================================================================= + * The University of Illinois/NCSA + * Open Source License (NCSA) + * + * Copyright (c) 2019, 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 , + * 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. + * + */ + +#include +#include + +#include +#include +#include + +#include "gtest/gtest.h" +#include "rocm_smi/rocm_smi.h" +#include "rocm_smi_test/functional/mem_util_read.h" +#include "rocm_smi_test/test_common.h" + +TestMemUtilRead::TestMemUtilRead() : TestBase() { + set_title("Memory Utilization Read Test"); + set_description("The Memory Utilization Read tests verifies that " + "memory utilization can be read properly."); +} + +TestMemUtilRead::~TestMemUtilRead(void) { +} + +void TestMemUtilRead::SetUp(void) { + TestBase::SetUp(); + + return; +} + +void TestMemUtilRead::DisplayTestInfo(void) { + TestBase::DisplayTestInfo(); +} + +void TestMemUtilRead::DisplayResults(void) const { + TestBase::DisplayResults(); + return; +} + +void TestMemUtilRead::Close() { + // This will close handles opened within rsmitst utility calls and call + // rsmi_shut_down(), so it should be done after other hsa cleanup + TestBase::Close(); +} + +static const std::map + kDevMemoryTypeNameMap = { + {RSMI_MEM_TYPE_VRAM, "VRAM memory"}, + {RSMI_MEM_TYPE_VIS_VRAM, "Visible VRAM memory"}, + {RSMI_MEM_TYPE_GTT, "GTT memory"}, +}; + +void TestMemUtilRead::Run(void) { + rsmi_status_t err; + uint64_t total; + uint64_t usage; + + TestBase::Run(); + + auto err_chk = [&](const char *str) { + if (err != RSMI_STATUS_SUCCESS) { + if (err == RSMI_STATUS_FILE_ERROR) { + IF_VERB(STANDARD) { + std::cout << "\t** " << str << ": Not supported on this machine" + << std::endl; + } + } else { + CHK_ERR_ASRT(err) + } + } + }; + + for (uint32_t i = 0; i < num_monitor_devs(); ++i) { + PrintDeviceHeader(i); + + for (uint32_t mem_type = RSMI_MEM_TYPE_FIRST; + mem_type <= RSMI_MEM_TYPE_LAST; ++mem_type) { + err = rsmi_dev_memory_total_get(i, + static_cast(mem_type), &total); + err_chk("rsmi_dev_memory_total_get()"); + if (err != RSMI_STATUS_SUCCESS) { + return; + } + + err = rsmi_dev_memory_usage_get(i, + static_cast(mem_type), &usage); + err_chk("rsmi_dev_memory_usage_get()"); + if (err != RSMI_STATUS_SUCCESS) { + return; + } + + IF_VERB(STANDARD) { + std::cout << "\t**" << + kDevMemoryTypeNameMap.at(static_cast(mem_type)) << + " Utilization: " << (static_cast(usage)*100)/total << "% ("<< + usage << "/" << total << ")" << std::endl; + } + } + } +} diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.h b/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.h new file mode 100755 index 0000000000..2ed92b3711 --- /dev/null +++ b/projects/amdsmi/tests/rocm_smi_test/functional/mem_util_read.h @@ -0,0 +1,71 @@ +/* + * ============================================================================= + * The University of Illinois/NCSA + * Open Source License (NCSA) + * + * Copyright (c) 2019, 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 , + * 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 TESTS_ROCM_SMI_TEST_FUNCTIONAL_MEM_UTIL_READ_H_ +#define TESTS_ROCM_SMI_TEST_FUNCTIONAL_MEM_UTIL_READ_H_ + +#include "rocm_smi_test/test_base.h" + +class TestMemUtilRead : public TestBase { + public: + TestMemUtilRead(); + + // @Brief: Destructor for test case of TestMemUtilRead + virtual ~TestMemUtilRead(); + + // @Brief: Setup the environment for measurement + virtual void SetUp(); + + // @Brief: Core measurement execution + virtual void Run(); + + // @Brief: Clean up and retrive the resource + virtual void Close(); + + // @Brief: Display results + virtual void DisplayResults() const; + + // @Brief: Display information about what this test does + virtual void DisplayTestInfo(void); +}; + +#endif // TESTS_ROCM_SMI_TEST_FUNCTIONAL_MEM_UTIL_READ_H_ diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/pci_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/pci_read_write.cc index c69abfa952..6e63e495a4 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/pci_read_write.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/pci_read_write.cc @@ -87,7 +87,7 @@ void TestPciReadWrite::Close() { void TestPciReadWrite::Run(void) { rsmi_status_t ret; - rsmi_pcie_bandwidth bw; + rsmi_pcie_bandwidth_t bw; uint32_t freq_bitmask; uint64_t sent, received, max_pkt_sz; diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc index 303bdd1592..4dfb78c54e 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read.cc @@ -87,7 +87,7 @@ void TestPerfLevelRead::Close() { void TestPerfLevelRead::Run(void) { rsmi_status_t err; - rsmi_dev_perf_level pfl; + rsmi_dev_perf_level_t pfl; TestBase::Run(); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc index 8d3ca30016..26aa43dfe2 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_level_read_write.cc @@ -54,7 +54,8 @@ #include "rocm_smi_test/functional/perf_level_read_write.h" #include "rocm_smi_test/test_common.h" -static const std::map kDevPerfLvlNameMap = { +static const std::map + kDevPerfLvlNameMap = { {RSMI_DEV_PERF_LEVEL_AUTO, "RSMI_DEV_PERF_LEVEL_AUTO"}, {RSMI_DEV_PERF_LEVEL_LOW, "RSMI_DEV_PERF_LEVEL_LOW"}, {RSMI_DEV_PERF_LEVEL_HIGH, "RSMI_DEV_PERF_LEVEL_HIGH"}, @@ -102,7 +103,7 @@ void TestPerfLevelReadWrite::Close() { void TestPerfLevelReadWrite::Run(void) { rsmi_status_t ret; - rsmi_dev_perf_level pfl, orig_pfl; + rsmi_dev_perf_level_t pfl, orig_pfl; TestBase::Run(); @@ -125,11 +126,11 @@ void TestPerfLevelReadWrite::Run(void) { IF_VERB(STANDARD) { std::cout << "Set Performance Level to " << - kDevPerfLvlNameMap.at(static_cast(pfl_i)) << + kDevPerfLvlNameMap.at(static_cast(pfl_i)) << " ..." << std::endl; } ret = rsmi_dev_perf_level_set(dv_ind, - static_cast(pfl_i)); + static_cast(pfl_i)); CHK_ERR_ASRT(ret) ret = rsmi_dev_perf_level_get(dv_ind, &pfl); CHK_ERR_ASRT(ret) diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc index cf29e8f069..32fbc32454 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/power_read_write.cc @@ -88,7 +88,7 @@ void TestPowerReadWrite::Close() { } static const char * -power_profile_string(rsmi_power_profile_preset_masks profile) { +power_profile_string(rsmi_power_profile_preset_masks_t profile) { switch (profile) { case RSMI_PWR_PROF_PRST_CUSTOM_MASK: return "CUSTOM"; @@ -111,7 +111,7 @@ power_profile_string(rsmi_power_profile_preset_masks profile) { void TestPowerReadWrite::Run(void) { rsmi_status_t ret; - rsmi_power_profile_status status; + rsmi_power_profile_status_t status; TestBase::Run(); @@ -127,7 +127,7 @@ void TestPowerReadWrite::Run(void) { while (tmp <= RSMI_PWR_PROF_PRST_LAST) { if ((tmp & status.available_profiles) == tmp) { std::cout << "\t" << - power_profile_string((rsmi_power_profile_preset_masks)tmp) << + power_profile_string((rsmi_power_profile_preset_masks_t)tmp) << std::endl; } tmp = tmp << 1; @@ -136,11 +136,11 @@ void TestPowerReadWrite::Run(void) { power_profile_string(status.current) << std::endl; } - rsmi_power_profile_preset_masks orig_profile = status.current; + rsmi_power_profile_preset_masks_t orig_profile = status.current; // Try setting the profile to a different power profile - rsmi_bit_field diff_profiles; - rsmi_power_profile_preset_masks new_prof; + rsmi_bit_field_t diff_profiles; + rsmi_power_profile_preset_masks_t new_prof; diff_profiles = status.available_profiles & (~status.current); if (diff_profiles & RSMI_PWR_PROF_PRST_COMPUTE_MASK) { @@ -162,7 +162,7 @@ void TestPowerReadWrite::Run(void) { ret = rsmi_dev_power_profile_set(dv_ind, 0, new_prof); CHK_ERR_ASRT(ret) - rsmi_dev_perf_level pfl; + rsmi_dev_perf_level_t pfl; ret = rsmi_dev_perf_level_get(dv_ind, &pfl); CHK_ERR_ASRT(ret) ASSERT_EQ(pfl, RSMI_DEV_PERF_LEVEL_MANUAL); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/sys_info_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/sys_info_read.cc index e4047f9679..50bd97a0bf 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/sys_info_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/sys_info_read.cc @@ -89,7 +89,7 @@ void TestSysInfoRead::Run(void) { rsmi_status_t err; uint64_t val_ui64; char buffer[80]; - rsmi_version ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; + rsmi_version_t ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; TestBase::Run(); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc index f85baa101b..9f04a0deeb 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/temp_read.cc @@ -94,7 +94,7 @@ void TestTempRead::Run(void) { for (uint32_t i = 0; i < num_monitor_devs(); ++i) { PrintDeviceHeader(i); - auto print_temp_metric = [&](rsmi_temperature_metric met, + auto print_temp_metric = [&](rsmi_temperature_metric_t met, std::string label) { err = rsmi_dev_temp_metric_get(i, 0, met, &val_i64); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/version_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/version_read.cc index 15e8eaa516..5e819a19bd 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/version_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/version_read.cc @@ -86,7 +86,7 @@ void TestVersionRead::Close() { void TestVersionRead::Run(void) { rsmi_status_t err; - rsmi_version ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; + rsmi_version_t ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; TestBase::Run(); diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc index 0039158d7b..4f99880c2d 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/volt_freq_curv_read.cc @@ -100,7 +100,7 @@ static void pt_rng_mV(std::string title, rsmi_range *r) { " mV" << std::endl; } -static void print_pnt(rsmi_od_vddc_point *pt) { +static void print_pnt(rsmi_od_vddc_point_t *pt) { std::cout << "\t\t** Frequency: " << pt->frequency/1000000 << "MHz" << std::endl; std::cout << "\t\t** Voltage: " << pt->voltage << "mV" << std::endl; @@ -113,7 +113,7 @@ static void pt_vddc_curve(rsmi_od_volt_curve *c) { } } -static void print_rsmi_od_volt_freq_data(rsmi_od_volt_freq_data *odv) { +static void print_rsmi_od_volt_freq_data_t(rsmi_od_volt_freq_data_t *odv) { assert(odv != nullptr); std::cout.setf(std::ios::dec, std::ios::basefield); @@ -131,13 +131,13 @@ static void print_rsmi_od_volt_freq_data(rsmi_od_volt_freq_data *odv) { odv->num_regions << std::endl; } -static void print_odv_region(rsmi_freq_volt_region *region) { +static void print_odv_region(rsmi_freq_volt_region_t *region) { pt_rng_Mhz("\t\tFrequency range:", ®ion->freq_range); pt_rng_mV("\t\tVoltage range:", ®ion->volt_range); } static void print_rsmi_od_volt_freq_regions(uint32_t num_regions, - rsmi_freq_volt_region *regions) { + rsmi_freq_volt_region_t *regions) { for (uint32_t i = 0; i < num_regions; ++i) { std::cout << "\tRegion " << i << ":" << std::endl; print_odv_region(®ions[i]); @@ -146,7 +146,7 @@ static void print_rsmi_od_volt_freq_regions(uint32_t num_regions, void TestVoltCurvRead::Run(void) { rsmi_status_t err; - rsmi_od_volt_freq_data odv; + rsmi_od_volt_freq_data_t odv; TestBase::Run(); @@ -167,11 +167,11 @@ void TestVoltCurvRead::Run(void) { if (err == RSMI_STATUS_SUCCESS) { std::cout << "\t**Frequency-voltage curve data:" << std::endl; - print_rsmi_od_volt_freq_data(&odv); + print_rsmi_od_volt_freq_data_t(&odv); - rsmi_freq_volt_region *regions; + rsmi_freq_volt_region_t *regions; uint32_t num_regions; - regions = new rsmi_freq_volt_region[odv.num_regions]; + regions = new rsmi_freq_volt_region_t[odv.num_regions]; ASSERT_TRUE(regions != nullptr); num_regions = odv.num_regions; diff --git a/projects/amdsmi/tests/rocm_smi_test/main.cc b/projects/amdsmi/tests/rocm_smi_test/main.cc index 0ff9b48307..315345dfa0 100755 --- a/projects/amdsmi/tests/rocm_smi_test/main.cc +++ b/projects/amdsmi/tests/rocm_smi_test/main.cc @@ -68,6 +68,8 @@ #include "functional/power_read_write.h" #include "functional/power_cap_read_write.h" #include "functional/version_read.h" +#include "functional/err_cnt_read.h" +#include "functional/mem_util_read.h" static RSMITstGlobals *sRSMIGlvalues = nullptr; @@ -181,7 +183,14 @@ TEST(rsmitstReadWrite, TestPowerCapReadWrite) { TestPowerCapReadWrite tst; RunGenericTest(&tst); } - +TEST(rsmitstReadOnly, TestErrCntRead) { + TestErrCntRead tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadOnly, TestMemUtilRead) { + TestMemUtilRead tst; + RunGenericTest(&tst); +} int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.cc b/projects/amdsmi/tests/rocm_smi_test/test_common.cc index 4869cbf158..39a4ad7aa3 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.cc +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.cc @@ -49,9 +49,17 @@ #include #include +#include #include "rocm_smi_test/test_base.h" #include "rocm_smi_test/test_common.h" +#include "rocm_smi/rocm_smi.h" + +static const std::map kBlockNameMap = { + {RSMI_GPU_BLOCK_UMC, "UMC"}, + {RSMI_GPU_BLOCK_SDMA, "SDMA"}, + {RSMI_GPU_BLOCK_GFX, "GFX"}, +}; static const struct option long_options[] = { {"iterations", required_argument, nullptr, 'i'}, @@ -123,6 +131,12 @@ uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list) { return 0; } +const char *GetBlockNameStr(rsmi_gpu_block_t id) { + return kBlockNameMap.at(id); +} + + + #if ENABLE_SMI void DumpMonitorInfo(const TestBase *test) { int ret = 0; diff --git a/projects/amdsmi/tests/rocm_smi_test/test_common.h b/projects/amdsmi/tests/rocm_smi_test/test_common.h index 5769153f05..5228ff441c 100755 --- a/projects/amdsmi/tests/rocm_smi_test/test_common.h +++ b/projects/amdsmi/tests/rocm_smi_test/test_common.h @@ -48,9 +48,8 @@ #include #include -#if ENABLE_SMI + #include "rocm_smi/rocm_smi.h" -#endif struct RSMITstGlobals { uint32_t verbosity; @@ -62,6 +61,7 @@ struct RSMITstGlobals { uint32_t ProcessCmdline(RSMITstGlobals* test, int arg_cnt, char** arg_list); void PrintTestHeader(uint32_t dv_ind); +const char *GetBlockNameStr(rsmi_gpu_block_t id); #if ENABLE_SMI void DumpMonitorInfo(const TestBase *test);