From 62ce965409ee11a0c9e9c2f9c6575f5007a07815 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Thu, 25 May 2023 13:03:30 -0500 Subject: [PATCH 1/2] Clean up the APIs Remove and rename APIs after review. Change-Id: I5464f200eb605b366673f8abca95183c3837843b --- example/amd_smi_drm_example.cc | 6 +- example/amd_smi_nodrm_example.cc | 6 +- include/amd_smi/amdsmi.h | 429 +----------------- rocm_smi/src/rocm_smi_gpu_metrics.cc | 4 +- src/amd_smi/amd_smi.cc | 200 +------- .../functional/api_support_read.cc | 89 ---- .../amd_smi_test/functional/gpu_busy_read.cc | 23 - tests/amd_smi_test/functional/id_info_read.cc | 18 +- .../amd_smi_test/functional/mem_util_read.cc | 11 - .../functional/mutual_exclusion.cc | 9 +- .../amd_smi_test/functional/sys_info_read.cc | 6 +- tests/amd_smi_test/functional/version_read.cc | 20 +- tests/amd_smi_test/test_common.h | 2 +- 13 files changed, 34 insertions(+), 789 deletions(-) diff --git a/example/amd_smi_drm_example.cc b/example/amd_smi_drm_example.cc index f67895cc7d..7d12be4ba8 100644 --- a/example/amd_smi_drm_example.cc +++ b/example/amd_smi_drm_example.cc @@ -59,7 +59,7 @@ const char *err_str; \ std::cout << "AMDSMI call returned " << RET << " at line " \ << __LINE__ << std::endl; \ - amdsmi_status_string(RET, &err_str); \ + amdsmi_status_code_to_string(RET, &err_str); \ std::cout << err_str << std::endl; \ return RET; \ } \ @@ -478,9 +478,9 @@ int main() { // Get ECC error counts amdsmi_error_count_t err_cnt_info = {}; - ret = amdsmi_get_gpu_ecc_error_count(processor_handles[j], &err_cnt_info); + ret = amdsmi_get_gpu_total_ecc_count(processor_handles[j], &err_cnt_info); CHK_AMDSMI_RET(ret) - printf(" Output of amdsmi_get_gpu_ecc_error_count:\n"); + printf(" Output of amdsmi_get_gpu_total_ecc_count:\n"); printf("\tCorrectable errors: %lu\n", err_cnt_info.correctable_count); printf("\tUncorrectable errors: %lu\n\n", err_cnt_info.uncorrectable_count); diff --git a/example/amd_smi_nodrm_example.cc b/example/amd_smi_nodrm_example.cc index 7222bdf339..51bc2ff1b9 100644 --- a/example/amd_smi_nodrm_example.cc +++ b/example/amd_smi_nodrm_example.cc @@ -57,7 +57,7 @@ const char *err_str; \ std::cout << "AMDSMI call returned " << RET << " at line " \ << __LINE__ << std::endl; \ - amdsmi_status_string(RET, &err_str); \ + amdsmi_status_code_to_string(RET, &err_str); \ std::cout << err_str << std::endl; \ return RET; \ } \ @@ -269,9 +269,9 @@ int main() { // Get ECC error counts amdsmi_error_count_t err_cnt_info = {}; - ret = amdsmi_get_gpu_ecc_error_count(processor_handles[j], &err_cnt_info); + ret = amdsmi_get_gpu_total_ecc_count(processor_handles[j], &err_cnt_info); CHK_AMDSMI_RET(ret) - printf(" Output of amdsmi_get_gpu_ecc_error_count:\n"); + printf(" Output of amdsmi_get_gpu_total_ecc_count:\n"); printf("\tCorrectable errors: %lu\n", err_cnt_info.correctable_count); printf("\tUncorrectable errors: %lu\n\n", err_cnt_info.uncorrectable_count); diff --git a/include/amd_smi/amdsmi.h b/include/amd_smi/amdsmi.h index 7618ab6477..69cdefd1ea 100644 --- a/include/amd_smi/amdsmi.h +++ b/include/amd_smi/amdsmi.h @@ -433,16 +433,6 @@ typedef enum { * @brief Available clock types. */ -/** - * @brief Software components - */ -typedef enum { - AMDSMI_SW_COMP_FIRST = 0x0, - - AMDSMI_SW_COMP_DRIVER = AMDSMI_SW_COMP_FIRST, //!< Driver - - AMDSMI_SW_COMP_LAST = AMDSMI_SW_COMP_DRIVER -} amdsmi_sw_component_t; /** * Event counter types @@ -1064,41 +1054,10 @@ typedef struct { uint32_t cu_occupancy; //!< Compute Unit usage in percent } amdsmi_process_info_t; -/** - * @brief Opaque handle to function-support object - */ -typedef struct amdsmi_func_id_iter_handle * amdsmi_func_id_iter_handle_t; - //! Place-holder "variant" for functions that have don't have any variants, //! but do have monitors or sensors. #define AMDSMI_DEFAULT_VARIANT 0xFFFFFFFFFFFFFFFF -/** - * @brief This union holds the value of an ::amdsmi_func_id_iter_handle_t. The - * value may be a function name, or an ennumerated variant value of types - * such as ::amdsmi_memory_type_t, ::amdsmi_temperature_metric_t, etc. - */ -typedef union { - uint64_t id; //!< uint64_t representation of value - const char *name; //!< name string (applicable to functions only) - union { - //!< Used for ::amdsmi_memory_type_t variants - amdsmi_memory_type_t memory_type; - //!< Used for ::amdsmi_temperature_metric_t variants - amdsmi_temperature_metric_t temp_metric; - //!< Used for ::amdsmi_event_type_t variants - amdsmi_event_type_t evnt_type; - //!< Used for ::amdsmi_event_group_t variants - amdsmi_event_group_t evnt_group; - //!< Used for ::amdsmi_clk_type_t variants - amdsmi_clk_type_t clk_type; - //!< Used for ::amdsmi_fw_block_t variants - amdsmi_fw_block_t fw_block; - //!< Used for ::amdsmi_gpu_block_t variants - amdsmi_gpu_block_t gpu_block_type; - }; -} amdsmi_func_id_value_t; - /*****************************************************************************/ /** @defgroup InitShutAdmin Initialization and Shutdown * These functions are used for initialization of AMD SMI and clean up when done. @@ -1273,7 +1232,7 @@ amdsmi_status_t amdsmi_get_processor_handle_from_bdf(amdsmi_bdf_t bdf, amdsmi_pr * @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. amdsmi_get_gpu_pci_id() should be used to get a + * one device from another. admsmi_get_gpu_bdf_id() should be used to get a * unique identifier. * * @param[in] processor_handle a processor handle @@ -1403,22 +1362,6 @@ amdsmi_status_t amdsmi_get_gpu_subsystem_id(amdsmi_processor_handle processor_ha amdsmi_status_t amdsmi_get_gpu_subsystem_name(amdsmi_processor_handle processor_handle, char *name, size_t len); -/** - * @brief Get the drm minor number associated with this device - * - * @details Given a processor handle @p processor_handle, find its render device file - * /dev/dri/renderDN where N corresponds to its minor number. - * - * @param[in] processor_handle a processor handle - * - * @param[in,out] minor a pointer to a uint32_t into which minor number will - * be copied - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_get_gpu_drm_render_minor(amdsmi_processor_handle processor_handle, uint32_t *minor); - /** @} End IDQuer */ /*****************************************************************************/ @@ -1478,7 +1421,7 @@ amdsmi_get_gpu_pci_bandwidth(amdsmi_processor_handle processor_handle, amdsmi_pc * * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ -amdsmi_status_t amdsmi_get_gpu_pci_id(amdsmi_processor_handle processor_handle, uint64_t *bdfid); +amdsmi_status_t admsmi_get_gpu_bdf_id(amdsmi_processor_handle processor_handle, uint64_t *bdfid); /** * @brief Get the NUMA node associated with a device @@ -1732,12 +1675,13 @@ amdsmi_get_gpu_memory_usage(amdsmi_processor_handle processor_handle, amdsmi_mem uint64_t *used); /** - * @brief The first call to this API returns the number of bad pages which - * should be used to allocate the buffer that should contain the bad page - * records. + * @brief Get the bad pages of a processor. * @details This call will query the device @p processor_handle for the * number of bad pages (written to @p num_pages address). The results are * written to address held by the @p info pointer. + * The first call to this API returns the number of bad pages which + * should be used to allocate the buffer that should contain the bad page + * records. * @param[in] processor_handle a processor handle * @param[out] num_pages Number of bad page records. * @param[out] info The results will be written to the @@ -1772,27 +1716,6 @@ amdsmi_status_t amdsmi_get_gpu_ras_block_features_enabled(amdsmi_processor_handle processor_handle, amdsmi_gpu_block_t block, amdsmi_ras_err_state_t *state); -/** - * @brief Get percentage of time any device memory is being used - * - * @details Given a processor handle @p processor_handle, this function returns the - * percentage of time that any device memory is being used for the specified - * device. - * - * @param[in] processor_handle a processor handle - * - * @param[in,out] busy_percent a pointer to the uint32_t to which the busy - * percent will be written - * If this parameter is nullptr, this function will return - * ::AMDSMI_STATUS_INVAL if the function is supported with the provided, - * arguments and ::AMDSMI_STATUS_NOT_SUPPORTED if it is not supported with the - * provided arguments. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_get_gpu_memory_busy_percent(amdsmi_processor_handle processor_handle, uint32_t *busy_percent); - /** * @brief Get information about reserved ("retired") memory pages * @@ -2024,28 +1947,6 @@ amdsmi_status_t amdsmi_set_gpu_fan_speed(amdsmi_processor_handle processor_handl * @{ */ -/** - * @brief Get percentage of time device is busy doing any processing - * - * @details Given a processor handle @p processor_handle, 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] processor_handle a processor handle - * - * @param[in,out] busy_percent a pointer to the uint32_t to which the busy - * percent will be written - * If this parameter is nullptr, this function will return - * ::AMDSMI_STATUS_INVAL if the function is supported with the provided, - * arguments and ::AMDSMI_STATUS_NOT_SUPPORTED if it is not supported with the - * provided arguments. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_get_busy_percent(amdsmi_processor_handle processor_handle, uint32_t *busy_percent); - /** * @brief Get coarse grain utilization counter of the specified device * @@ -2393,9 +2294,6 @@ amdsmi_status_t * @brief Set the PowerPlay performance level associated with the device with * provided processor handle with the provided value. * - * @deprecated :: amdsmi_set_gpu_perf_level_v1() is preferred, with an - * interface that more closely matches the rest of the amd_smi API. - * * @details Given a processor handle @p processor_handle and an ::amdsmi_dev_perf_level_t @p * perf_level, this function will set the PowerPlay performance level for the * device to the value @p perf_lvl. @@ -2411,32 +2309,10 @@ amdsmi_status_t amdsmi_status_t amdsmi_set_gpu_perf_level(amdsmi_processor_handle processor_handle, amdsmi_dev_perf_level_t perf_lvl); -/** - * @brief Set the PowerPlay performance level associated with the device with - * provided processor handle with the provided value. - * - * @details Given a processor handle @p processor_handle and an ::amdsmi_dev_perf_level_t @p - * perf_level, this function will set the PowerPlay performance level for the - * device to the value @p perf_lvl. - * - * @note This function requires root access - * - * @param[in] processor_handle a processor handle - * - * @param[in] perf_lvl the value to which the performance level should be set - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t - amdsmi_set_gpu_perf_level_v1(amdsmi_processor_handle processor_handle, amdsmi_dev_perf_level_t perf_lvl); - /** * @brief Set the overdrive percent associated with the device with provided * processor handle with the provided value. See details for WARNING. * - * @deprecated This function is deprecated. :: amdsmi_set_gpu_overdrive_level_v1 - * has the same functionaltiy, with an interface that more closely - * matches the rest of the amd_smi API. * * @details Given a processor handle @p processor_handle and an overdrive level @p od, * this function will set the overdrive level for the device to the value @@ -2471,45 +2347,6 @@ amdsmi_status_t */ amdsmi_status_t amdsmi_set_gpu_overdrive_level(amdsmi_processor_handle processor_handle, uint32_t od); -/** - * @brief Set the overdrive percent associated with the device with provided - * processor handle with the provided value. See details for WARNING. - * - * @details Given a processor handle @p processor_handle 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. - * - * @note This function requires root access - * - * @param[in] processor_handle a processor handle - * - * @param[in] od the value to which the overdrive level should be set - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_set_gpu_overdrive_level_v1(amdsmi_processor_handle processor_handle, uint32_t od); - /** * @brief Control the set of allowed frequencies that can be used for the * specified clock. @@ -2566,34 +2403,7 @@ amdsmi_status_t amdsmi_set_clk_freq(amdsmi_processor_handle processor_handle, * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t -amdsmi_get_version(amdsmi_version_t *version); - -/** - * @brief Get the driver version string for the current system. - * - * @details Given a software component @p component, a pointer to a char - * buffer, @p ver_str, this function will write the driver version string - * (up to @p len characters) for the current system to @p ver_str. The caller - * must ensure that it is safe to write at least @p len characters to @p - * ver_str. - * - * @param[in] component The component for which the version string is being - * requested - * - * @param[in,out] ver_str A pointer to a buffer of char's to which the version - * of @p component will be written - * - * @param[in] len the length of the caller provided buffer @p name. - * - * @note ::AMDSMI_STATUS_INSUFFICIENT_SIZE is returned if @p len bytes is not - * large enough to hold the entire name. In this case, only @p len bytes will - * be written. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_get_version_str(amdsmi_sw_component_t component, char *ver_str, - uint32_t len); +amdsmi_get_lib_version(amdsmi_version_t *version); /** @} End VersQuer */ @@ -2693,7 +2503,7 @@ amdsmi_status_t amdsmi_get_gpu_ecc_status(amdsmi_processor_handle processor_han * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t -amdsmi_status_string(amdsmi_status_t status, const char **status_string); +amdsmi_status_code_to_string(amdsmi_status_t status, const char **status_string); /** @} End ErrQuer */ @@ -3125,7 +2935,7 @@ amdsmi_topo_get_link_weight(amdsmi_processor_handle processor_handle_src, amdsmi * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t - amdsmi_get_minmax_bandwidth(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, + admsmi_get_minmax_bandwith_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, uint64_t *min_bandwidth, uint64_t *max_bandwidth); /** @@ -3179,223 +2989,6 @@ amdsmi_is_P2P_accessible(amdsmi_processor_handle processor_handle_src, amdsmi_pr /** @} End HWTopo */ -/*****************************************************************************/ -/** @defgroup APISupport Supported Functions - * API function support varies by both GPU type and the version of the - * installed ROCm stack. The functions described in this section can be used - * to determine, up front, which functions are supported for a given device - * on a system. If such "up front" knowledge of support for a function is not - * needed, alternatively, one can call a device related function and check the - * return code. - * - * Some functions have several variations ("variants") where some variants are - * supported and others are not. For example, on a given device, - * :: amdsmi_get_temp_metric may support some types of temperature metrics - * (e.g., ::AMDSMI_TEMP_CRITICAL_HYST), but not others - * (e.g., ::AMDSMI_TEMP_EMERGENCY). - * - * In addition to a top level of variant support for a function, a function - * may have varying support for monitors/sensors. These are considered - * "sub-variants" in functions described in this section. Continuing the - * :: amdsmi_get_temp_metric example, if variant - * ::AMDSMI_TEMP_CRITICAL_HYST is supported, perhaps - * only the sub-variant sensors ::AMDSMI_TEMP_TYPE_EDGE - * and ::AMDSMI_TEMP_TYPE_EDGE are supported, but not - * ::AMDSMI_TEMP_TYPE_MEMORY. - * - * In cases where a function takes in a sensor id parameter but does not have - * any "top level" variants, the functions in this section will indicate a - * default "variant", ::AMDSMI_DEFAULT_VARIANT, for the top level variant, and - * the various monitor support will be sub-variants of this. - * - * The functions in this section use the "iterator" concept to list which - * functions are supported; to list which variants of the supported functions - * are supported; and finally which monitors/sensors are supported for a - * variant. - * - * Here is example code that prints out all supported functions, their - * supported variants and sub-variants. Please see the related descriptions - * functions and AMDSMI types. - * @latexonly - * \pagebreak - * @endlatexonly - * @code{.cpp} - * amdsmi_func_id_iter_handle_t iter_handle, var_iter, sub_var_iter; - * amdsmi_func_id_value_t value; - * amdsmi_status_t err; - * amdsmi_processor_handle device; - * - * // Get the processor handle via amdsmi_get_processor_handles() - * // ... ... - * - * std::cout << "Supported AMDSMI Functions:" << std::endl; * - * err = amdsmi_open_supported_func_iterator(device, &iter_handle); - * - * while (1) { - * err = amdsmi_get_func_iter_value(iter_handle, &value); - * std::cout << "Function Name: " << value.name << std::endl; - * - * err = amdsmi_open_supported_variant_iterator(iter_handle, &var_iter); - * if (err != AMDSMI_STATUS_NO_DATA) { - * std::cout << "\tVariants/Monitors: "; - * while (1) { - * err = amdsmi_get_func_iter_value(var_iter, &value); - * if (value.id == AMDSMI_DEFAULT_VARIANT) { - * std::cout << "Default Variant "; - * } else { - * std::cout << value.id; - * } - * std::cout << " ("; - * - * err = - * amdsmi_open_supported_variant_iterator(var_iter, &sub_var_iter); - * if (err != AMDSMI_STATUS_NO_DATA) { - * - * while (1) { - * err = amdsmi_get_func_iter_value(sub_var_iter, &value); - * std::cout << value.id << ", "; - * - * err = amdsmi_next_func_iter(sub_var_iter); - * - * if (err == AMDSMI_STATUS_NO_DATA) { - * break; - * } - * } - * err = amdsmi_close_supported_func_iterator(&sub_var_iter); - * } - * - * std::cout << "), "; - * - * err = amdsmi_next_func_iter(var_iter); - * - * if (err == AMDSMI_STATUS_NO_DATA) { - * break; - * } - * } - * std::cout << std::endl; - * - * err = amdsmi_close_supported_func_iterator(&var_iter); - * } - * - * err = amdsmi_next_func_iter(iter_handle); - * - * if (err == AMDSMI_STATUS_NO_DATA) { - * break; - * } - * } - * err = amdsmi_close_supported_func_iterator(&iter_handle); - * } - * @endcode - * - * @{ - */ - -/** - * @brief Get a function name iterator of supported AMDSMI functions for a device - * - * @details Given a processor handle @p processor_handle, this function will write a function - * iterator handle to the caller-provided memory pointed to by @p handle. This - * handle can be used to iterate through all the supported functions. - * - * Note that although this function takes in @p processor_handle as an argument, - * ::amdsmi_open_supported_func_iterator itself will not be among the - * functions listed as supported. This is because - * ::amdsmi_open_supported_func_iterator does not depend on hardware or - * driver support and should always be supported. - * - * @param[in] processor_handle a processor handle of device for which support information is - * requested - * - * @param[in,out] handle A pointer to caller-provided memory to which the - * function iterator will be written. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_open_supported_func_iterator(amdsmi_processor_handle processor_handle, - amdsmi_func_id_iter_handle_t *handle); - -/** - * @brief Get a variant iterator for a given handle - * - * @details Given a ::amdsmi_func_id_iter_handle_t @p obj_h, this function will - * write a function iterator handle to the caller-provided memory pointed to - * by @p var_iter. This handle can be used to iterate through all the supported - * variants of the provided handle. @p obj_h may be a handle to a function - * object, as provided by a call to ::amdsmi_open_supported_func_iterator, or - * it may be a variant itself (from a call to - * ::amdsmi_open_supported_variant_iterator), it which case @p var_iter will - * be an iterator of the sub-variants of @p obj_h (e.g., monitors). - * - * This call allocates a small amount of memory to @p var_iter. To free this memory - * ::amdsmi_close_supported_func_iterator should be called on the returned - * iterator handle @p var_iter when it is no longer needed. - * - * @param[in] obj_h an iterator handle for which the variants are being requested - * - * @param[in,out] var_iter A pointer to caller-provided memory to which the - * sub-variant iterator will be written. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_open_supported_variant_iterator(amdsmi_func_id_iter_handle_t obj_h, - amdsmi_func_id_iter_handle_t *var_iter); - -/** - * @brief Advance a function identifer iterator - * - * @details Given a function id iterator handle (::amdsmi_func_id_iter_handle_t) - * @p handle, this function will increment the iterator to point to the next - * identifier. After a successful call to this function, obtaining the value - * of the iterator @p handle will provide the value of the next item in the - * list of functions/variants. - * - * If there are no more items in the list, ::AMDSMI_STATUS_NO_DATA is returned. - * - * @param[in] handle A pointer to an iterator handle to be incremented - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_next_func_iter(amdsmi_func_id_iter_handle_t handle); - -/** - * @brief Close a variant iterator handle - * - * @details Given a pointer to an ::amdsmi_func_id_iter_handle_t @p handle, this - * function will free the resources being used by the handle - * - * @param[in] handle A pointer to an iterator handle to be closed - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_close_supported_func_iterator(amdsmi_func_id_iter_handle_t *handle); - -/** - * @brief Get the value associated with a function/variant iterator - * - * @details Given an ::amdsmi_func_id_iter_handle_t @p handle, this function - * will write the identifier of the function/variant to the user provided - * memory pointed to by @p value. - * - * @p value may point to a function name, a variant id, or a monitor/sensor - * index, depending on what kind of iterator @p handle is - * - * @param[in] handle An iterator for which the value is being requested - * - * @param[in,out] value A pointer to an ::amdsmi_func_id_value_t provided by the - * caller to which this function will write the value assocaited with @p handle - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t -amdsmi_get_func_iter_value(amdsmi_func_id_iter_handle_t handle, - amdsmi_func_id_value_t *value); - -/** @} End APISupport */ - /*****************************************************************************/ /** @defgroup EvntNotif Event Notification Functions * These functions are used to configure for and get asynchronous event @@ -3799,7 +3392,7 @@ amdsmi_get_gpu_process_info(amdsmi_processor_handle processor_handle, amdsmi_pro */ /** - * @brief Returns the number of ECC errors (correctable and + * @brief Returns the total number of ECC errors (correctable and * uncorrectable) in the given GPU. * * @param[in] processor_handle Device which to query @@ -3810,7 +3403,7 @@ amdsmi_get_gpu_process_info(amdsmi_processor_handle processor_handle, amdsmi_pro * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t -amdsmi_get_gpu_ecc_error_count(amdsmi_processor_handle processor_handle, amdsmi_error_count_t *ec); +amdsmi_get_gpu_total_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_error_count_t *ec); /** @} End eccinfo */ diff --git a/rocm_smi/src/rocm_smi_gpu_metrics.cc b/rocm_smi/src/rocm_smi_gpu_metrics.cc index 7c8f6bf163..801030d6eb 100755 --- a/rocm_smi/src/rocm_smi_gpu_metrics.cc +++ b/rocm_smi/src/rocm_smi_gpu_metrics.cc @@ -129,8 +129,8 @@ typedef struct { /* Voltage (mV) */ uint16_t voltage_soc; - uint16_t voltage_gfx; - uint16_t voltage_mem; + uint16_t gfx_voltage; + uint16_t mem_voltage; uint16_t padding1; diff --git a/src/amd_smi/amd_smi.cc b/src/amd_smi/amd_smi.cc index 87ff9f566a..282913d300 100644 --- a/src/amd_smi/amd_smi.cc +++ b/src/amd_smi/amd_smi.cc @@ -138,7 +138,7 @@ amdsmi_shut_down() { } amdsmi_status_t -amdsmi_status_string(amdsmi_status_t status, const char **status_string) { +amdsmi_status_code_to_string(amdsmi_status_t status, const char **status_string) { switch (status) { case AMDSMI_STATUS_FAIL_LOAD_MODULE: *status_string = "FAIL_LOAD_MODULE: Fail to load module."; @@ -667,7 +667,7 @@ amdsmi_topo_get_link_weight(amdsmi_processor_handle processor_handle_src, amdsmi } amdsmi_status_t - amdsmi_get_minmax_bandwidth(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, + admsmi_get_minmax_bandwith_between_processors(amdsmi_processor_handle processor_handle_src, amdsmi_processor_handle processor_handle_dst, uint64_t *min_bandwidth, uint64_t *max_bandwidth) { AMDSMI_CHECK_INIT(); @@ -743,145 +743,6 @@ amdsmi_reset_gpu_xgmi_error(amdsmi_processor_handle processor_handle) { return rsmi_wrapper(rsmi_dev_xgmi_error_reset, processor_handle); } -amdsmi_status_t -amdsmi_open_supported_func_iterator(amdsmi_processor_handle processor_handle, - amdsmi_func_id_iter_handle_t *handle) { - AMDSMI_CHECK_INIT(); - - if (handle == nullptr) - return AMDSMI_STATUS_INVAL; - return rsmi_wrapper(rsmi_dev_supported_func_iterator_open, processor_handle, - reinterpret_cast(handle)); -} - -amdsmi_status_t -amdsmi_open_supported_variant_iterator(amdsmi_func_id_iter_handle_t obj_h, - amdsmi_func_id_iter_handle_t *var_iter) { - AMDSMI_CHECK_INIT(); - - if (var_iter == nullptr) - return AMDSMI_STATUS_INVAL; - auto r = rsmi_dev_supported_variant_iterator_open( - reinterpret_cast(obj_h), - reinterpret_cast(var_iter)); - return amd::smi::rsmi_to_amdsmi_status(r); -} - -amdsmi_status_t -amdsmi_next_func_iter(amdsmi_func_id_iter_handle_t handle) { - AMDSMI_CHECK_INIT(); - - auto r = rsmi_func_iter_next( - reinterpret_cast(handle)); - return amd::smi::rsmi_to_amdsmi_status(r); -} - -amdsmi_status_t -amdsmi_close_supported_func_iterator(amdsmi_func_id_iter_handle_t *handle) { - AMDSMI_CHECK_INIT(); - - if (handle == nullptr) - return AMDSMI_STATUS_INVAL; - auto r = rsmi_dev_supported_func_iterator_close( - reinterpret_cast(handle)); - return amd::smi::rsmi_to_amdsmi_status(r); -} - -amdsmi_status_t -amdsmi_get_func_iter_value(amdsmi_func_id_iter_handle_t handle, - amdsmi_func_id_value_t *value) { - - AMDSMI_CHECK_INIT(); - - if (value == nullptr) - return AMDSMI_STATUS_INVAL; - - static const std::map rsmi_2_amdsmi = { - {"rsmi_dev_vram_vendor_get", "amdsmi_get_gpu_vram_vendor"}, - {"rsmi_dev_id_get", "amdsmi_get_gpu_id"}, - {"rsmi_dev_vendor_id_get", "amdsmi_get_gpu_asic_info"}, - {"rsmi_dev_name_get", "amdsmi_get_gpu_board_info"}, - {"rsmi_dev_sku_get", "amdsmi_get_gpu_board_info"}, - {"rsmi_dev_brand_get", "amdsmi_get_gpu_asic_info"}, - {"rsmi_dev_vendor_name_get", "amdsmi_get_gpu_vendor_name"}, - {"rsmi_dev_serial_number_get", "amdsmi_get_gpu_asic_info"}, - {"rsmi_dev_subsystem_id_get", "amdsmi_get_gpu_subsystem_id"}, - {"rsmi_dev_subsystem_name_get", "amdsmi_get_gpu_subsystem_name"}, - {"rsmi_dev_drm_render_minor_get", "amdsmi_get_gpu_drm_render_minor"}, - {"rsmi_dev_subsystem_vendor_id_get", "amdsmi_get_gpu_asic_info"}, - {"rsmi_dev_unique_id_get", "amdsmi_get_gpu_board_info"}, - {"rsmi_dev_pci_bandwidth_get", "amdsmi_get_gpu_pci_bandwidth"}, - {"rsmi_dev_pci_id_get", "amdsmi_get_gpu_pci_id"}, - {"rsmi_dev_pci_throughput_get", "amdsmi_get_gpu_pci_throughput"}, - {"rsmi_dev_pci_replay_counter_get", " amdsmi_get_gpu_pci_replay_counter"}, - {"rsmi_dev_pci_bandwidth_set", " amdsmi_set_gpu_pci_bandwidth"}, - {"rsmi_dev_power_profile_set", " amdsmi_set_gpu_power_profile"}, - {"rsmi_dev_memory_busy_percent_get", "amdsmi_get_gpu_memory_busy_percent"}, - {"rsmi_dev_busy_percent_get", "amdsmi_get_busy_percent"}, - {"rsmi_dev_memory_reserved_pages_get", "amdsmi_get_gpu_memory_reserved_pages"}, - {"rsmi_dev_overdrive_level_get", "amdsmi_get_gpu_overdrive_level"}, - {"rsmi_dev_power_profile_presets_get", " amdsmi_get_gpu_power_profile_presets"}, - {"rsmi_dev_perf_level_set", " amdsmi_set_gpu_perf_level"}, - {"rsmi_dev_perf_level_set_v1", " amdsmi_set_gpu_perf_level_v1"}, - {"rsmi_dev_perf_level_get", "amdsmi_get_gpu_perf_level"}, - {"rsmi_perf_determinism_mode_set", "amdsmi_set_gpu_perf_determinism_mode"}, - {"rsmi_dev_overdrive_level_set", " amdsmi_set_gpu_overdrive_level"}, - {"rsmi_dev_vbios_version_get", "amdsmi_get_gpu_vbios_info"}, - {"rsmi_dev_od_volt_info_get", " amdsmi_get_gpu_od_volt_info"}, - {"rsmi_dev_od_volt_info_set", " amdsmi_set_gpu_od_volt_info"}, - {"rsmi_dev_od_volt_curve_regions_get", " amdsmi_get_gpu_od_volt_curve_regions"}, - {"rsmi_dev_ecc_enabled_get", " amdsmi_get_gpu_ecc_enabled"}, - {"rsmi_dev_ecc_status_get", " amdsmi_get_gpu_ecc_status"}, - {"rsmi_dev_counter_group_supported", "amdsmi_gpu_counter_group_supported"}, - {"rsmi_dev_counter_create", "amdsmi_gpu_create_counter"}, - {"rsmi_dev_xgmi_error_status", "amdsmi_gpu_xgmi_error_status"}, - {"rsmi_dev_xgmi_error_reset", "amdsmi_reset_gpu_xgmi_error"}, - {"rsmi_dev_memory_reserved_pages_get", "amdsmi_get_gpu_memory_reserved_pages"}, - {"rsmi_topo_numa_affinity_get", "amdsmi_get_gpu_topo_numa_affinity"}, - {"rsmi_dev_gpu_metrics_info_get", " amdsmi_get_gpu_metrics_info"}, - {"rsmi_dev_gpu_reset", "amdsmi_reset_gpu"}, - {"rsmi_dev_memory_total_get", "amdsmi_get_gpu_memory_total"}, - {"rsmi_dev_memory_usage_get", "amdsmi_get_gpu_memory_usage"}, - {"rsmi_dev_gpu_clk_freq_get", " amdsmi_get_clk_freq"}, - {"rsmi_dev_gpu_clk_freq_set", " amdsmi_set_clk_freq"}, - {"rsmi_dev_firmware_version_get", "amdsmi_get_fw_info"}, - {"rsmi_dev_ecc_count_get", " amdsmi_get_gpu_ecc_count"}, - {"rsmi_counter_available_counters_get", " amdsmi_get_gpu_available_counters"}, - {"rsmi_dev_power_cap_get", "amdsmi_get_power_cap_info"}, - {"rsmi_dev_power_cap_default_get", "amdsmi_get_power_cap_info"}, - {"rsmi_dev_power_cap_range_get", "amdsmi_get_power_cap_info"}, - {"rsmi_dev_power_cap_set", " amdsmi_set_power_cap"}, - {"rsmi_dev_fan_rpms_get", "amdsmi_get_gpu_fan_rpms"}, - {"rsmi_dev_fan_speed_get", "amdsmi_get_gpu_fan_speed"}, - {"rsmi_dev_fan_speed_max_get", "amdsmi_get_gpu_fan_speed_max"}, - {"rsmi_dev_temp_metric_get", " amdsmi_get_temp_metric"}, - {"rsmi_dev_fan_reset", "amdsmi_reset_gpu_fan"}, - {"rsmi_dev_fan_speed_set", "amdsmi_set_gpu_fan_speed"}, - {"rsmi_dev_volt_metric_get", " amdsmi_get_gpu_volt_metric"} - }; - - auto rocm_func_handle = - reinterpret_cast(handle); - - auto r = rsmi_func_iter_value_get( - rocm_func_handle, - reinterpret_cast(value)); - - if ( r != RSMI_STATUS_SUCCESS ) - return amd::smi::rsmi_to_amdsmi_status(r); - - // Only change the function name, FUNC_ITER == 0 - if (rocm_func_handle->id_type != 0) - return amd::smi::rsmi_to_amdsmi_status(r); - - auto iter = rsmi_2_amdsmi.find(value->name); - if (iter != rsmi_2_amdsmi.end()) { - value->name = (*iter).second; - } - - return amd::smi::rsmi_to_amdsmi_status(r); -} - amdsmi_status_t amdsmi_get_gpu_compute_process_info(amdsmi_process_info_t *procs, uint32_t *num_items) { AMDSMI_CHECK_INIT(); @@ -947,16 +808,6 @@ amdsmi_status_t amdsmi_get_gpu_ecc_status(amdsmi_processor_handle processor_han reinterpret_cast(state)); } -amdsmi_status_t -amdsmi_get_busy_percent(amdsmi_processor_handle processor_handle, - uint32_t *busy_percent) { - AMDSMI_CHECK_INIT(); - - if (busy_percent == nullptr) - return AMDSMI_STATUS_INVAL; - return rsmi_wrapper(rsmi_dev_busy_percent_get, processor_handle, - busy_percent); -} amdsmi_status_t amdsmi_get_gpu_metrics_info( amdsmi_processor_handle processor_handle, amdsmi_gpu_metrics_t *pgpu_metrics) { @@ -1076,13 +927,6 @@ amdsmi_status_t amdsmi_get_gpu_perf_level(amdsmi_processor_handle processor_hand amdsmi_status_t amdsmi_set_gpu_perf_level(amdsmi_processor_handle processor_handle, amdsmi_dev_perf_level_t perf_lvl) { - return rsmi_wrapper(rsmi_dev_perf_level_set, processor_handle, - static_cast(perf_lvl)); -} - -amdsmi_status_t - amdsmi_set_gpu_perf_level_v1(amdsmi_processor_handle processor_handle, - amdsmi_dev_perf_level_t perf_lvl) { return rsmi_wrapper(rsmi_dev_perf_level_set_v1, processor_handle, static_cast(perf_lvl)); } @@ -1186,7 +1030,7 @@ amdsmi_status_t amdsmi_get_gpu_overdrive_level( amdsmi_status_t amdsmi_set_gpu_overdrive_level( amdsmi_processor_handle processor_handle, uint32_t od) { - return rsmi_wrapper(rsmi_dev_overdrive_level_set, processor_handle, od); + return rsmi_wrapper(rsmi_dev_overdrive_level_set_v1, processor_handle, od); } amdsmi_status_t amdsmi_get_gpu_pci_replay_counter( amdsmi_processor_handle processor_handle, uint64_t *counter) { @@ -1245,13 +1089,6 @@ amdsmi_status_t amdsmi_set_gpu_clk_range(amdsmi_processor_handle processor_handl static_cast(clkType)); } -amdsmi_status_t amdsmi_set_gpu_overdrive_level_v1( - amdsmi_processor_handle processor_handle, - uint32_t od) { - return rsmi_wrapper(rsmi_dev_overdrive_level_set_v1, processor_handle, - od); -} - amdsmi_status_t amdsmi_reset_gpu(amdsmi_processor_handle processor_handle) { return rsmi_wrapper(rsmi_dev_gpu_reset, processor_handle); } @@ -1264,12 +1101,6 @@ amdsmi_status_t amdsmi_get_utilization_count(amdsmi_processor_handle processor_h reinterpret_cast(utilization_counters), count, timestamp); } -amdsmi_status_t amdsmi_get_gpu_memory_busy_percent( - amdsmi_processor_handle processor_handle, - uint32_t *busy_percent) { - return rsmi_wrapper(rsmi_dev_memory_busy_percent_get, processor_handle, - busy_percent); -} amdsmi_status_t amdsmi_get_energy_count(amdsmi_processor_handle processor_handle, uint64_t *power, float *counter_resolution, uint64_t *timestamp) { @@ -1277,13 +1108,7 @@ amdsmi_status_t amdsmi_get_energy_count(amdsmi_processor_handle processor_handle power, counter_resolution, timestamp); } -amdsmi_status_t amdsmi_get_gpu_drm_render_minor( - amdsmi_processor_handle processor_handle, uint32_t *minor) { - return rsmi_wrapper(rsmi_dev_drm_render_minor_get, processor_handle, - minor); -} - -amdsmi_status_t amdsmi_get_gpu_pci_id( +amdsmi_status_t admsmi_get_gpu_bdf_id( amdsmi_processor_handle processor_handle, uint64_t *bdfid) { return rsmi_wrapper(rsmi_dev_pci_id_get, processor_handle, bdfid); @@ -1295,7 +1120,7 @@ amdsmi_status_t amdsmi_get_gpu_topo_numa_affinity( numa_node); } -amdsmi_status_t amdsmi_get_version(amdsmi_version_t *version) { +amdsmi_status_t amdsmi_get_lib_version(amdsmi_version_t *version) { AMDSMI_CHECK_INIT(); if (version == nullptr) @@ -1306,19 +1131,6 @@ amdsmi_status_t amdsmi_get_version(amdsmi_version_t *version) { return amd::smi::rsmi_to_amdsmi_status(rstatus); } -amdsmi_status_t amdsmi_get_version_str(amdsmi_sw_component_t component, - char *ver_str, - uint32_t len) { - AMDSMI_CHECK_INIT(); - - if (ver_str == nullptr) - return AMDSMI_STATUS_INVAL; - - auto status = rsmi_version_str_get( - static_cast(component), ver_str, len); - return amd::smi::rsmi_to_amdsmi_status(status); -} - amdsmi_status_t amdsmi_get_gpu_vbios_info(amdsmi_processor_handle processor_handle, amdsmi_vbios_info_t *info) { AMDSMI_CHECK_INIT(); @@ -1491,7 +1303,7 @@ amdsmi_get_gpu_bad_page_info(amdsmi_processor_handle processor_handle, uint32_t } amdsmi_status_t -amdsmi_get_gpu_ecc_error_count(amdsmi_processor_handle processor_handle, amdsmi_error_count_t *ec) { +amdsmi_get_gpu_total_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_error_count_t *ec) { AMDSMI_CHECK_INIT(); if (ec == nullptr) { diff --git a/tests/amd_smi_test/functional/api_support_read.cc b/tests/amd_smi_test/functional/api_support_read.cc index 25dee643fe..939c35b3e4 100755 --- a/tests/amd_smi_test/functional/api_support_read.cc +++ b/tests/amd_smi_test/functional/api_support_read.cc @@ -96,93 +96,4 @@ void TestAPISupportRead::Run(void) { return; } - amdsmi_func_id_iter_handle_t iter_handle, var_iter, sub_var_iter; - amdsmi_func_id_value_t value; - - for (uint32_t x = 0; x < num_iterations(); ++x) { - for (uint32_t i = 0; i < num_monitor_devs(); ++i) { - IF_VERB(STANDARD) { - PrintDeviceHeader(processor_handles_[i]); - std::cout << "Supported AMDSMI Functions:" << std::endl; - std::cout << "\tVariants (Monitors)" << std::endl; - } - err = amdsmi_open_supported_func_iterator(processor_handles_[i], &iter_handle); - CHK_ERR_ASRT(err) - - while (1) { - err = amdsmi_get_func_iter_value(iter_handle, &value); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "Function Name: " << value.name << std::endl; - } - err = amdsmi_open_supported_variant_iterator(iter_handle, &var_iter); - if (err != AMDSMI_STATUS_NO_DATA) { - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\tVariants/Monitors: "; - } - while (1) { - err = amdsmi_get_func_iter_value(var_iter, &value); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - if (value.id == AMDSMI_DEFAULT_VARIANT) { - std::cout << "Default Variant "; - } else { - std::cout << value.id; - } - std::cout << " ("; - } - err = - amdsmi_open_supported_variant_iterator(var_iter, &sub_var_iter); - if (err != AMDSMI_STATUS_NO_DATA) { - CHK_ERR_ASRT(err) - - while (1) { - err = amdsmi_get_func_iter_value(sub_var_iter, &value); - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << value.id << ", "; - } - err = amdsmi_next_func_iter(sub_var_iter); - - if (err == AMDSMI_STATUS_NO_DATA) { - break; - } - CHK_ERR_ASRT(err) - } - err = amdsmi_close_supported_func_iterator(&sub_var_iter); - CHK_ERR_ASRT(err) - } - - IF_VERB(STANDARD) { - std::cout << "), "; - } - err = amdsmi_next_func_iter(var_iter); - - if (err == AMDSMI_STATUS_NO_DATA) { - break; - } - CHK_ERR_ASRT(err) - } - IF_VERB(STANDARD) { - std::cout << std::endl; - } - err = amdsmi_close_supported_func_iterator(&var_iter); - CHK_ERR_ASRT(err) - } - - err = amdsmi_next_func_iter(iter_handle); - - if (err == AMDSMI_STATUS_NO_DATA) { - break; - } - CHK_ERR_ASRT(err) - - // err = amdsmi_open_supported_variant_iterator(iter_handle, &var_iter); - // - } - err = amdsmi_close_supported_func_iterator(&iter_handle); - CHK_ERR_ASRT(err) - } - } } diff --git a/tests/amd_smi_test/functional/gpu_busy_read.cc b/tests/amd_smi_test/functional/gpu_busy_read.cc index 636b0cec88..7d02cafecb 100755 --- a/tests/amd_smi_test/functional/gpu_busy_read.cc +++ b/tests/amd_smi_test/functional/gpu_busy_read.cc @@ -94,27 +94,4 @@ void TestGPUBusyRead::Run(void) { std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl; return; } - - for (uint32_t x = 0; x < num_iterations(); ++x) { - for (uint32_t i = 0; i < num_monitor_devs(); ++i) { - PrintDeviceHeader(processor_handles_[i]); - - err = amdsmi_get_busy_percent(processor_handles_[i], &val_ui32); - if (err != AMDSMI_STATUS_SUCCESS) { - if (err == AMDSMI_STATUS_FILE_ERROR) { - IF_VERB(STANDARD) { - std::cout << "\t**GPU Busy Percent: Not supported on this machine" - << std::endl; - } - } else { - CHK_ERR_ASRT(err) - } - } else { - IF_VERB(STANDARD) { - std::cout << "\t**GPU Busy Percent (Percent Idle):" << std::dec << - val_ui32 << " (" << 100 - val_ui32 << ")" << std::endl; - } - } - } - } } diff --git a/tests/amd_smi_test/functional/id_info_read.cc b/tests/amd_smi_test/functional/id_info_read.cc index 5b1cb1d635..c4fea51a86 100755 --- a/tests/amd_smi_test/functional/id_info_read.cc +++ b/tests/amd_smi_test/functional/id_info_read.cc @@ -145,20 +145,6 @@ void TestIdInfoRead::Run(void) { } } - err = amdsmi_get_gpu_drm_render_minor(processor_handles_[i], &drm_render_minor); - if (err == AMDSMI_STATUS_NOT_SUPPORTED) { - // Verify api support checking functionality is working - err = amdsmi_get_gpu_drm_render_minor(processor_handles_[i], nullptr); - ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED); - } else { - CHK_ERR_ASRT(err) - IF_VERB(STANDARD) { - std::cout << "\t**DRM Render Minor: " << drm_render_minor << std::endl; - } - // Verify api support checking functionality is working - err = amdsmi_get_gpu_drm_render_minor(processor_handles_[i], nullptr); - ASSERT_EQ(err, AMDSMI_STATUS_INVAL); - } err = amdsmi_get_gpu_vendor_name(processor_handles_[i], buffer, kBufferLen); if (err == AMDSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Device Vendor name string not found on this system." << @@ -231,7 +217,7 @@ void TestIdInfoRead::Run(void) { ASSERT_EQ(err, AMDSMI_STATUS_INVAL); } - err = amdsmi_get_gpu_pci_id(processor_handles_[i], &val_ui64); + err = admsmi_get_gpu_bdf_id(processor_handles_[i], &val_ui64); // Don't check for AMDSMI_STATUS_NOT_SUPPORTED since this should always be // supported. It is not based on a sysfs file. CHK_ERR_ASRT(err) @@ -240,7 +226,7 @@ void TestIdInfoRead::Run(void) { std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; } // Verify api support checking functionality is working - err = amdsmi_get_gpu_pci_id(processor_handles_[i], nullptr); + err = admsmi_get_gpu_bdf_id(processor_handles_[i], nullptr); ASSERT_EQ(err, AMDSMI_STATUS_INVAL); } } diff --git a/tests/amd_smi_test/functional/mem_util_read.cc b/tests/amd_smi_test/functional/mem_util_read.cc index 1a5701f1d8..86b41b0015 100755 --- a/tests/amd_smi_test/functional/mem_util_read.cc +++ b/tests/amd_smi_test/functional/mem_util_read.cc @@ -118,17 +118,6 @@ void TestMemUtilRead::Run(void) { for (uint32_t i = 0; i < num_monitor_devs(); ++i) { PrintDeviceHeader(processor_handles_[i]); -#if 0 - err = amdsmi_get_gpu_memory_busy_percent(i, &mem_busy_percent); - err_chk("amdsmi_get_gpu_memory_busy_percent()"); - if (err != AMDSMI_STATUS_SUCCESS) { - return; - } - IF_VERB(STANDARD) { - std::cout << "\t**" << "GPU Memory Busy %: " << mem_busy_percent << - std::endl; - } -#endif for (uint32_t mem_type = AMDSMI_MEM_TYPE_FIRST; mem_type <= AMDSMI_MEM_TYPE_LAST; ++mem_type) { err = amdsmi_get_gpu_memory_total(processor_handles_[i], diff --git a/tests/amd_smi_test/functional/mutual_exclusion.cc b/tests/amd_smi_test/functional/mutual_exclusion.cc index 116b624d2a..8080bb3721 100755 --- a/tests/amd_smi_test/functional/mutual_exclusion.cc +++ b/tests/amd_smi_test/functional/mutual_exclusion.cc @@ -215,7 +215,7 @@ void TestMutualExclusion::Run(void) { CHECK_RET(ret, AMDSMI_STATUS_BUSY); ret = amdsmi_get_gpu_subsystem_id(processor_handles_[0], &dmy_ui16); CHECK_RET(ret, AMDSMI_STATUS_BUSY); - ret = amdsmi_get_gpu_pci_id(processor_handles_[0], &dmy_ui64); + ret = admsmi_get_gpu_bdf_id(processor_handles_[0], &dmy_ui64); CHECK_RET(ret, AMDSMI_STATUS_BUSY); ret = amdsmi_get_gpu_pci_throughput(processor_handles_[0], &dmy_ui64, &dmy_ui64, &dmy_ui64); CHECK_RET(ret, AMDSMI_STATUS_BUSY); @@ -245,8 +245,6 @@ void TestMutualExclusion::Run(void) { CHECK_RET(ret, AMDSMI_STATUS_BUSY); ret = amdsmi_get_gpu_od_volt_curve_regions(processor_handles_[0], &dmy_ui32, &dmy_vlt_reg); CHECK_RET(ret, AMDSMI_STATUS_BUSY); - ret = amdsmi_set_gpu_overdrive_level_v1(processor_handles_[0], dmy_i32); - CHECK_RET(ret, AMDSMI_STATUS_BUSY); ret = amdsmi_set_clk_freq(processor_handles_[0], CLK_TYPE_SYS, 0); CHECK_RET(ret, AMDSMI_STATUS_BUSY); ret = amdsmi_get_gpu_ecc_count(processor_handles_[0], AMDSMI_GPU_BLOCK_UMC, &dmy_err_cnt); @@ -258,7 +256,6 @@ void TestMutualExclusion::Run(void) { /* Other functions holding device mutexes. Listed for reference. amdsmi_dev_sku_get - amdsmi_set_gpu_perf_level_v1 amdsmi_set_gpu_od_clk_info amdsmi_set_gpu_od_volt_info amdsmi_dev_firmware_version_get @@ -267,7 +264,6 @@ void TestMutualExclusion::Run(void) { amdsmi_dev_brand_get amdsmi_get_gpu_vram_vendor amdsmi_get_gpu_subsystem_name - amdsmi_get_gpu_drm_render_minor amdsmi_get_gpu_vendor_name amdsmi_get_gpu_pci_bandwidth amdsmi_set_gpu_pci_bandwidth @@ -283,6 +279,7 @@ void TestMutualExclusion::Run(void) { amdsmi_get_gpu_metrics_info amdsmi_get_gpu_od_volt_curve_regions amdsmi_dev_power_max_get + amdsmi_get_power_ave amdsmi_dev_power_cap_get amdsmi_dev_power_cap_range_get amdsmi_set_power_cap @@ -290,8 +287,6 @@ void TestMutualExclusion::Run(void) { amdsmi_set_gpu_power_profile amdsmi_get_gpu_memory_total amdsmi_get_gpu_memory_usage - amdsmi_get_gpu_memory_busy_percent - amdsmi_get_busy_percent amdsmi_dev_vbios_version_get amdsmi_dev_serial_number_get amdsmi_get_gpu_pci_replay_counter diff --git a/tests/amd_smi_test/functional/sys_info_read.cc b/tests/amd_smi_test/functional/sys_info_read.cc index 334b30e79a..c3bb800db6 100755 --- a/tests/amd_smi_test/functional/sys_info_read.cc +++ b/tests/amd_smi_test/functional/sys_info_read.cc @@ -128,14 +128,14 @@ void TestSysInfoRead::Run(void) { } } - err = amdsmi_get_gpu_pci_id(processor_handles_[i], &val_ui64); + err = admsmi_get_gpu_bdf_id(processor_handles_[i], &val_ui64); CHK_ERR_ASRT(err) IF_VERB(STANDARD) { std::cout << "\t**PCI ID (BDFID): 0x" << std::hex << val_ui64; std::cout << " (" << std::dec << val_ui64 << ")" << std::endl; } // Verify api support checking functionality is working - err = amdsmi_get_gpu_pci_id(processor_handles_[i], nullptr); + err = admsmi_get_gpu_bdf_id(processor_handles_[i], nullptr); ASSERT_EQ(err, AMDSMI_STATUS_INVAL); err = amdsmi_get_gpu_topo_numa_affinity(processor_handles_[i], &val_ui32); @@ -177,7 +177,7 @@ void TestSysInfoRead::Run(void) { } } - err = amdsmi_get_version(&ver); + err = amdsmi_get_lib_version(&ver); CHK_ERR_ASRT(err) ASSERT_TRUE(ver.major != 0xFFFFFFFF && ver.minor != 0xFFFFFFFF && diff --git a/tests/amd_smi_test/functional/version_read.cc b/tests/amd_smi_test/functional/version_read.cc index 7819368e67..d44b8f88d6 100755 --- a/tests/amd_smi_test/functional/version_read.cc +++ b/tests/amd_smi_test/functional/version_read.cc @@ -86,11 +86,6 @@ void TestVersionRead::Close() { static const uint32_t kVerMaxStrLen = 80; -static const std::map - kComponentNameMap = { - {AMDSMI_SW_COMP_DRIVER, "Driver Version"}, -}; - void TestVersionRead::Run(void) { amdsmi_status_t err; amdsmi_version_t ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr}; @@ -101,7 +96,7 @@ void TestVersionRead::Run(void) { return; } - err = amdsmi_get_version(&ver); + err = amdsmi_get_lib_version(&ver); CHK_ERR_ASRT(err) ASSERT_TRUE(ver.major != 0xFFFFFFFF && ver.minor != 0xFFFFFFFF && @@ -110,17 +105,4 @@ void TestVersionRead::Run(void) { std::cout << "\t**AMD SMI Library version: " << ver.major << "." << ver.minor << "." << ver.patch << " (" << ver.build << ")" << std::endl; } - - char ver_str[kVerMaxStrLen]; - - for (uint32_t cmp = AMDSMI_SW_COMP_FIRST; cmp <= AMDSMI_SW_COMP_LAST; ++cmp) { - err = amdsmi_get_version_str(static_cast(cmp), - ver_str, kVerMaxStrLen); - CHK_ERR_ASRT(err) - - IF_VERB(STANDARD) { - std::cout << "\t**" << kComponentNameMap.at(cmp) << ": " << - ver_str << std::endl; - } - } } diff --git a/tests/amd_smi_test/test_common.h b/tests/amd_smi_test/test_common.h index 51de1f4c04..5a2aa6d9fc 100644 --- a/tests/amd_smi_test/test_common.h +++ b/tests/amd_smi_test/test_common.h @@ -77,7 +77,7 @@ void DumpMonitorInfo(const TestBase *test); if (RET != AMDSMI_STATUS_SUCCESS) { \ const char *err_str; \ std::cout << "\t===> ERROR: AMDSMI call returned " << (RET) << std::endl; \ - amdsmi_status_string((RET), &err_str); \ + amdsmi_status_code_to_string((RET), &err_str); \ std::cout << "\t===> (" << err_str << ")" << std::endl; \ std::cout << "\t===> at " << __FILE__ << ":" << std::dec << __LINE__ << \ std::endl; \ From c5e06b404048c431acd4e911083271308a5072db Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Tue, 16 May 2023 17:14:23 -0600 Subject: [PATCH 2/2] add configurations for sphinx documentation Change-Id: I5672348aab0f20d0bfc4dd1efcfecdf4324342d6 --- .github/dependabot.yml | 12 ++ .gitignore | 6 + .readthedocs.yaml | 18 ++ docs/conf.py | 26 +++ .../{amd_smi_doxygen.cfg => doxygen/Doxyfile} | 33 ++-- docs/index.rst | 2 + docs/license.rst | 6 + docs/sphinx/_toc.yml.in | 14 ++ docs/sphinx/requirements.in | 1 + docs/sphinx/requirements.txt | 172 ++++++++++++++++++ src/CMakeLists.txt | 36 ---- 11 files changed, 276 insertions(+), 50 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .readthedocs.yaml create mode 100644 docs/conf.py rename docs/{amd_smi_doxygen.cfg => doxygen/Doxyfile} (99%) create mode 100644 docs/index.rst create mode 100644 docs/license.rst create mode 100644 docs/sphinx/_toc.yml.in create mode 100644 docs/sphinx/requirements.in create mode 100644 docs/sphinx/requirements.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..276690bd4f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/docs/sphinx" # Location of package manifests + open-pull-requests-limit: 10 + schedule: + interval: "daily" diff --git a/.gitignore b/.gitignore index 5b157b6f4b..28441fe2f8 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ docs/*.pdf __pycache__/ *.py[cod] *.egg-* + +# documentation artifacts +_toc.yml +_build/ +_doxygen/ +docBin/ diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000000..5f50df2525 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,18 @@ +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.8" + +sphinx: + configuration: docs/conf.py + +formats: [htmlzip, pdf, epub] + +python: + install: + - requirements: docs/sphinx/requirements.txt diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000000..f77158e731 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,26 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +import subprocess + +from rocm_docs import ROCmDocs + + +name = "AMD SMI" +get_version = r'sed -n -e "s/^get_package_version_number(.*\"\([0-9\.]\{1,\}\).*/\1/p" ../CMakeLists.txt' +version = subprocess.getoutput(get_version) +if len(version) > 0: + name = f"{name} {version}" + +external_toc_path = "./sphinx/_toc.yml" + +docs_core = ROCmDocs(f"{name} Documentation") +docs_core.run_doxygen(doxygen_root="doxygen", doxygen_path="doxygen/docBin/xml") +docs_core.enable_api_reference() +docs_core.setup() + +for sphinx_var in ROCmDocs.SPHINX_VARS: + globals()[sphinx_var] = getattr(docs_core, sphinx_var) diff --git a/docs/amd_smi_doxygen.cfg b/docs/doxygen/Doxyfile similarity index 99% rename from docs/amd_smi_doxygen.cfg rename to docs/doxygen/Doxyfile index 3e9779a09a..a35063a3ab 100644 --- a/docs/amd_smi_doxygen.cfg +++ b/docs/doxygen/Doxyfile @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "AMDSMI" +PROJECT_NAME = AMD SMI # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -58,7 +58,7 @@ PROJECT_LOGO = # entered, it will be relative to the location where doxygen was started. If # left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = docBin # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- # directories (in 2 levels) under the output directory of each output format and @@ -759,8 +759,8 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = @CMAKE_CURRENT_SOURCE_DIR@/../README.md \ - @CMAKE_CURRENT_SOURCE_DIR@/../include/amd_smi/amdsmi.h +INPUT = ../../README.md \ + ../../include/amd_smi/amdsmi.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses @@ -1086,7 +1086,7 @@ HTML_FILE_EXTENSION = .html # of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_HEADER = +HTML_HEADER = ../_doxygen/header.html # The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each # generated HTML page. If the tag is left blank doxygen will generate a standard @@ -1096,7 +1096,7 @@ HTML_HEADER = # that doxygen normally uses. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_FOOTER = +HTML_FOOTER = ../_doxygen/footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading style # sheet that is used by each HTML page. It can be used to fine-tune the look of @@ -1108,7 +1108,7 @@ HTML_FOOTER = # obsolete. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_STYLESHEET = +HTML_STYLESHEET = ../_doxygen/stylesheet.css # The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined # cascading style sheets that are included after the standard style sheets @@ -1118,10 +1118,15 @@ HTML_STYLESHEET = # Doxygen will copy the style sheet files to the output directory. # Note: The order of the extra style sheet files is of importance (e.g. the last # style sheet in the list overrules the setting of the previous ones in the -# list). For an example see the documentation. +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. # This tag requires that the tag GENERATE_HTML is set to YES. -HTML_EXTRA_STYLESHEET = +HTML_EXTRA_STYLESHEET = ../_doxygen/extra_stylesheet.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note @@ -1521,7 +1526,7 @@ MATHJAX_CODEFILE = # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. -SEARCHENGINE = YES +SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. There @@ -1875,7 +1880,7 @@ MAN_LINKS = NO # captures the structure of the code including all documentation. # The default value is: NO. -GENERATE_XML = NO +GENERATE_XML = YES # The XML_OUTPUT tag is used to specify where the XML pages will be put. If a # relative path is entered the value of OUTPUT_DIRECTORY will be put in front of @@ -2072,7 +2077,7 @@ TAGFILES = # tag file that is based on the input files it reads. See section "Linking to # external documentation" for more information about the usage of tag files. -GENERATE_TAGFILE = +GENERATE_TAGFILE = docBin/html/tagfile.xml # If the ALLEXTERNALS tag is set to YES, all external class will be listed in # the class index. If set to NO, only the inherited external classes will be @@ -2307,7 +2312,7 @@ DIRECTORY_GRAPH = YES # The default value is: png. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_IMAGE_FORMAT = png +DOT_IMAGE_FORMAT = svg # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. @@ -2319,7 +2324,7 @@ DOT_IMAGE_FORMAT = png # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -INTERACTIVE_SVG = NO +INTERACTIVE_SVG = YES # The DOT_PATH tag can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000000..339dc8f42d --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,2 @@ +.. include:: ../README.md + :parser: myst_parser.sphinx_ diff --git a/docs/license.rst b/docs/license.rst new file mode 100644 index 0000000000..ddb544496e --- /dev/null +++ b/docs/license.rst @@ -0,0 +1,6 @@ +======= +License +======= + +.. include:: ../LICENSE + :literal: diff --git a/docs/sphinx/_toc.yml.in b/docs/sphinx/_toc.yml.in new file mode 100644 index 0000000000..7d534c0601 --- /dev/null +++ b/docs/sphinx/_toc.yml.in @@ -0,0 +1,14 @@ +# Anywhere {branch} is used, the branch name will be substituted. +# These comments will also be removed. +defaults: + numbered: False + maxdepth: 6 +root: index +subtrees: + - caption: API + entries: + - file: doxygen/docBin/html/index + title: API + - caption: About + entries: + - file: license diff --git a/docs/sphinx/requirements.in b/docs/sphinx/requirements.in new file mode 100644 index 0000000000..0c3a8febc3 --- /dev/null +++ b/docs/sphinx/requirements.in @@ -0,0 +1 @@ +rocm-docs-core[api_reference]==0.10.3 diff --git a/docs/sphinx/requirements.txt b/docs/sphinx/requirements.txt new file mode 100644 index 0000000000..630360bde9 --- /dev/null +++ b/docs/sphinx/requirements.txt @@ -0,0 +1,172 @@ +# +# This file is autogenerated by pip-compile with Python 3.8 +# by the following command: +# +# pip-compile sphinx/requirements.in +# +accessible-pygments==0.0.4 + # via pydata-sphinx-theme +alabaster==0.7.13 + # via sphinx +babel==2.12.1 + # via + # pydata-sphinx-theme + # sphinx +beautifulsoup4==4.12.2 + # via pydata-sphinx-theme +breathe==4.35.0 + # via rocm-docs-core +certifi==2023.5.7 + # via requests +cffi==1.15.1 + # via + # cryptography + # pynacl +charset-normalizer==3.1.0 + # via requests +click==8.1.3 + # via + # click-log + # doxysphinx + # sphinx-external-toc +click-log==0.4.0 + # via doxysphinx +cryptography==40.0.2 + # via pyjwt +deprecated==1.2.13 + # via pygithub +docutils==0.19 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # sphinx +doxysphinx==3.3.3 + # via rocm-docs-core +gitdb==4.0.10 + # via gitpython +gitpython==3.1.31 + # via rocm-docs-core +idna==3.4 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==6.6.0 + # via sphinx +importlib-resources==5.12.0 + # via rocm-docs-core +jinja2==3.1.2 + # via + # myst-parser + # sphinx +libsass==0.22.0 + # via doxysphinx +linkify-it-py==1.0.3 + # via myst-parser +lxml==4.9.2 + # via doxysphinx +markdown-it-py==2.2.0 + # via + # mdit-py-plugins + # myst-parser +markupsafe==2.1.2 + # via jinja2 +mdit-py-plugins==0.3.5 + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +mpire==2.7.1 + # via doxysphinx +myst-parser[linkify]==1.0.0 + # via rocm-docs-core +packaging==23.1 + # via + # pydata-sphinx-theme + # sphinx +pycparser==2.21 + # via cffi +pydata-sphinx-theme==0.13.3 + # via + # rocm-docs-core + # sphinx-book-theme +pygithub==1.58.2 + # via rocm-docs-core +pygments==2.15.1 + # via + # accessible-pygments + # mpire + # pydata-sphinx-theme + # sphinx +pyjson5==1.6.2 + # via doxysphinx +pyjwt[crypto]==2.7.0 + # via pygithub +pynacl==1.5.0 + # via pygithub +pyparsing==3.0.9 + # via doxysphinx +pytz==2023.3 + # via babel +pyyaml==6.0 + # via + # myst-parser + # sphinx-external-toc +requests==2.30.0 + # via + # pygithub + # sphinx +rocm-docs-core[api_reference]==0.10.3 + # via -r sphinx/requirements.in +smmap==5.0.0 + # via gitdb +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.4.1 + # via beautifulsoup4 +sphinx==5.3.0 + # via + # breathe + # myst-parser + # pydata-sphinx-theme + # rocm-docs-core + # sphinx-book-theme + # sphinx-copybutton + # sphinx-design + # sphinx-external-toc + # sphinx-notfound-page +sphinx-book-theme==1.0.1 + # via rocm-docs-core +sphinx-copybutton==0.5.2 + # via rocm-docs-core +sphinx-design==0.4.1 + # via rocm-docs-core +sphinx-external-toc==0.3.1 + # via rocm-docs-core +sphinx-notfound-page==0.8.3 + # via rocm-docs-core +sphinxcontrib-applehelp==1.0.4 + # via sphinx +sphinxcontrib-devhelp==1.0.2 + # via sphinx +sphinxcontrib-htmlhelp==2.0.1 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.3 + # via sphinx +sphinxcontrib-serializinghtml==1.1.5 + # via sphinx +tqdm==4.65.0 + # via mpire +typing-extensions==4.5.0 + # via pydata-sphinx-theme +uc-micro-py==1.0.2 + # via linkify-it-py +urllib3==2.0.2 + # via requests +wrapt==1.15.0 + # via deprecated +zipp==3.15.0 + # via + # importlib-metadata + # importlib-resources diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07b45cf3b4..430a374459 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -138,39 +138,3 @@ install( # DESTINATION libexec/${AMD_SMI}) #install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bin/rocm-smi # DESTINATION bin) - -# Generate Doxygen documentation -find_package(Doxygen) -find_package(LATEX COMPONENTS PDFLATEX) - -if(DOXYGEN_FOUND AND LATEX_FOUND) - set(ASMI_MANUAL_NAME "AMD_SMI_Manual") - configure_file(${PROJECT_SOURCE_DIR}/docs/amd_smi_doxygen.cfg ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) - - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.tex - COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - DEPENDS ${PROJECT_SOURCE_DIR}/docs/amd_smi_doxygen.cfg "${PROJECT_SOURCE_DIR}/include/amd_smi/amdsmi.h" - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf - COMMAND make > /dev/null - COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf ${PROJECT_SOURCE_DIR}/docs/${ASMI_MANUAL_NAME}_new.pdf - DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.tex - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/latex) - - add_custom_target(docs DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf) - - add_dependencies(${AMD_SMI_TARGET} docs) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/latex/refman.pdf - DESTINATION share/doc/${AMD_SMI} - RENAME ${ASMI_MANUAL_NAME}.pdf - COMPONENT dev) - install( - FILES ${PROJECT_SOURCE_DIR}/README.md - DESTINATION share/doc/${AMD_SMI} - COMPONENT dev) -else() - message("Doxygen or Latex is not found. Will not generate documents.") -endif(DOXYGEN_FOUND AND LATEX_FOUND)