From 8dfded3dc4f0b68888f4197de42c755d89419af3 Mon Sep 17 00:00:00 2001 From: Sam Wu Date: Thu, 29 Jun 2023 12:43:04 -0600 Subject: [PATCH 01/33] Update rocm-docs Change-Id: I30633c9cd29bc58b0c48086d5f493204f3d6ffd8 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 1de63ce5062def48e4cd8ebcd6139ad8e04081dc] --- projects/amdsmi/.readthedocs.yaml | 2 +- projects/amdsmi/docs/.doxygen/Doxyfile | 824 ++++++++++++------ projects/amdsmi/docs/.sphinx/.gitignore | 1 + projects/amdsmi/docs/.sphinx/requirements.in | 2 +- projects/amdsmi/docs/.sphinx/requirements.txt | 12 +- 5 files changed, 549 insertions(+), 292 deletions(-) create mode 100644 projects/amdsmi/docs/.sphinx/.gitignore diff --git a/projects/amdsmi/.readthedocs.yaml b/projects/amdsmi/.readthedocs.yaml index 1240c9c525..3baf848c33 100644 --- a/projects/amdsmi/.readthedocs.yaml +++ b/projects/amdsmi/.readthedocs.yaml @@ -6,7 +6,7 @@ version: 2 sphinx: configuration: docs/conf.py -formats: [htmlzip] +formats: [htmlzip, pdf, epub] python: install: diff --git a/projects/amdsmi/docs/.doxygen/Doxyfile b/projects/amdsmi/docs/.doxygen/Doxyfile index 63fcd8c926..39f0d396eb 100644 --- a/projects/amdsmi/docs/.doxygen/Doxyfile +++ b/projects/amdsmi/docs/.doxygen/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.11 +# Doxyfile 1.9.6 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -12,16 +12,26 @@ # For lists, items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (\" \"). +# +# Note: +# +# Use doxygen to compare the used configuration file with the template +# configuration file: +# doxygen -x [configFile] +# Use doxygen to compare the used configuration file with the template +# configuration file without replacing the environment variables or CMake type +# replacement variables: +# doxygen -x_noenv [configFile] #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all text -# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv -# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv -# for the list of possible encodings. +# This tag specifies the encoding used for all characters in the configuration +# file that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# https://www.gnu.org/software/libiconv/ for the list of possible encodings. # The default value is: UTF-8. DOXYFILE_ENCODING = UTF-8 @@ -32,7 +42,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "ROCmSMI" +PROJECT_NAME = ROCmSMI # 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 @@ -60,16 +70,28 @@ PROJECT_LOGO = 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 -# will distribute the generated files over these directories. Enabling this +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 +# sub-directories (in 2 levels) under the output directory of each output format +# and will distribute the generated files over these directories. Enabling this # option can be useful when feeding doxygen a huge amount of source files, where # putting all generated files in the same directory would otherwise causes -# performance problems for the file system. +# performance problems for the file system. Adapt CREATE_SUBDIRS_LEVEL to +# control the number of sub-directories. # The default value is: NO. CREATE_SUBDIRS = NO +# Controls the number of sub-directories that will be created when +# CREATE_SUBDIRS tag is set to YES. Level 0 represents 16 directories, and every +# level increment doubles the number of directories, resulting in 4096 +# directories at level 8 which is the default and also the maximum value. The +# sub-directories are organized in 2 levels, the first level always has a fixed +# number of 16 directories. +# Minimum value: 0, maximum value: 8, default value: 8. +# This tag requires that the tag CREATE_SUBDIRS is set to YES. + +CREATE_SUBDIRS_LEVEL = 8 + # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII # characters will be escaped, for example _xE3_x81_x84 will be used for Unicode @@ -81,14 +103,14 @@ ALLOW_UNICODE_NAMES = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. -# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese, -# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States), -# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian, -# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian, -# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian, -# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish, -# Ukrainian and Vietnamese. +# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Bulgarian, +# Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, English +# (United States), Esperanto, Farsi (Persian), Finnish, French, German, Greek, +# Hindi, Hungarian, Indonesian, Italian, Japanese, Japanese-en (Japanese with +# English messages), Korean, Korean-en (Korean with English messages), Latvian, +# Lithuanian, Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, +# Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, +# Swedish, Turkish, Ukrainian and Vietnamese. # The default value is: English. OUTPUT_LANGUAGE = English @@ -179,6 +201,16 @@ SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO +# If the JAVADOC_BANNER tag is set to YES then doxygen will interpret a line +# such as +# /*************** +# as being the beginning of a Javadoc-style comment "banner". If set to NO, the +# Javadoc-style will behave just like regular comments and it will not be +# interpreted by doxygen. +# The default value is: NO. + +JAVADOC_BANNER = NO + # If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first # line (until the first dot) of a Qt-style comment as the brief description. If # set to NO, the Qt-style will behave just like regular Qt-style comments (thus @@ -199,6 +231,14 @@ QT_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -222,21 +262,19 @@ TAB_SIZE = 4 # the documentation. An alias has the form: # name=value # For example adding -# "sideeffect=@par Side Effects:\n" +# "sideeffect=@par Side Effects:^^" # will allow you to put the command \sideeffect (or @sideeffect) in the # documentation, which will result in a user-defined paragraph with heading -# "Side Effects:". You can put \n's in the value part of an alias to insert -# newlines. +# "Side Effects:". Note that you cannot put \n's in the value part of an alias +# to insert newlines (in the resulting output). You can put ^^ in the value part +# of an alias to insert a newline as if a physical newline was in the original +# file. When you need a literal { or } or , in the value part of an alias you +# have to escape them by means of a backslash (\), this can lead to conflicts +# with the commands \{ and \} for these it is advised to use the version @{ and +# @} or use a double escape (\\{ and \\}) ALIASES = -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -# Doxygen says following tag is obsolete; comment to quiet warning -# TCL_SUBST = - # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For # instance, some of the names that are used will be different. The list of all @@ -265,28 +303,40 @@ OPTIMIZE_FOR_FORTRAN = NO OPTIMIZE_OUTPUT_VHDL = NO +# Set the OPTIMIZE_OUTPUT_SLICE tag to YES if your project consists of Slice +# sources only. Doxygen will then generate output that is more tailored for that +# language. For instance, namespaces will be presented as modules, types will be +# separated into more groups, etc. +# The default value is: NO. + +OPTIMIZE_OUTPUT_SLICE = NO + # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: -# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: -# Fortran. In the later case the parser tries to guess whether the code is fixed -# or free formatted code, this is the default for Fortran type files), VHDL. For -# instance to make doxygen treat .inc files as Fortran files (default is PHP), -# and .f files as C (default is Fortran), use: inc=Fortran f=C. +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, Lex, D, PHP, md (Markdown), Objective-C, Python, Slice, +# VHDL, Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: +# FortranFree, unknown formatted Fortran: Fortran. In the later case the parser +# tries to guess whether the code is fixed or free formatted code, this is the +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = # If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments # according to the Markdown format, which allows for more readable -# documentation. See http://daringfireball.net/projects/markdown/ for details. +# documentation. See https://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you can # mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in # case of backward compatibilities issues. @@ -294,6 +344,15 @@ EXTENSION_MAPPING = MARKDOWN_SUPPORT = YES +# When the TOC_INCLUDE_HEADINGS tag is set to a non-zero value, all headings up +# to that level are automatically included in the table of contents, even if +# they do not have an id attribute. +# Note: This feature currently applies only to Markdown headings. +# Minimum value: 0, maximum value: 99, default value: 5. +# This tag requires that the tag MARKDOWN_SUPPORT is set to YES. + +TOC_INCLUDE_HEADINGS = 5 + # When enabled doxygen tries to link words that correspond to documented # classes, or namespaces to their corresponding documentation. Such a link can # be prevented in individual cases by putting a % sign in front of the word or @@ -319,7 +378,7 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip (see: -# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen +# https://www.riverbankcomputing.com/software/sip/intro) sources only. Doxygen # will parse them like normal C++ but will assume all classes use public instead # of private inheritance when no explicit protection keyword is present. # The default value is: NO. @@ -344,6 +403,13 @@ IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO +# If one adds a struct or class to a group and this option is enabled, then also +# any nested class or struct is added to the same group. By default this option +# is disabled and one has to add nested compounds explicitly via \ingroup. +# The default value is: NO. + +GROUP_NESTED_COMPOUNDS = NO + # Set the SUBGROUPING tag to YES to allow class member groups of the same type # (for instance a group of public functions) to be put as a subgroup of that # type (e.g. under the Public Functions section). Set it to NO to prevent @@ -398,6 +464,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number of threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which effectively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -418,6 +497,12 @@ EXTRACT_ALL = NO EXTRACT_PRIVATE = NO +# If the EXTRACT_PRIV_VIRTUAL tag is set to YES, documented private virtual +# methods of a class will be included in the documentation. +# The default value is: NO. + +EXTRACT_PRIV_VIRTUAL = NO + # If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal # scope will be included in the documentation. # The default value is: NO. @@ -455,6 +540,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -466,14 +558,15 @@ HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. If set # to NO, these classes will be included in the various overviews. This option -# has no effect if EXTRACT_ALL is enabled. +# will also hide undocumented C++ concepts if enabled. This option has no effect +# if EXTRACT_ALL is enabled. # The default value is: NO. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -492,12 +585,20 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. -# The default value is: system dependent. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. +# Possible values are: SYSTEM, NO and YES. +# The default value is: SYSTEM. CASE_SENSE_NAMES = YES @@ -515,6 +616,12 @@ HIDE_SCOPE_NAMES = NO HIDE_COMPOUND_REFERENCE= NO +# If the SHOW_HEADERFILE tag is set to YES then the documentation for a class +# will show which file needs to be included to use the class. +# The default value is: YES. + +SHOW_HEADERFILE = YES + # If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of # the files that are included by a file in the documentation of that file. # The default value is: YES. @@ -672,7 +779,8 @@ FILE_VERSION_FILTER = # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. You can # optionally specify a file name after the option, if omitted DoxygenLayout.xml -# will be used as the name of the layout file. +# will be used as the name of the layout file. See also section "Changing the +# layout of pages" for information. # # Note that if you run doxygen from a directory containing a file called # DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE @@ -683,7 +791,7 @@ LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files containing # the reference definitions. This must be a list of .bib files. The .bib # extension is automatically appended if omitted. This requires the bibtex tool -# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info. +# to be installed. See also https://en.wikipedia.org/wiki/BibTeX for more info. # For LaTeX the style of the bibliography can be controlled using # LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the # search path. See also \cite for info how to create references. @@ -718,34 +826,74 @@ WARNINGS = YES WARN_IF_UNDOCUMENTED = YES # If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some parameters -# in a documented function, or documenting parameters that don't exist or using -# markup commands wrongly. +# potential errors in the documentation, such as documenting some parameters in +# a documented function twice, or documenting parameters that don't exist or +# using markup commands wrongly. # The default value is: YES. WARN_IF_DOC_ERROR = YES +# If WARN_IF_INCOMPLETE_DOC is set to YES, doxygen will warn about incomplete +# function parameter documentation. If set to NO, doxygen will accept that some +# parameters have no documentation without warning. +# The default value is: YES. + +WARN_IF_INCOMPLETE_DOC = YES + # This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that # are documented, but have no documentation for their parameters or return -# value. If set to NO, doxygen will only warn about wrong or incomplete -# parameter documentation, but not about the absence of documentation. +# value. If set to NO, doxygen will only warn about wrong parameter +# documentation, but not about the absence of documentation. If EXTRACT_ALL is +# set to YES then this flag will automatically be disabled. See also +# WARN_IF_INCOMPLETE_DOC # The default value is: NO. WARN_NO_PARAMDOC = NO +# If WARN_IF_UNDOC_ENUM_VAL option is set to YES, doxygen will warn about +# undocumented enumeration values. If set to NO, doxygen will accept +# undocumented enumeration values. If EXTRACT_ALL is set to YES then this flag +# will automatically be disabled. +# The default value is: NO. + +WARN_IF_UNDOC_ENUM_VAL = NO + +# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. +# The default value is: NO. + +WARN_AS_ERROR = NO + # The WARN_FORMAT tag determines the format of the warning messages that doxygen # can produce. The string should contain the $file, $line, and $text tags, which # will be replaced by the file and line number from which the warning originated # and the warning text. Optionally the format may contain $version, which will # be replaced by the version of the file (if it could be obtained via # FILE_VERSION_FILTER) +# See also: WARN_LINE_FORMAT # The default value is: $file:$line: $text. WARN_FORMAT = "$file:$line: $text" +# In the $text part of the WARN_FORMAT command it is possible that a reference +# to a more specific place is given. To make it easier to jump to this place +# (outside of doxygen) the user can define a custom "cut" / "paste" string. +# Example: +# WARN_LINE_FORMAT = "'vi $file +$line'" +# See also: WARN_FORMAT +# The default value is: at line $line of file $file. + +WARN_LINE_FORMAT = "at line $line of file $file" + # The WARN_LOGFILE tag can be used to specify a file to which warning and error # messages should be written. If left blank the output is written to standard -# error (stderr). +# error (stderr). In case the file specified cannot be opened for writing the +# warning and error messages are written to standard error. When as file - is +# specified the warning and error messages are written to standard output +# (stdout). WARN_LOGFILE = @@ -759,18 +907,29 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ../../README.md \ - ../../include/rocm_smi/rocm_smi.h +INPUT = ../../README.md \ + ../../include/rocm_smi/rocm_smi.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 # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: http://www.gnu.org/software/libiconv) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. +# See also: INPUT_FILE_ENCODING # The default value is: UTF-8. INPUT_ENCODING = UTF-8 +# This tag can be used to specify the character encoding of the source files +# that doxygen parses The INPUT_FILE_ENCODING tag can be used to specify +# character encoding on a per file pattern basis. Doxygen will compare the file +# name with each pattern and apply the encoding instead of the default +# INPUT_ENCODING) if there is a match. The character encodings are a list of the +# form: pattern=encoding (like *.php=ISO-8859-1). See cfg_input_encoding +# "INPUT_ENCODING" for further information on supported encodings. + +INPUT_FILE_ENCODING = + # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and # *.h) to filter out the source-files in the directories. @@ -779,11 +938,15 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, -# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl, -# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js. +# *.hh, *.hxx, *.hpp, *.h++, *.l, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, +# *.inc, *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C +# comment), *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, +# *.vhdl, *.ucf, *.qsf and *.ice. FILE_PATTERNS = @@ -822,7 +985,7 @@ EXCLUDE_PATTERNS = # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, -# AClass::ANamespace, ANamespace::*Test +# ANamespace::AClass, ANamespace::*Test # # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories use the pattern */test/* @@ -870,6 +1033,11 @@ IMAGE_PATH = # code is scanned, but not when the output code is generated. If lines are added # or removed, the anchors will not be placed correctly. # +# Note that doxygen will use the data processed and written to standard output +# for further processing, therefore nothing else, like debug statements or used +# commands (so in case of a Windows batch file always use @echo OFF), should be +# written to standard output. +# # Note that for custom extensions or not directly supported extensions you also # need to set EXTENSION_MAPPING for the extension otherwise the files are not # properly processed by doxygen. @@ -911,6 +1079,15 @@ FILTER_SOURCE_PATTERNS = USE_MDFILE_AS_MAINPAGE = ../../README.md +# The Fortran standard specifies that for fixed formatted Fortran code all +# characters from position 72 are to be considered as comment. A common +# extension is to allow longer lines before the automatic comment starts. The +# setting FORTRAN_COMMENT_AFTER will also make it possible that longer lines can +# be processed before the automatic comment starts. +# Minimum value: 7, maximum value: 10000, default value: 72. + +FORTRAN_COMMENT_AFTER = 72 + #--------------------------------------------------------------------------- # Configuration options related to source browsing #--------------------------------------------------------------------------- @@ -938,7 +1115,7 @@ INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES then for each documented -# function all documented functions referencing it will be listed. +# entity all documented functions referencing it will be listed. # The default value is: NO. REFERENCED_BY_RELATION = NO @@ -970,12 +1147,12 @@ SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code will # point to the HTML generated by the htags(1) tool instead of doxygen built-in # source browser. The htags tool is part of GNU's global source tagging system -# (see http://www.gnu.org/software/global/global.html). You will need version +# (see https://www.gnu.org/software/global/global.html). You will need version # 4.8.6 or higher. # # To use it do the following: # - Install the latest version of global -# - Enable SOURCE_BROWSER and USE_HTAGS in the config file +# - Enable SOURCE_BROWSER and USE_HTAGS in the configuration file # - Make sure the INPUT points to the root of the source tree # - Run doxygen as normal # @@ -997,27 +1174,6 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES -# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the -# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the -# cost of reduced performance. This can be particularly helpful with template -# rich C++ code for which doxygen's built-in parser lacks the necessary type -# information. -# Note: The availability of this option depends on whether or not doxygen was -# generated with the -Duse-libclang=ON option for CMake. -# The default value is: NO. - -# comment following to quiet warning -# CLANG_ASSISTED_PARSING = NO - -# If clang assisted parsing is enabled you can provide the compiler with command -# line options that you would normally use when invoking the compiler. Note that -# the include paths will already be set by doxygen for the files and directories -# specified with INPUT and INCLUDE_PATH. -# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. - -# comment following to quiet warning -# CLANG_OPTIONS = - #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1029,17 +1185,11 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all classes will -# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag -# can be used to specify a prefix (or a list of prefixes) that should be ignored -# while generating the index headers. +# The IGNORE_PREFIX tag can be used to specify a prefix (or a list of prefixes) +# that should be ignored while generating the index headers. The IGNORE_PREFIX +# tag works for classes, function and member names. The entity will be placed in +# the alphabetical list under the first letter of the entity name that remains +# after removing the prefix. # This tag requires that the tag ALPHABETICAL_INDEX is set to YES. IGNORE_PREFIX = @@ -1118,7 +1268,12 @@ HTML_STYLESHEET = ../_doxygen/stylesheet.css # 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 = ../_doxygen/extra_stylesheet.css @@ -1133,10 +1288,23 @@ HTML_EXTRA_STYLESHEET = ../_doxygen/extra_stylesheet.css HTML_EXTRA_FILES = +# The HTML_COLORSTYLE tag can be used to specify if the generated HTML output +# should be rendered with a dark or light theme. +# Possible values are: LIGHT always generate light mode output, DARK always +# generate dark mode output, AUTO_LIGHT automatically set the mode according to +# the user preference, use light mode if no preference is set (the default), +# AUTO_DARK automatically set the mode according to the user preference, use +# dark mode if no preference is set and TOGGLE allow to user to switch between +# light and dark mode via a button. +# The default value is: AUTO_LIGHT. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_COLORSTYLE = AUTO_LIGHT + # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen # will adjust the colors in the style sheet and background images according to -# this color. Hue is specified as an angle on a colorwheel, see -# http://en.wikipedia.org/wiki/Hue for more information. For instance the value +# this color. Hue is specified as an angle on a color-wheel, see +# https://en.wikipedia.org/wiki/Hue for more information. For instance the value # 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300 # purple, and 360 is red again. # Minimum value: 0, maximum value: 359, default value: 220. @@ -1145,7 +1313,7 @@ HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors -# in the HTML output. For a value of 0 the output will use grayscales only. A +# in the HTML output. For a value of 0 the output will use gray-scales only. A # value of 255 will produce the most vivid colors. # Minimum value: 0, maximum value: 255, default value: 100. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1172,6 +1340,17 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = NO +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via JavaScript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have JavaScript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = YES + # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. @@ -1195,13 +1374,14 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: http://developer.apple.com/tools/xcode/), introduced with -# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at -# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html -# for more information. +# startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy +# genXcode/_index.html for more information. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1215,6 +1395,13 @@ GENERATE_DOCSET = NO DOCSET_FEEDNAME = "Doxygen generated docs" +# This tag determines the URL of the docset feed. A documentation feed provides +# an umbrella under which multiple documentation sets from a single provider +# (such as a company or product suite) can be grouped. +# This tag requires that the tag GENERATE_DOCSET is set to YES. + +DOCSET_FEEDURL = + # This tag specifies a string that should uniquely identify the documentation # set bundle. This should be a reverse domain-name style string, e.g. # com.mycompany.MyDocSet. Doxygen will append .docset to the name. @@ -1240,8 +1427,12 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# on Windows. In the beginning of 2021 Microsoft took the original page, with +# a.o. the download links, offline the HTML help workshop was already many years +# in maintenance mode). You can download the HTML help workshop from the web +# archives at Installation executable (see: +# http://web.archive.org/web/20160201063255/http://download.microsoft.com/downlo +# ad/0/A/9/0A939EF6-E31C-430F-A3DF-DFAE7960D564/htmlhelp.exe). # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1271,7 +1462,7 @@ CHM_FILE = HHC_LOCATION = # The GENERATE_CHI flag controls if a separate .chi index file is generated -# (YES) or that it should be included in the master .chm file (NO). +# (YES) or that it should be included in the main .chm file (NO). # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1316,7 +1507,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1324,8 +1516,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1333,30 +1525,30 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's filter section matches. Qt Help Project / Filter Attributes (see: -# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes). +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#filter-attributes). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1399,16 +1591,28 @@ DISABLE_INDEX = NO # to work a browser that supports JavaScript, DHTML, CSS and frames is required # (i.e. any modern browser). Windows users are probably better off using the # HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can -# further fine-tune the look of the index. As an example, the default style -# sheet generated by doxygen has an example that shows how to put an image at -# the root of the tree instead of the PROJECT_NAME. Since the tree basically has -# the same information as the tab index, you could consider setting -# DISABLE_INDEX to YES when enabling this option. +# further fine tune the look of the index (see "Fine-tuning the output"). As an +# example, the default style sheet generated by doxygen has an example that +# shows how to put an image at the root of the tree instead of the PROJECT_NAME. +# Since the tree basically has the same information as the tab index, you could +# consider setting DISABLE_INDEX to YES when enabling this option. # The default value is: NO. # This tag requires that the tag GENERATE_HTML is set to YES. GENERATE_TREEVIEW = NO +# When both GENERATE_TREEVIEW and DISABLE_INDEX are set to YES, then the +# FULL_SIDEBAR option determines if the side bar is limited to only the treeview +# area (value NO) or if it should extend to the full height of the window (value +# YES). Setting this to YES gives a layout similar to +# https://docs.readthedocs.io with more room for contents, but less room for the +# project logo, title, and description. If either GENERATE_TREEVIEW or +# DISABLE_INDEX is set to NO, this option has no effect. +# The default value is: NO. +# This tag requires that the tag GENERATE_HTML is set to YES. + +FULL_SIDEBAR = NO + # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that # doxygen will group on one line in the generated HTML documentation. # @@ -1433,6 +1637,24 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the OBFUSCATE_EMAILS tag is set to YES, doxygen will obfuscate email +# addresses. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +OBFUSCATE_EMAILS = YES + +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1442,19 +1664,14 @@ EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 16 -# Use the FORMULA_TRANPARENT tag to determine whether or not the images -# generated for formulas are transparent PNGs. Transparent PNGs are not -# supported properly for IE 6.0, but are supported on all modern browsers. -# -# Note that when changing this option you need to delete any form_*.png files in -# the HTML output directory before the changes have effect. -# The default value is: YES. -# This tag requires that the tag GENERATE_HTML is set to YES. +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. -FORMULA_TRANSPARENT = YES +FORMULA_MACROFILE = # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# http://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1464,11 +1681,29 @@ FORMULA_TRANSPARENT = YES USE_MATHJAX = NO +# With MATHJAX_VERSION it is possible to specify the MathJax version to be used. +# Note that the different versions of MathJax have different requirements with +# regards to the different settings, so it is possible that also other MathJax +# settings have to be changed when switching between the different MathJax +# versions. +# Possible values are: MathJax_2 and MathJax_3. +# The default value is: MathJax_2. +# This tag requires that the tag USE_MATHJAX is set to YES. + +MATHJAX_VERSION = MathJax_2 + # When MathJax is enabled you can set the default output format to be used for -# the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# the MathJax output. For more details about the output format see MathJax +# version 2 (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) and MathJax version 3 +# (see: +# http://docs.mathjax.org/en/latest/web/components/output.html). # Possible values are: HTML-CSS (which is slower, but has the best -# compatibility), NativeMML (i.e. MathML) and SVG. +# compatibility. This is the name for Mathjax version 2, for MathJax version 3 +# this will be translated into chtml), NativeMML (i.e. MathML. Only supported +# for NathJax 2. For MathJax version 3 chtml will be used instead.), chtml (This +# is the name for Mathjax version 3, for MathJax version 2 this will be +# translated into HTML-CSS) and SVG. # The default value is: HTML-CSS. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1481,22 +1716,29 @@ MATHJAX_FORMAT = HTML-CSS # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. The default value is: +# - in case of MathJax version 2: https://cdn.jsdelivr.net/npm/mathjax@2 +# - in case of MathJax version 3: https://cdn.jsdelivr.net/npm/mathjax@3 # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax # extension names that should be enabled during MathJax rendering. For example +# for MathJax version 2 (see +# https://docs.mathjax.org/en/v2.7-latest/tex.html#tex-and-latex-extensions): # MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols +# For example for MathJax version 3 (see +# http://docs.mathjax.org/en/latest/input/tex/extensions/index.html): +# MATHJAX_EXTENSIONS = ams # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_EXTENSIONS = # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1524,7 +1766,7 @@ MATHJAX_CODEFILE = 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 +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1543,7 +1785,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1556,8 +1799,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: http://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1608,21 +1852,35 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. # -# Note that when enabling USE_PDFLATEX this option is only used for generating -# bitmaps for formulas in the HTML output, but not in the Makefile that is -# written to the output directory. -# The default file is: latex. +# Note that when not enabling USE_PDFLATEX the default is latex when enabling +# USE_PDFLATEX the default is pdflatex and when in the later case latex is +# chosen this is overwritten by pdflatex. For specific output languages the +# default can have been set differently, this depends on the implementation of +# the output language. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate # index for LaTeX. +# Note: This tag is used in the Makefile / make.bat. +# See also: LATEX_MAKEINDEX_CMD for the part in the generated output file +# (.tex). # The default file is: makeindex. # This tag requires that the tag GENERATE_LATEX is set to YES. MAKEINDEX_CMD_NAME = makeindex +# The LATEX_MAKEINDEX_CMD tag can be used to specify the command name to +# generate index for LaTeX. In case there is no backslash (\) as first character +# it will be automatically added in the LaTeX code. +# Note: This tag is used in the generated output file (.tex). +# See also: MAKEINDEX_CMD_NAME for the part in the Makefile / make.bat. +# The default value is: makeindex. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_MAKEINDEX_CMD = makeindex + # If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX # documents. This may be useful for small projects and may help to save some # trees in general. @@ -1652,29 +1910,31 @@ PAPER_TYPE = a4 EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the -# generated LaTeX document. The header should contain everything until the first -# chapter. If it is left blank doxygen will generate a standard header. See -# section "Doxygen usage" for information on how to let doxygen write the -# default header to a separate file. +# The LATEX_HEADER tag can be used to specify a user-defined LaTeX header for +# the generated LaTeX document. The header should contain everything until the +# first chapter. If it is left blank doxygen will generate a standard header. It +# is highly recommended to start with a default header using +# doxygen -w latex new_header.tex new_footer.tex new_stylesheet.sty +# and then modify the file new_header.tex. See also section "Doxygen usage" for +# information on how to generate the default header that doxygen normally uses. # -# Note: Only use a user-defined header if you know what you are doing! The -# following commands have a special meaning inside the header: $title, -# $datetime, $date, $doxygenversion, $projectname, $projectnumber, -# $projectbrief, $projectlogo. Doxygen will replace $title with the empty -# string, for the replacement values of the other commands the user is referred -# to HTML_HEADER. +# Note: Only use a user-defined header if you know what you are doing! +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. The following +# commands have a special meaning inside the header (and footer): For a +# description of the possible markers and block names see the documentation. # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_HEADER = -# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the -# generated LaTeX document. The footer should contain everything after the last -# chapter. If it is left blank doxygen will generate a standard footer. See +# The LATEX_FOOTER tag can be used to specify a user-defined LaTeX footer for +# the generated LaTeX document. The footer should contain everything after the +# last chapter. If it is left blank doxygen will generate a standard footer. See # LATEX_HEADER for more information on how to generate a default footer and what -# special commands can be used inside the footer. -# -# Note: Only use a user-defined footer if you know what you are doing! +# special commands can be used inside the footer. See also section "Doxygen +# usage" for information on how to generate the default footer that doxygen +# normally uses. Note: Only use a user-defined footer if you know what you are +# doing! # This tag requires that the tag GENERATE_LATEX is set to YES. LATEX_FOOTER = @@ -1707,9 +1967,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1717,8 +1979,7 @@ USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode # command to the generated LaTeX files. This will instruct LaTeX to keep running -# if errors occur, instead of asking the user for help. This option is also used -# when generating formulas in HTML. +# if errors occur, instead of asking the user for help. # The default value is: NO. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1731,19 +1992,9 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO -# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source -# code with syntax highlighting in the LaTeX output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_LATEX is set to YES. - -LATEX_SOURCE_CODE = NO - # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. See -# http://en.wikipedia.org/wiki/BibTeX and \cite for more info. +# https://en.wikipedia.org/wiki/BibTeX and \cite for more info. # The default value is: plain. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -1757,6 +2008,14 @@ LATEX_BIB_STYLE = plain LATEX_TIMESTAMP = NO +# The LATEX_EMOJI_DIRECTORY tag is used to specify the (relative or absolute) +# path from which the emoji images will be read. If a relative path is entered, +# it will be relative to the LATEX_OUTPUT directory. If left blank the +# LATEX_OUTPUT directory will be used. +# This tag requires that the tag GENERATE_LATEX is set to YES. + +LATEX_EMOJI_DIRECTORY = + #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1796,9 +2055,9 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's config -# file, i.e. a series of assignments. You only have to provide replacements, -# missing definitions are set to their default value. +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# configuration file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. # # See also section "Doxygen usage" for information on how to generate the # default style sheet that doxygen normally uses. @@ -1807,22 +2066,12 @@ RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an RTF document. Syntax is -# similar to doxygen's config file. A template extensions file can be generated -# using doxygen -e rtf extensionFile. +# similar to doxygen's configuration file. A template extensions file can be +# generated using doxygen -e rtf extensionFile. # This tag requires that the tag GENERATE_RTF is set to YES. RTF_EXTENSIONS_FILE = -# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code -# with syntax highlighting in the RTF output. -# -# Note that which sources are shown also depends on other settings such as -# SOURCE_BROWSER. -# The default value is: NO. -# This tag requires that the tag GENERATE_RTF is set to YES. - -RTF_SOURCE_CODE = NO - #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- @@ -1894,6 +2143,13 @@ XML_OUTPUT = xml XML_PROGRAMLISTING = YES +# If the XML_NS_MEMB_FILE_SCOPE tag is set to YES, doxygen will include +# namespace members in file scope as well, matching the HTML output. +# The default value is: NO. +# This tag requires that the tag GENERATE_XML is set to YES. + +XML_NS_MEMB_FILE_SCOPE = NO + #--------------------------------------------------------------------------- # Configuration options related to the DOCBOOK output #--------------------------------------------------------------------------- @@ -1912,23 +2168,14 @@ GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook -# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the -# program listings (including syntax highlighting and cross-referencing -# information) to the DOCBOOK output. Note that enabling this will significantly -# increase the size of the DOCBOOK output. -# The default value is: NO. -# This tag requires that the tag GENERATE_DOCBOOK is set to YES. - -DOCBOOK_PROGRAMLISTING = NO - #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an -# AutoGen Definitions (see http://autogen.sf.net) file that captures the -# structure of the code including all documentation. Note that this feature is -# still experimental and incomplete at the moment. +# AutoGen Definitions (see http://autogen.sourceforge.net/) file that captures +# the structure of the code including all documentation. Note that this feature +# is still experimental and incomplete at the moment. # The default value is: NO. GENERATE_AUTOGEN_DEF = NO @@ -2007,7 +2254,8 @@ SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by the -# preprocessor. +# preprocessor. Note that the INCLUDE_PATH is not recursive, so the setting of +# RECURSIVE has no effect here. # This tag requires that the tag SEARCH_INCLUDES is set to YES. INCLUDE_PATH = @@ -2095,36 +2343,10 @@ EXTERNAL_GROUPS = YES EXTERNAL_PAGES = YES -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of 'which perl'). -# The default file (with absolute path) is: /usr/bin/perl. - -# PERL_PATH is now obsolete -# PERL_PATH = /usr/bin/perl - #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram -# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to -# NO turns the diagrams off. Note that this option also works with HAVE_DOT -# disabled, but it is recommended to install and use dot, since it yields more -# powerful graphs. -# The default value is: YES. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see: -# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the -# default search path. - -# MSCGEN_PATH is now obsolete -# MSCGEN_PATH = - # You can include diagrams made with dia in doxygen documentation. Doxygen will # then run dia to produce the diagram and insert it in the documentation. The # DIA_PATH tag allows you to specify the directory where the dia binary resides. @@ -2143,7 +2365,7 @@ HIDE_UNDOC_RELATIONS = YES # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO -# The default value is: YES. +# The default value is: NO. HAVE_DOT = NO @@ -2157,35 +2379,50 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 -# When you want a differently looking font in the dot files that doxygen -# generates you can specify the font name using DOT_FONTNAME. You need to make -# sure dot is able to find the font, which can be done by putting it in a -# standard location or by setting the DOTFONTPATH environment variable or by -# setting DOT_FONTPATH to the directory containing the font. -# The default value is: Helvetica. +# DOT_COMMON_ATTR is common attributes for nodes, edges and labels of +# subgraphs. When you want a differently looking font in the dot files that +# doxygen generates you can specify fontname, fontcolor and fontsize attributes. +# For details please see Node, +# Edge and Graph Attributes specification You need to make sure dot is able +# to find the font, which can be done by putting it in a standard location or by +# setting the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. Default graphviz fontsize is 14. +# The default value is: fontname=Helvetica,fontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTNAME = Helvetica +DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10" -# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of -# dot graphs. -# Minimum value: 4, maximum value: 24, default value: 10. +# DOT_EDGE_ATTR is concatenated with DOT_COMMON_ATTR. For elegant style you can +# add 'arrowhead=open, arrowtail=open, arrowsize=0.5'. Complete documentation about +# arrows shapes. +# The default value is: labelfontname=Helvetica,labelfontsize=10. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_FONTSIZE = 10 +DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10" -# By default doxygen will tell dot to use the default font as specified with -# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set -# the path where dot can find it using this tag. +# DOT_NODE_ATTR is concatenated with DOT_COMMON_ATTR. For view without boxes +# around nodes set 'shape=plain' or 'shape=plaintext' Shapes specification +# The default value is: shape=box,height=0.2,width=0.4. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4" + +# You can set the path where dot can find font specified with fontname in +# DOT_COMMON_ATTR and others dot attributes. # This tag requires that the tag HAVE_DOT is set to YES. DOT_FONTPATH = -# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for -# each documented class showing the direct and indirect inheritance relations. -# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO. +# If the CLASS_GRAPH tag is set to YES (or GRAPH) then doxygen will generate a +# graph for each documented class showing the direct and indirect inheritance +# relations. In case HAVE_DOT is set as well dot will be used to draw the graph, +# otherwise the built-in generator will be used. If the CLASS_GRAPH tag is set +# to TEXT the direct and indirect inheritance relations will be shown as texts / +# links. +# Possible values are: NO, YES, TEXT and GRAPH. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. CLASS_GRAPH = YES @@ -2199,7 +2436,8 @@ CLASS_GRAPH = YES COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for -# groups, showing the direct groups dependencies. +# groups, showing the direct groups dependencies. See also the chapter Grouping +# in the manual. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. @@ -2222,10 +2460,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2292,6 +2552,13 @@ GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES +# The DIR_GRAPH_MAX_DEPTH tag can be used to limit the maximum number of levels +# of child directories generated in directory dependency graphs by dot. +# Minimum value: 1, maximum value: 25, default value: 1. +# This tag requires that the tag DIRECTORY_GRAPH is set to YES. + +DIR_GRAPH_MAX_DEPTH = 1 + # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. For an explanation of the image formats see the section # output formats in the documentation of the dot tool (Graphviz (see: @@ -2299,9 +2566,7 @@ DIRECTORY_GRAPH = YES # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, -# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, -# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo, +# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. @@ -2347,13 +2612,18 @@ MSCFILE_DIRS = DIAFILE_DIRS = # When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the -# path where java can find the plantuml.jar file. If left blank, it is assumed -# PlantUML is not used or called during a preprocessing step. Doxygen will -# generate a warning when it encounters a \startuml command in this case and -# will not generate output for the diagram. +# path where java can find the plantuml.jar file or to the filename of jar file +# to be used. If left blank, it is assumed PlantUML is not used or called during +# a preprocessing step. Doxygen will generate a warning when it encounters a +# \startuml command in this case and will not generate output for the diagram. PLANTUML_JAR_PATH = +# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a +# configuration file for plantuml. + +PLANTUML_CFG_FILE = + # When using plantuml, the specified paths are searched for files specified by # the !include statement in a plantuml block. @@ -2383,18 +2653,6 @@ DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, because dot on Windows does not seem -# to support this out of the box. -# -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). -# The default value is: NO. -# This tag requires that the tag HAVE_DOT is set to YES. - -DOT_TRANSPARENT = NO - # Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) support @@ -2407,14 +2665,18 @@ DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated # graphs. +# Note: This tag requires that UML_LOOK isn't set, i.e. the doxygen internal +# graphical representation for inheritance and collaboration diagrams is used. # The default value is: YES. # This tag requires that the tag HAVE_DOT is set to YES. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc temporary +# files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/projects/amdsmi/docs/.sphinx/.gitignore b/projects/amdsmi/docs/.sphinx/.gitignore new file mode 100644 index 0000000000..732e9711d2 --- /dev/null +++ b/projects/amdsmi/docs/.sphinx/.gitignore @@ -0,0 +1 @@ +_toc.yml diff --git a/projects/amdsmi/docs/.sphinx/requirements.in b/projects/amdsmi/docs/.sphinx/requirements.in index 0bcf7dd930..6c2cd861c3 100755 --- a/projects/amdsmi/docs/.sphinx/requirements.in +++ b/projects/amdsmi/docs/.sphinx/requirements.in @@ -1 +1 @@ -rocm-docs-core[api_reference]==0.24.1 +rocm-docs-core[api_reference]==0.26.0 diff --git a/projects/amdsmi/docs/.sphinx/requirements.txt b/projects/amdsmi/docs/.sphinx/requirements.txt index 297193c462..72c1c3dffa 100644 --- a/projects/amdsmi/docs/.sphinx/requirements.txt +++ b/projects/amdsmi/docs/.sphinx/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.10 # by the following command: # # pip-compile requirements.in @@ -105,8 +105,6 @@ pynacl==1.5.0 # via pygithub pyparsing==3.0.9 # via doxysphinx -pytz==2023.3 - # via babel pyyaml==6.0 # via # myst-parser @@ -116,7 +114,7 @@ requests==2.28.2 # via # pygithub # sphinx -rocm-docs-core[api_reference]==0.24.1 +rocm-docs-core[api_reference]==0.26.0 # via -r requirements.in smmap==5.0.0 # via gitdb @@ -161,11 +159,7 @@ tqdm==4.66.1 # via mpire typing-extensions==4.5.0 # via pydata-sphinx-theme -urllib3==1.26.15 +urllib3==2.0.3 # via requests wrapt==1.15.0 # via deprecated -zipp==3.15.0 - # via - # importlib-metadata - # importlib-resources From 714c6b1a51ac83b8f01043f4740be27a0c23ba0c Mon Sep 17 00:00:00 2001 From: Maxime Chambonnet Date: Sun, 30 Jan 2022 08:11:33 +0100 Subject: [PATCH 02/33] Updated README.md with standard Markdown tables, cleaned a bit header levels. Change-Id: Ibd6e382413d7667a5a823ac69620a2cfb7046bc5 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 8cfcb51550b2a2c1a406465a6b8d994a13cf0f9e] --- projects/amdsmi/python_smi_tools/README.md | 79 +++++++++++++--------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/projects/amdsmi/python_smi_tools/README.md b/projects/amdsmi/python_smi_tools/README.md index 5c65f21f4c..18fd197b7d 100644 --- a/projects/amdsmi/python_smi_tools/README.md +++ b/projects/amdsmi/python_smi_tools/README.md @@ -1,4 +1,5 @@ -### ROCm System Management Interface +## Synopsis +Radeon Open Compute Platform - System Management Interface - Command Line tool. This tool acts as a command line interface for manipulating and monitoring the amdgpu kernel, and is intended to replace @@ -7,14 +8,14 @@ It uses Ctypes to call the rocm_smi_lib API. Recommended: At least one AMD GPU with ROCm driver installed Required: ROCm SMI library installed (librocm_smi64) -#### Installation +## Installation Follow installation procedure for rocm_smi_lib. Please refer to [https://github.com/RadeonOpenCompute/rocm_smi_lib](https://github.com/RadeonOpenCompute/rocm_smi_lib) for the installation guide. LD_LIBRARY_PATH should be set to the folder containing librocm_smi64. -### Version +## Version The SMI will report a "version" which is the version of the kernel installed: ```shell AMD ROCm System Management Interface v$(uname) @@ -26,7 +27,7 @@ which will be equivalent to the following bash command: $(uname -a) | cut -d ' ' -f 3) ``` -#### Usage +## Usage For detailed and up to date usage information, we recommend consulting the help: ```shell @@ -167,7 +168,7 @@ Output options: ``` -#### Detailed Option Descriptions +## Detailed Option Descriptions --setsclk/--setmclk # [# # ...]: This allows you to set a mask for the levels. For example, if a GPU has 8 clock levels, @@ -235,21 +236,34 @@ Output options: The Compute Profile accepts 1 or n parameters, either the Profile to select (see --showprofile for a list of preset Power Profiles) or a quoted string of values for the CUSTOM profile. NOTE: These values can vary based on the ASIC, and may include: - SCLK_PROFILE_ENABLE - Whether or not to apply the 3 following SCLK settings (0=disable,1=enable) - NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-' - SCLK_UP_HYST - Delay before sclk is increased (in milliseconds) - SCLK_DOWN_HYST - Delay before sclk is decresed (in milliseconds) - SCLK_ACTIVE_LEVEL - Workload required before sclk levels change (in %) - MCLK_PROFILE_ENABLE - Whether or not to apply the 3 following MCLK settings (0=disable,1=enable) - NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-' - MCLK_UP_HYST - Delay before mclk is increased (in milliseconds) - MCLK_DOWN_HYST - Delay before mclk is decresed (in milliseconds) - MCLK_ACTIVE_LEVEL - Workload required before mclk levels change (in %) - BUSY_SET_POINT - Threshold for raw activity level before levels change - FPS - Frames Per Second - USE_RLC_BUSY - When set to 1, DPM is switched up as long as RLC busy message is received - MIN_ACTIVE_LEVEL - Workload required before levels change (in %) + + SCLK_PROFILE_ENABLE - Whether or not to apply the 3 following SCLK settings (0=disable,1=enable) + NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-’ + +| Setting | Description | +|-------------------|----------------------------------------------------| +| SCLK_UP_HYST | Delay before sclk is increased (in milliseconds) | +| SCLK_DOWN_HYST | Delay before sclk is decresed (in milliseconds) | +| SCLK_ACTIVE_LEVEL | Workload required before sclk levels change (in %) | + + MCLK_PROFILE_ENABLE - Whether or not to apply the 3 following MCLK settings (0=disable,1=enable) + NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-' + +| Setting | Description | +|-------------------|----------------------------------------------------| +| MCLK_UP_HYST | Delay before mclk is increased (in milliseconds) | +| MCLK_DOWN_HYST | Delay before mclk is decresed (in milliseconds) | +| MCLK_ACTIVE_LEVEL | Workload required before mclk levels change (in %) | + + Other settings: + +| Setting | Description | +|------------------|---------------------------------------------------------------------------| +| BUSY_SET_POINT | Threshold for raw activity level before levels change | +| FPS | Frames Per Second | +| USE_RLC_BUSY | When set to 1, DPM is switched up as long as RLC busy message is received | +| MIN_ACTIVE_LEVEL | Workload required before levels change (in %) | NOTES: When a compute queue is detected, the COMPUTE Power Profile values will be automatically @@ -301,16 +315,19 @@ This shows the RAS information for a given block. This includes enablement of th ue - Uncorrectable errors ce - Correctable errors -### Clock Type Descriptions -DCEFCLK - DCE (Display) -FCLK - Data fabric (VG20 and later) - Data flow from XGMI, Memory, PCIe -SCLK - GFXCLK (Graphics core) - Note - SOCCLK split from SCLK as of Vega10. Pre-Vega10 they were both controlled by SCLK -MCLK - GPU Memory (VRAM) -PCLK - PCIe bus - Note - This gives 2 speeds, PCIe Gen1 x1 and the highest available based on the hardware -SOCCLK - System clock (VG10 and later) - Data Fabric (DF), MM HUB, AT HUB, SYSTEM HUB, OSS, DFD - Note - DF split from SOCCLK as of Vega20. Pre-Vega20 they were both controlled by SOCCLK +## Clock Type Descriptions +| Clock type | Description | +| --- | --- | +| DCEFCLK | DCE (Display) | +| FCLK | Data fabric (VG20 and later) - Data flow from XGMI, Memory, PCIe | +| SCLK | GFXCLK (Graphics core) | +| | **Note - SOCCLK split from SCLK as of Vega10. Pre-Vega10 they were both controlled by SCLK** | +| MCLK | GPU Memory (VRAM) | +| PCLK | PCIe bus | +| | **Note - This gives 2 speeds, PCIe Gen1 x1 and the highest available based on the hardware** | +| SOCCLK | System clock (VG10 and later) - Data Fabric (DF), MM HUB, AT HUB, SYSTEM HUB, OSS, DFD | +| | **Note - DF split from SOCCLK as of Vega20. Pre-Vega20 they were both controlled by SOCCLK** | + --gpureset: This flag will attempt to reset the GPU for a specified device. This will invoke the GPU reset through @@ -350,7 +367,7 @@ is calculated in a generic sense. as well as the total available for those partitions. The percentage shown there indicates the amount of used memory in terms of current allocations -### OverDrive settings #### +## OverDrive settings Enabling OverDrive requires both a card that support OverDrive and a driver parameter that enables its use. Because OverDrive features can damage your card, most workstation and server GPUs cannot use OverDrive. @@ -381,7 +398,7 @@ These are the flags that require OverDrive functionality to be enabled for the f --setmrange -#### Disclaimer +## Disclaimer The information contained herein is for informational purposes only, and is subject to change without notice. While every precaution has been taken in the preparation of this document, it may contain technical inaccuracies, omissions and typographical errors, and AMD is under no obligation to update or otherwise correct this information. Advanced Micro Devices, Inc. makes no representations or warranties with respect to the accuracy or completeness of the contents of this document, and assumes no liability of any kind, including the implied warranties of noninfringement, merchantability or fitness for particular purposes, with respect to the operation or use of AMD hardware, software or other products described herein. From d94f4310b2f7e14e0cf603f7e9467d6a93a025c1 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 23 Oct 2023 13:09:13 -0500 Subject: [PATCH 03/33] README - Clean-up cli readme Change-Id: I665cc5a48a240f0d2289439a4877c9f667b19851 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 275108f5b949f9661d0da65cbe4defaa952c8d28] --- projects/amdsmi/.gitignore | 2 + projects/amdsmi/python_smi_tools/README.md | 346 ++++++++++-------- .../amdsmi/python_smi_tools/build_manual.sh | 16 + 3 files changed, 202 insertions(+), 162 deletions(-) create mode 100755 projects/amdsmi/python_smi_tools/build_manual.sh diff --git a/projects/amdsmi/.gitignore b/projects/amdsmi/.gitignore index 1629ea81d3..71facfe540 100644 --- a/projects/amdsmi/.gitignore +++ b/projects/amdsmi/.gitignore @@ -21,3 +21,5 @@ device/ # Misc __pycache__ +README +README.html diff --git a/projects/amdsmi/python_smi_tools/README.md b/projects/amdsmi/python_smi_tools/README.md index 18fd197b7d..bbb8652019 100644 --- a/projects/amdsmi/python_smi_tools/README.md +++ b/projects/amdsmi/python_smi_tools/README.md @@ -1,4 +1,5 @@ ## Synopsis + Radeon Open Compute Platform - System Management Interface - Command Line tool. This tool acts as a command line interface for manipulating @@ -14,159 +15,187 @@ Follow installation procedure for rocm_smi_lib. Please refer to [https://github.com/RadeonOpenCompute/rocm_smi_lib](https://github.com/RadeonOpenCompute/rocm_smi_lib) for the installation guide. LD_LIBRARY_PATH should be set to the folder containing librocm_smi64. - ## Version + The SMI will report a "version" which is the version of the kernel installed: -```shell -AMD ROCm System Management Interface v$(uname) -``` + + AMD ROCm System Management Interface v$(uname) + For ROCk installations, this will be the AMDGPU module version (e.g. 5.0.71) For non-ROCk or monolithic ROCk installations, this will be the kernel version, which will be equivalent to the following bash command: -```shell -$(uname -a) | cut -d ' ' -f 3) -``` + + $(uname -a) | cut -d ' ' -f 3) ## Usage For detailed and up to date usage information, we recommend consulting the help: -```shell -/opt/rocm/bin/rocm-smi -h -``` + + /opt/rocm/bin/rocm-smi -h For convenience purposes, following is the output from the -h flag: -```shell -usage: rocmSmiLib_cli.py [-h] [-d DEVICE [DEVICE ...]] [--alldevices] [--showhw] [-a] [-i] [-v] [--showdriverversion] - [--showfwinfo [BLOCK [BLOCK ...]]] [--showmclkrange] [--showmemvendor] [--showsclkrange] - [--showproductname] [--showserial] [--showuniqueid] [--showvoltagerange] [--showbus] - [--showpagesinfo] [--showpendingpages] [--showretiredpages] [--showunreservablepages] [-f] [-P] - [-t] [-u] [--showmemuse] [--showvoltage] [-b] [-c] [-g] [-l] [-M] [-m] [-o] [-p] [-S] [-s] - [--showmeminfo TYPE [TYPE ...]] [--showpids] [--showpidgpus [SHOWPIDGPUS [SHOWPIDGPUS ...]]] - [--showreplaycount] [--showrasinfo [SHOWRASINFO [SHOWRASINFO ...]]] [--showvc] [--showxgmierr] - [--showtopo] [--showtopoweight] [--showtopohops] [--showtopotype] [--showtoponuma] [-r] - [--resetfans] [--resetprofile] [--resetpoweroverdrive] [--resetxgmierr] - [--setsclk LEVEL [LEVEL ...]] [--setmclk LEVEL [LEVEL ...]] [--setpcie LEVEL [LEVEL ...]] - [--setslevel SCLKLEVEL SCLK SVOLT] [--setmlevel MCLKLEVEL MCLK MVOLT] - [--setvc POINT SCLK SVOLT] [--setsrange MINMAX SCLK] [--setmrange MINMAX MCLK] [--setfan LEVEL] - [--setperflevel LEVEL] [--setoverdrive %] [--setmemoverdrive %] [--setpoweroverdrive WATTS] - [--setprofile SETPROFILE] [--rasenable BLOCK ERRTYPE] [--rasdisable BLOCK ERRTYPE] - [--rasinject BLOCK] [--gpureset] [--load FILE | --save FILE] [--autorespond RESPONSE] - [--loglevel LEVEL] [--json] [--csv] + usage: rocm-smi [-h] [-V] [-d DEVICE [DEVICE ...]] [--alldevices] [--showhw] [-a] [-i] [-v] [-e [EVENT ...]] + [--showdriverversion] [--showtempgraph] [--showfwinfo [BLOCK ...]] [--showmclkrange] [--showmemvendor] + [--showsclkrange] [--showproductname] [--showserial] [--showuniqueid] [--showvoltagerange] [--showbus] + [--showpagesinfo] [--showpendingpages] [--showretiredpages] [--showunreservablepages] [-f] [-P] [-t] + [-u] [--showmemuse] [--showvoltage] [-b] [-c] [-g] [-l] [-M] [-m] [-o] [-p] [-S] [-s] + [--showmeminfo TYPE [TYPE ...]] [--showpids [VERBOSE]] [--showpidgpus [SHOWPIDGPUS ...]] + [--showreplaycount] [--showrasinfo [SHOWRASINFO ...]] [--showvc] [--showxgmierr] [--showtopo] + [--showtopoaccess] [--showtopoweight] [--showtopohops] [--showtopotype] [--showtoponuma] + [--showenergycounter] [--shownodesbw] [--showcomputepartition] [--showmemorypartition] [-r] + [--resetfans] [--resetprofile] [--resetpoweroverdrive] [--resetxgmierr] [--resetperfdeterminism] + [--resetcomputepartition] [--resetmemorypartition] [--setclock TYPE LEVEL] [--setsclk LEVEL [LEVEL ...]] + [--setmclk LEVEL [LEVEL ...]] [--setpcie LEVEL [LEVEL ...]] [--setslevel SCLKLEVEL SCLK SVOLT] + [--setmlevel MCLKLEVEL MCLK MVOLT] [--setvc POINT SCLK SVOLT] [--setsrange SCLKMIN SCLKMAX] + [--setmrange MCLKMIN MCLKMAX] [--setfan LEVEL] [--setperflevel LEVEL] [--setoverdrive %] + [--setmemoverdrive %] [--setpoweroverdrive WATTS] [--setprofile SETPROFILE] [--setperfdeterminism SCLK] + [--setcomputepartition {CPX,SPX,DPX,TPX,QPX,cpx,spx,dpx,tpx,qpx}] + [--setmemorypartition {NPS1,NPS2,NPS4,NPS8,nps1,nps2,nps4,nps8}] [--rasenable BLOCK ERRTYPE] + [--rasdisable BLOCK ERRTYPE] [--rasinject BLOCK] [--gpureset] [--load FILE | --save FILE] + [--autorespond RESPONSE] [--loglevel LEVEL] [--json] [--csv] -AMD ROCm System Management Interface | ROCM-SMI version: 1.4.1 | Kernel version: 5.4.8 + AMD ROCm System Management Interface | ROCM-SMI version: 1.5.0 -optional arguments: - -h, --help show this help message and exit - --gpureset Reset specified GPU (One GPU must be specified) - --load FILE Load Clock, Fan, Performance and Profile settings from FILE - --save FILE Save Clock, Fan, Performance and Profile settings to FILE + options: + -h, --help show this help message and exit + --gpureset Reset specified GPU (One GPU must be specified) + --load FILE Load Clock, Fan, Performance and Profile settings + from FILE + --save FILE Save Clock, Fan, Performance and Profile settings to + FILE - -d DEVICE [DEVICE ...], --device DEVICE [DEVICE ...] Execute command on specified device + -V, --version Show version information -Display Options: - --alldevices - --showhw Show Hardware details - -a, --showallinfo Show Temperature, Fan and Clock values + -d DEVICE [DEVICE ...], --device DEVICE [DEVICE ...] Execute command on specified device -Topology: - -i, --showid Show DEVICE ID - -v, --showvbios Show VBIOS version - --showdriverversion Show kernel driver version - --showfwinfo [BLOCK [BLOCK ...]] Show FW information - --showmclkrange Show mclk range - --showmemvendor Show GPU memory vendor - --showsclkrange Show sclk range - --showproductname Show SKU/Vendor name - --showserial Show GPU's Serial Number - --showuniqueid Show GPU's Unique ID - --showvoltagerange Show voltage range - --showbus Show PCI bus number + Display Options: + --alldevices + --showhw Show Hardware details + -a, --showallinfo Show Temperature, Fan and Clock values -Pages information: - --showpagesinfo Show retired, pending and unreservable pages - --showpendingpages Show pending retired pages - --showretiredpages Show retired pages - --showunreservablepages Show unreservable pages + Topology: + -i, --showid Show DEVICE ID + -v, --showvbios Show VBIOS version + -e [EVENT ...], --showevents [EVENT ...] Show event list + --showdriverversion Show kernel driver version + --showtempgraph Show Temperature Graph + --showfwinfo [BLOCK ...] Show FW information + --showmclkrange Show mclk range + --showmemvendor Show GPU memory vendor + --showsclkrange Show sclk range + --showproductname Show SKU/Vendor name + --showserial Show GPU's Serial Number + --showuniqueid Show GPU's Unique ID + --showvoltagerange Show voltage range + --showbus Show PCI bus number -Hardware-related information: - -f, --showfan Show current fan speed - -P, --showpower Show current Average Graphics Package Power Consumption - -t, --showtemp Show current temperature - -u, --showuse Show current GPU use - --showmemuse Show current GPU memory used - --showvoltage Show current GPU voltage + Pages information: + --showpagesinfo Show retired, pending and unreservable pages + --showpendingpages Show pending retired pages + --showretiredpages Show retired pages + --showunreservablepages Show unreservable pages -Software-related/controlled information: - -b, --showbw Show estimated PCIe use - -c, --showclocks Show current clock frequencies - -g, --showgpuclocks Show current GPU clock frequencies - -l, --showprofile Show Compute Profile attributes - -M, --showmaxpower Show maximum graphics package power this GPU will consume - -m, --showmemoverdrive Show current GPU Memory Clock OverDrive level - -o, --showoverdrive Show current GPU Clock OverDrive level - -p, --showperflevel Show current DPM Performance Level - -S, --showclkvolt Show supported GPU and Memory Clocks and Voltages - -s, --showclkfrq Show supported GPU and Memory Clock - --showmeminfo TYPE [TYPE ...] Show Memory usage information for given block(s) TYPE - --showpids Show current running KFD PIDs - --showpidgpus [SHOWPIDGPUS [SHOWPIDGPUS ...]] Show GPUs used by specified KFD PIDs (all if no arg given) - --showreplaycount Show PCIe Replay Count - --showrasinfo [SHOWRASINFO [SHOWRASINFO ...]] Show RAS enablement information and error counts for the - specified block(s) (all if no arg given) - --showvc Show voltage curve - --showxgmierr Show XGMI error information since last read - --showtopo Show hardware topology information - --showtopoweight Shows the relative weight between GPUs - --showtopohops Shows the number of hops between GPUs - --showtopotype Shows the link type between GPUs - --showtoponuma Shows the numa nodes + Hardware-related information: + -f, --showfan Show current fan speed + -P, --showpower Show current Average Graphics Package Power + Consumption + -t, --showtemp Show current temperature + -u, --showuse Show current GPU use + --showmemuse Show current GPU memory used + --showvoltage Show current GPU voltage -Set options: - --setsclk LEVEL [LEVEL ...] Set GPU Clock Frequency Level(s) (requires manual Perf level) - --setmclk LEVEL [LEVEL ...] Set GPU Memory Clock Frequency Level(s) (requires manual Perf - level) - --setpcie LEVEL [LEVEL ...] Set PCIE Clock Frequency Level(s) (requires manual Perf level) - --setslevel SCLKLEVEL SCLK SVOLT Change GPU Clock frequency (MHz) and Voltage (mV) for a specific - Level - --setmlevel MCLKLEVEL MCLK MVOLT Change GPU Memory clock frequency (MHz) and Voltage for (mV) a - specific Level - --setvc POINT SCLK SVOLT Change SCLK Voltage Curve (MHz mV) for a specific point - --setsrange MINMAX SCLK Set min(0) or max(1) SCLK speed - --setmrange MINMAX MCLK Set min(0) or max(1) MCLK speed - --setfan LEVEL Set GPU Fan Speed (Level or %) - --setperflevel LEVEL Set Performance Level - --setoverdrive % Set GPU OverDrive level (requires manual|high Perf level) - --setmemoverdrive % Set GPU Memory Overclock OverDrive level (requires manual|high - Perf level) - --setpoweroverdrive WATTS Set the maximum GPU power using Power OverDrive in Watts - --setprofile SETPROFILE Specify Power Profile level (#) or a quoted string of CUSTOM - Profile attributes "# # # #..." (requires manual Perf level) - --rasenable BLOCK ERRTYPE Enable RAS for specified block and error type - --rasdisable BLOCK ERRTYPE Disable RAS for specified block and error type - --rasinject BLOCK Inject RAS poison for specified block (ONLY WORKS ON UNSECURE - BOARDS) + Software-related/controlled information: + -b, --showbw Show estimated PCIe use + -c, --showclocks Show current clock frequencies + -g, --showgpuclocks Show current GPU clock frequencies + -l, --showprofile Show Compute Profile attributes + -M, --showmaxpower Show maximum graphics package power this GPU will + consume + -m, --showmemoverdrive Show current GPU Memory Clock OverDrive level + -o, --showoverdrive Show current GPU Clock OverDrive level + -p, --showperflevel Show current DPM Performance Level + -S, --showclkvolt Show supported GPU and Memory Clocks and Voltages + -s, --showclkfrq Show supported GPU and Memory Clock + --showmeminfo TYPE [TYPE ...] Show Memory usage information for given block(s) TYPE + --showpids [VERBOSE] Show current running KFD PIDs (pass details to + VERBOSE for detailed information) + --showpidgpus [SHOWPIDGPUS ...] Show GPUs used by specified KFD PIDs (all if no arg + given) + --showreplaycount Show PCIe Replay Count + --showrasinfo [SHOWRASINFO ...] Show RAS enablement information and error counts for + the specified block(s) (all if no arg given) + --showvc Show voltage curve + --showxgmierr Show XGMI error information since last read + --showtopo Show hardware topology information + --showtopoaccess Shows the link accessibility between GPUs + --showtopoweight Shows the relative weight between GPUs + --showtopohops Shows the number of hops between GPUs + --showtopotype Shows the link type between GPUs + --showtoponuma Shows the numa nodes + --showenergycounter Energy accumulator that stores amount of energy + consumed + --shownodesbw Shows the numa nodes + --showcomputepartition Shows current compute partitioning + --showmemorypartition Shows current memory partition -Reset options: - -r, --resetclocks Reset clocks and OverDrive to default - --resetfans Reset fans to automatic (driver) control - --resetprofile Reset Power Profile back to default - --resetpoweroverdrive Set the maximum GPU power back to the device deafult state - --resetxgmierr Reset XGMI error count + Set options: + --setclock TYPE LEVEL Set Clock Frequency Level(s) for specified clock + (requires manual Perf level) + --setsclk LEVEL [LEVEL ...] Set GPU Clock Frequency Level(s) (requires manual + Perf level) + --setmclk LEVEL [LEVEL ...] Set GPU Memory Clock Frequency Level(s) (requires + manual Perf level) + --setpcie LEVEL [LEVEL ...] Set PCIE Clock Frequency Level(s) (requires manual + Perf level) + --setslevel SCLKLEVEL SCLK SVOLT Change GPU Clock frequency (MHz) and Voltage (mV) for + a specific Level + --setmlevel MCLKLEVEL MCLK MVOLT Change GPU Memory clock frequency (MHz) and Voltage + for (mV) a specific Level + --setvc POINT SCLK SVOLT Change SCLK Voltage Curve (MHz mV) for a specific + point + --setsrange SCLKMIN SCLKMAX Set min and max SCLK speed + --setmrange MCLKMIN MCLKMAX Set min and max MCLK speed + --setfan LEVEL Set GPU Fan Speed (Level or %) + --setperflevel LEVEL Set Performance Level + --setoverdrive % Set GPU OverDrive level (requires manual|high Perf + level) + --setmemoverdrive % Set GPU Memory Overclock OverDrive level (requires + manual|high Perf level) + --setpoweroverdrive WATTS Set the maximum GPU power using Power OverDrive in + Watts + --setprofile SETPROFILE Specify Power Profile level (#) or a quoted string of + CUSTOM Profile attributes "# # # #..." (requires + manual Perf level) + --setperfdeterminism SCLK Set clock frequency limit to get minimal performance + variation + --setcomputepartition {CPX,SPX,DPX,TPX,QPX,cpx,spx,dpx,tpx,qpx} Set compute partition + --setmemorypartition {NPS1,NPS2,NPS4,NPS8,nps1,nps2,nps4,nps8} Set memory partition + --rasenable BLOCK ERRTYPE Enable RAS for specified block and error type + --rasdisable BLOCK ERRTYPE Disable RAS for specified block and error type + --rasinject BLOCK Inject RAS poison for specified block (ONLY WORKS ON + UNSECURE BOARDS) -Auto-response options: - --autorespond RESPONSE Response to automatically provide for all prompts (NOT - RECOMMENDED) + Reset options: + -r, --resetclocks Reset clocks and OverDrive to default + --resetfans Reset fans to automatic (driver) control + --resetprofile Reset Power Profile back to default + --resetpoweroverdrive Set the maximum GPU power back to the device deafult + state + --resetxgmierr Reset XGMI error count + --resetperfdeterminism Disable performance determinism + --resetcomputepartition Resets to boot compute partition state + --resetmemorypartition Resets to boot memory partition state -Output options: - --loglevel LEVEL How much output will be printed for what program is doing, one - of debug/info/warning/error/critical - --json Print output in JSON format - --csv Print output in CSV format - - -``` + Auto-response options: + --autorespond RESPONSE Response to automatically provide for all prompts + (NOT RECOMMENDED) + Output options: + --loglevel LEVEL How much output will be printed for what program is + doing, one of debug/info/warning/error/critical + --json Print output in JSON format + --csv Print output in CSV format ## Detailed Option Descriptions @@ -237,24 +266,18 @@ Output options: of preset Power Profiles) or a quoted string of values for the CUSTOM profile. NOTE: These values can vary based on the ASIC, and may include: - - SCLK_PROFILE_ENABLE - Whether or not to apply the 3 following SCLK settings (0=disable,1=enable) - NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-’ - -| Setting | Description | -|-------------------|----------------------------------------------------| -| SCLK_UP_HYST | Delay before sclk is increased (in milliseconds) | -| SCLK_DOWN_HYST | Delay before sclk is decresed (in milliseconds) | -| SCLK_ACTIVE_LEVEL | Workload required before sclk levels change (in %) | - - MCLK_PROFILE_ENABLE - Whether or not to apply the 3 following MCLK settings (0=disable,1=enable) - NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-' - -| Setting | Description | -|-------------------|----------------------------------------------------| -| MCLK_UP_HYST | Delay before mclk is increased (in milliseconds) | -| MCLK_DOWN_HYST | Delay before mclk is decresed (in milliseconds) | -| MCLK_ACTIVE_LEVEL | Workload required before mclk levels change (in %) | +| Setting | Description | +|---------------------|----------------------------------------------------| +| SCLK_PROFILE_ENABLE | Whether or not to apply the 3 following SCLK settings (0=disable,1=enable) | +| | **NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-’** | +| SCLK_UP_HYST | Delay before sclk is increased (in milliseconds) | +| SCLK_DOWN_HYST | Delay before sclk is decresed (in milliseconds) | +| SCLK_ACTIVE_LEVEL | Workload required before sclk levels change (in %) | +| MCLK_PROFILE_ENABLE | Whether or not to apply the 3 following MCLK settings (0=disable,1=enable) | +| | **NOTE: This is a hidden field. If set to 0, the following 3 values are displayed as '-'** | +| MCLK_UP_HYST | Delay before mclk is increased (in milliseconds) | +| MCLK_DOWN_HYST | Delay before mclk is decresed (in milliseconds) | +| MCLK_ACTIVE_LEVEL | Workload required before mclk levels change (in %) | Other settings: @@ -316,8 +339,9 @@ ue - Uncorrectable errors ce - Correctable errors ## Clock Type Descriptions + | Clock type | Description | -| --- | --- | +| ---------- | --- | | DCEFCLK | DCE (Display) | | FCLK | Data fabric (VG20 and later) - Data flow from XGMI, Memory, PCIe | | SCLK | GFXCLK (Graphics core) | @@ -328,7 +352,6 @@ ce - Correctable errors | SOCCLK | System clock (VG10 and later) - Data Fabric (DF), MM HUB, AT HUB, SYSTEM HUB, OSS, DFD | | | **Note - DF split from SOCCLK as of Vega20. Pre-Vega20 they were both controlled by SOCCLK** | - --gpureset: This flag will attempt to reset the GPU for a specified device. This will invoke the GPU reset through the kernel debugfs file amdgpu_gpu_recover. Note that GPU reset will not always work, depending on the @@ -383,20 +406,19 @@ As an example, if the ppfeaturemask is set to 0xffffbfff (1111111111111111101111 then enabling the OverDrive bit would make it 0xffffffff (11111111111111111111111111111111). These are the flags that require OverDrive functionality to be enabled for the flag to work: ---showclkvolt ---showvoltagerange ---showvc ---showsclkrange ---showmclkrange ---setslevel ---setmlevel ---setoverdrive ---setpoweroverdrive ---resetpoweroverdrive ---setvc ---setsrange ---setmrange - + --showclkvolt + --showvoltagerange + --showvc + --showsclkrange + --showmclkrange + --setslevel + --setmlevel + --setoverdrive + --setpoweroverdrive + --resetpoweroverdrive + --setvc + --setsrange + --setmrange ## Disclaimer diff --git a/projects/amdsmi/python_smi_tools/build_manual.sh b/projects/amdsmi/python_smi_tools/build_manual.sh new file mode 100755 index 0000000000..0a00b2095c --- /dev/null +++ b/projects/amdsmi/python_smi_tools/build_manual.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# Build manpages using ronn + +set -eu +set -o pipefail + +if ! command -v ronn > /dev/null; then + echo "ERROR: no ronn found!" >&2 + echo "Please follow installation instructions here:" >&2 + echo "https://github.com/apjanke/ronn-ng" >&2 + exit 1 +fi + +set -x +ronn ./README.md From 942d30e078f3542985ff9c6c8d64eb8effa94c75 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 23 Oct 2023 16:28:04 -0500 Subject: [PATCH 04/33] CMake - Prevent failure to build on non-amd64 targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifaa59fb672ea01c07cffea6cd2429bec15a5deaf Signed-off-by: Galantsev, Dmitrii Co-authored-by: Étienne Mollier Change-Id: Ia691ab1db0061f04662e10e112da4b9ef06c4256 [ROCm/amdsmi commit: 1cf05dd9c704f0fad0f535330ee1955914a4fe86] --- projects/amdsmi/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index c5bb82ce3a..f5353608b1 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -72,7 +72,11 @@ endif() ## Compiler flags set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -m64 -msse -msse2 ") + "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti") +if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -m64 -msse -msse2") +endif() # Security options set(CMAKE_CXX_FLAGS From 56794eb847e5fa0a4b6ca2b83e11c8dc97722ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Mollier?= Date: Sun, 27 Aug 2023 11:24:39 +0200 Subject: [PATCH 05/33] CMake - do not enforce -fPIE. When built with LTO enabled, the linking of liboam.so chokes on the following error, which is somewhat similar to the Debian bug #1030876 affecting PA-RISC, although the symptoms subtly differs in that it suggests to build using -fPIC: /usr/bin/ld: /tmp/cc0wF8Kx.ltrans0.ltrans.o: relocation R_X86_64_PC32 against symbol `_ZTVSt9exception@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC The -fPIC argument is passed appropriately down to the build command, however it looks to be erased by the late introduction of -fPIE flag by upstream build system. Erasing this flag allows the build to go through, both with LTO and on PA-RISC. Bug: https://github.com/RadeonOpenCompute/rocm_smi_lib/issues/111 Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015653 Change-Id: I8b35fd4b62cfa1a9ddb145362464df5dd276e2f5 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: c4c19e79179d0895bfa82df71f307d334d8dd9d4] --- projects/amdsmi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index f5353608b1..6a9a003561 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -110,7 +110,7 @@ else () set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-z,noexecstack -Wl,-znoexecheap -Wl,-z,relro ") set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wtrampolines -Wl,-z,now -fPIE") + "${CMAKE_CXX_FLAGS} -Wtrampolines -Wl,-z,now") endif () # Use this instead of above for 32 bit From 791ad2407cf019bc3da06447ea086d2a5f34218b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Mollier?= Date: Mon, 23 Oct 2023 16:31:58 -0500 Subject: [PATCH 06/33] CMake - Set rocm_smi64 soversion to 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream soversion is at 5 for a while, but Debian's soversion has been set to 1 in the beginning of the rocm-smi-lib package. This is probably erroneous, and the library should probably be better off being synchronized with upstream so there is some kind of ABI compatibility between the two distributions. . FIXME: please use upstream soversion next time an ABI breakage justifies an SOVERSION bump, instead of just incrementing the present version by one. Author: Étienne Mollier Forwarded: not-needed Last-Update: 2023-09-17 Change-Id: I6c4d28bd26889359c0b83c474d5ae58a81741cf4 Co-authored-by: Étienne Mollier Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 1775ae4b8dd434a1b2748f9e8092dbe7a88fd350] --- projects/amdsmi/rocm_smi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/rocm_smi/CMakeLists.txt b/projects/amdsmi/rocm_smi/CMakeLists.txt index 08b2599542..ee53412e09 100755 --- a/projects/amdsmi/rocm_smi/CMakeLists.txt +++ b/projects/amdsmi/rocm_smi/CMakeLists.txt @@ -39,7 +39,7 @@ message("Package version: ${PKG_VERSION_STR}") # Debian package specific variables # Set a default value for the package version -get_version_from_tag("5.0.0.0" ${SO_VERSION_GIT_TAG_PREFIX} GIT) +get_version_from_tag("1.0.0.0" ${SO_VERSION_GIT_TAG_PREFIX} GIT) # VERSION_* variables should be set by get_version_from_tag if ( ${ROCM_PATCH_VERSION} ) From 33bfb69a7dd4c40610b0d214987ed3bababd3c25 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Tue, 24 Oct 2023 18:37:12 -0500 Subject: [PATCH 07/33] CMake - Configure __version__ for python scripts Change-Id: I646dc27b5dc93e8dde38ff09ae9c826dfc7faaa7 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 336ef57ed8d4ed1f2709211d14d8eca9648e091a] --- projects/amdsmi/CMakeLists.txt | 42 ++++++++++--------- projects/amdsmi/amdsmi_cli/CMakeLists.txt | 5 ++- projects/amdsmi/amdsmi_cli/__init__.py | 2 +- projects/amdsmi/amdsmi_cli/_version.py | 1 - projects/amdsmi/amdsmi_cli/_version.py.in | 1 + projects/amdsmi/cmake_modules/utils.cmake | 1 + projects/amdsmi/py-interface/CMakeLists.txt | 25 +++++++---- ...amdsmi_wrapper.py => amdsmi_wrapper.py.in} | 0 .../{pyproject.toml => pyproject.toml.in} | 2 +- projects/amdsmi/py-interface/setup.cfg.in | 6 +++ projects/amdsmi/update_wrapper.sh | 6 +-- 11 files changed, 54 insertions(+), 37 deletions(-) delete mode 100644 projects/amdsmi/amdsmi_cli/_version.py create mode 100644 projects/amdsmi/amdsmi_cli/_version.py.in rename projects/amdsmi/py-interface/{amdsmi_wrapper.py => amdsmi_wrapper.py.in} (100%) rename projects/amdsmi/py-interface/{pyproject.toml => pyproject.toml.in} (93%) create mode 100644 projects/amdsmi/py-interface/setup.cfg.in diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 50683e7d81..ab61539758 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -30,18 +30,31 @@ find_program(GIT NAMES git) set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver") get_package_version_number("23.4.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) message("Package version: ${PKG_VERSION_STR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${VERSION_MAJOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${VERSION_MINOR}") -set(${AMD_SMI_LIBS_TARGET}_VERSION_PATCH "0") +set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}") +set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}") +set(${AMD_SMI_LIBS_TARGET}_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}") set(${AMD_SMI_LIBS_TARGET}_VERSION_BUILD "0") +set(${AMD_SMI_LIBS_TARGET}_VERSION_HASH "${PKG_VERSION_HASH}") + +set(${AMD_SMI_LIBS_TARGET}_VERSION_STRING "${${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_MINOR}.${${AMD_SMI_LIBS_TARGET}_VERSION_PATCH}+${${AMD_SMI_LIBS_TARGET}_VERSION_HASH}") + +# Make proper version for appending +# Default Value is 99999 +set(ROCM_VERSION_FOR_PACKAGE "99999") +if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) + set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION}) +endif() +#Prepare final version for the CPACK use +set(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") # The following default version values should be updated as appropriate for # ABI breaks (update MAJOR and MINOR), and ABI/API additions (update MINOR). # Until ABI stabilizes VERSION_MAJOR will be 0. This should be over-ridden # by git tags (through "git describe") when they are present. -set(PKG_VERSION_MAJOR "${VERSION_MAJOR}") -set(PKG_VERSION_MINOR "${VERSION_MINOR}") -set(PKG_VERSION_PATCH 0) +set(PKG_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}") +set(PKG_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}") +set(PKG_VERSION_PATCH "${CPACK_PACKAGE_VERSION_PATCH}") set(PKG_VERSION_NUM_COMMIT 0) set(AMD_SMI_PACKAGE @@ -226,13 +239,6 @@ install( DESTINATION share/doc/${AMD_SMI} COMPONENT dev) -#Make proper version for appending -#Default Value is 99999, setting it first -set(ROCM_VERSION_FOR_PACKAGE "99999") -if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) - set(ROCM_VERSION_FOR_PACKAGE $ENV{ROCM_LIBPATCH_VERSION}) -endif() - #Debian package specific variables set(CPACK_DEBIAN_PACKAGE_PROVIDES "amd-smi") set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sudo, libdrm-dev, python3-yaml") @@ -259,7 +265,8 @@ endif() set(CPACK_RPM_PACKAGE_PROVIDES "amd-smi") set(CPACK_RPM_DEV_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}") set(CPACK_RPM_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan") -set(CPACK_RPM_PACKAGE_SUGGESTS "python3 >= 3.7.9") +# python version gated by rhel8 :( +set(CPACK_RPM_PACKAGE_SUGGESTS "python3 >= 3.6.8") set(CPACK_RPM_DEV_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS}) set(CPACK_RPM_ASAN_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS}) @@ -294,14 +301,9 @@ endif() # https://bugzilla.redhat.com/show_bug.cgi?id=1811358 # set(CPACK_RPM_PACKAGE_SUGGESTS "sudo, libdrm-dev") -#Prepare final version for the CPACK use -set(CPACK_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}" -) - ## Process the Rpm install/remove scripts to update the CPACK variables configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/post.in" RPM/post @ONLY) -configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/preun.in" RPM/preun @ONLY ) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/preun.in" RPM/preun @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/postun.in" RPM/postun @ONLY) set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post") set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/preun" ) diff --git a/projects/amdsmi/amdsmi_cli/CMakeLists.txt b/projects/amdsmi/amdsmi_cli/CMakeLists.txt index 3cd72a9fb1..96a9c4d4ba 100644 --- a/projects/amdsmi/amdsmi_cli/CMakeLists.txt +++ b/projects/amdsmi/amdsmi_cli/CMakeLists.txt @@ -9,10 +9,12 @@ set(PY_CLI_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}" CACHE STRING "CLI tool installation directory") +# populate version string +configure_file(_version.py.in ${PY_PACKAGE_DIR}/_version.py @ONLY) + # hard-linking instead of copying avoids unnecessarry regeneration of packaged files add_custom_command( OUTPUT ${PY_PACKAGE_DIR}/__init__.py - ${PY_PACKAGE_DIR}/_version.py ${PY_PACKAGE_DIR}/amdsmi_cli.py ${PY_PACKAGE_DIR}/amdsmi_commands.py ${PY_PACKAGE_DIR}/amdsmi_helpers.py @@ -26,7 +28,6 @@ add_custom_command( DEPENDS amdsmi_cli COMMAND mkdir -p ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${PY_PACKAGE_DIR}/ - COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/_version.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_cli.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_commands.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_helpers.py ${PY_PACKAGE_DIR}/ diff --git a/projects/amdsmi/amdsmi_cli/__init__.py b/projects/amdsmi/amdsmi_cli/__init__.py index 608c46bbe2..6a5649080e 100644 --- a/projects/amdsmi/amdsmi_cli/__init__.py +++ b/projects/amdsmi/amdsmi_cli/__init__.py @@ -1 +1 @@ -__version__ = "23.4.0.0" +from _version import __version__ diff --git a/projects/amdsmi/amdsmi_cli/_version.py b/projects/amdsmi/amdsmi_cli/_version.py deleted file mode 100644 index 608c46bbe2..0000000000 --- a/projects/amdsmi/amdsmi_cli/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "23.4.0.0" diff --git a/projects/amdsmi/amdsmi_cli/_version.py.in b/projects/amdsmi/amdsmi_cli/_version.py.in new file mode 100644 index 0000000000..479e19fe2e --- /dev/null +++ b/projects/amdsmi/amdsmi_cli/_version.py.in @@ -0,0 +1 @@ +__version__ = "@amd_smi_libraries_VERSION_STRING@" diff --git a/projects/amdsmi/cmake_modules/utils.cmake b/projects/amdsmi/cmake_modules/utils.cmake index afaa442e59..7131761b67 100755 --- a/projects/amdsmi/cmake_modules/utils.cmake +++ b/projects/amdsmi/cmake_modules/utils.cmake @@ -159,6 +159,7 @@ function(get_package_version_number DEFAULT_VERSION_STRING VERSION_PREFIX GIT) endif() set(PKG_VERSION_STR "${PKG_VERSION_STR}-${VERSION_HASH}") set(PKG_VERSION_STR ${PKG_VERSION_STR} PARENT_SCOPE) + set(PKG_VERSION_HASH ${VERSION_HASH} PARENT_SCOPE) set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} PARENT_SCOPE) set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} PARENT_SCOPE) set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} PARENT_SCOPE) diff --git a/projects/amdsmi/py-interface/CMakeLists.txt b/projects/amdsmi/py-interface/CMakeLists.txt index 7996d04bf1..048b456a62 100644 --- a/projects/amdsmi/py-interface/CMakeLists.txt +++ b/projects/amdsmi/py-interface/CMakeLists.txt @@ -36,8 +36,9 @@ if(NOT GOOD_CLANG_FOUND) OUTPUT amdsmi_wrapper.py ${PY_PACKAGE_DIR}/amdsmi_wrapper.py DEPENDS ${AMD_SMI} - ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py - COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py ${CMAKE_CURRENT_BINARY_DIR}/ + ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in + # remove .in suffix when copying + COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py # hacky alternative to configure_file that will run at MAKE compile instead of CMake configure COMMAND sed -i s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g @@ -58,7 +59,7 @@ else() configure_file(${PROJECT_SOURCE_DIR}/tools/generator.py generator.py @ONLY COPYONLY) add_custom_command( OUTPUT amdsmi.h - ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py + ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in amdsmi_wrapper.py ${PY_PACKAGE_DIR}/amdsmi_wrapper.py DEPENDS ${AMD_SMI} @@ -66,8 +67,9 @@ else() generator.py ${PROJECT_SOURCE_DIR}/include/amd_smi/amdsmi.h COMMAND cp ${PROJECT_SOURCE_DIR}/include/amd_smi/amdsmi.h ./ - COMMAND ${Python3_EXECUTABLE} generator.py "$<$:-e -DENABLE_ESMI_LIB>" -i amdsmi.h -l ${PROJECT_BINARY_DIR}/src/libamd_smi.so -o ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py - COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py ${CMAKE_CURRENT_BINARY_DIR}/ + COMMAND ${Python3_EXECUTABLE} generator.py "$<$:-e -DENABLE_ESMI_LIB>" -i amdsmi.h -l ${PROJECT_BINARY_DIR}/src/libamd_smi.so -o ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in + # remove .in suffix when copying + COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py # hacky alternative to configure_file that will run at MAKE compile instead of CMake configure COMMAND sed -i s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g @@ -76,20 +78,22 @@ else() COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) endif() +# populate version string +configure_file(pyproject.toml.in ${PY_BUILD_DIR}/pyproject.toml @ONLY) +configure_file(setup.cfg.in ${PY_BUILD_DIR}/setup.cfg @ONLY) + add_custom_target( python_wrapper DEPENDS amdsmi_wrapper.py) # hard-linking instead of copying avoids unnecessarry regeneration of packaged files add_custom_command( - OUTPUT ${PY_BUILD_DIR}/pyproject.toml - ${PY_PACKAGE_DIR}/__init__.py + OUTPUT ${PY_PACKAGE_DIR}/__init__.py ${PY_PACKAGE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/README.md ${PY_PACKAGE_DIR}/LICENSE DEPENDS python_wrapper - COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/pyproject.toml ${PY_BUILD_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/ @@ -99,6 +103,7 @@ add_custom_command( add_custom_target( python_package ALL DEPENDS ${PY_BUILD_DIR}/pyproject.toml + ${PY_BUILD_DIR}/setup.cfg ${PY_PACKAGE_DIR}/__init__.py ${PY_PACKAGE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/amdsmi_interface.py @@ -106,7 +111,9 @@ add_custom_target( ${PY_PACKAGE_DIR}/LICENSE) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/pyproject.toml + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/pyproject.toml + ${CMAKE_CURRENT_BINARY_DIR}/${PY_BUILD_DIR}/setup.cfg DESTINATION ${PY_WRAPPER_INSTALL_DIR} COMPONENT dev) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in similarity index 100% rename from projects/amdsmi/py-interface/amdsmi_wrapper.py rename to projects/amdsmi/py-interface/amdsmi_wrapper.py.in diff --git a/projects/amdsmi/py-interface/pyproject.toml b/projects/amdsmi/py-interface/pyproject.toml.in similarity index 93% rename from projects/amdsmi/py-interface/pyproject.toml rename to projects/amdsmi/py-interface/pyproject.toml.in index fa2cb5d040..f659dc4202 100644 --- a/projects/amdsmi/py-interface/pyproject.toml +++ b/projects/amdsmi/py-interface/pyproject.toml.in @@ -10,7 +10,7 @@ name = "amdsmi" authors = [ {name = "AMD", email = "amd-smi.support@amd.com"}, ] -version = "23.4.0.0" +version = "@amd_smi_libraries_VERSION_STRING@" license = {file = "amdsmi/LICENSE"} readme = {file = "amdsmi/README.md", content-type = "text/markdown"} description = "AMDSMI Python LIB - AMD GPU Monitoring Library" diff --git a/projects/amdsmi/py-interface/setup.cfg.in b/projects/amdsmi/py-interface/setup.cfg.in new file mode 100644 index 0000000000..c073f89a12 --- /dev/null +++ b/projects/amdsmi/py-interface/setup.cfg.in @@ -0,0 +1,6 @@ +# this file is only required for setuptools < 61.0 +# mostly a rhel8 limitation... + +[metadata] +name = "amdsmi" +version = "@amd_smi_libraries_VERSION_STRING@" diff --git a/projects/amdsmi/update_wrapper.sh b/projects/amdsmi/update_wrapper.sh index 0a836f5405..fdbb2985c9 100755 --- a/projects/amdsmi/update_wrapper.sh +++ b/projects/amdsmi/update_wrapper.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# this program generates py-interface/amdsmi_wrapper.py +# this program generates py-interface/amdsmi_wrapper.py.in set -eu @@ -44,7 +44,7 @@ cp -r /src /tmp/src \ && rm -rf build .cache \ && cmake -B build -DBUILD_WRAPPER=ON $ENABLE_ESMI_LIB \ && make -C build -j $(nproc) \ - && cp /tmp/src/py-interface/amdsmi_wrapper.py /src/py-interface/amdsmi_wrapper.py" + && cp /tmp/src/py-interface/amdsmi_wrapper.py.in /src/py-interface/amdsmi_wrapper.py.in" echo -e "Generated new wrapper! -[$DIR/py-interface/amdsmi_wrapper.py]" +[$DIR/py-interface/amdsmi_wrapper.py.in]" From 41f5a26408cb8f32dcc1da9bc1e6e9ec17d58ad7 Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Mon, 23 Oct 2023 21:37:31 -0500 Subject: [PATCH 08/33] Partition EBUSY with RSMI_STATUS_BUSY & invalid GPU Metrics check * Updates: - [API/CLI] rsmi_dev_*_partition_set & rsmi_dev_*_partition_reset - exposed RSMI_STATUS_BUSY for EBUSY writes + cleaned up accidental map insertions (maplookup[] can insert values that are not in the map, map.at(key) fixes this potential issue) - [API] rsmi_dev_gpu_metrics_info_get() - returns RSMI_STATUS_NOT_SUPPORTED for unsupported metric tables outside of 1v1/1v2/1v3 - [API] writeDevInfoStr() - exposes RSMI_STATUS_BUSY for EBUSY write errors; kept backward compatibility for other writes which do not care about these states - [API] rsmi_dev_od_volt_info_get() & rsmi_dev_od_volt_curve_regions_get() have better logging + Expose more details on why they are erroring - [Utils/logs/example] Expose AMD GPU gfx target version to aid in system troubleshooting - [Utils] Added test methods that look at od volt freq & regions into here - for easier access across several tests - [Utils] Updated getRSMIStatusString(new argument - fullstatus; default to true for backwards compatibility) -> true shows shortened RSMI STATUS response - [Utils] Added splitString to cut out noisy return responses (used in getRSMIStatusString(), when fullstatus = true) - [Utils] Added getFileCreationDate() to expose build date of the library - helpful for local builds or experimental builds - [Utils] Macro cleanup - [Example] Added a few gpu_metric checks - helpful for upcoming updates - [Device] SYSFS/DebugFS - now have better r/w displayed in logs - [LOGS] Expose library build date - see above for details - [Tests] Add more warnings/errors to test builds - [Tests] Moved up Partition tests for ordered test runs - helped identify issues with GPU BUSY writes - [Tests] compute_partition_read_write - handles RSMI_STATUS_BUSY with waits for busy status found & cleaned up how we checked for partition changes - with RSMI responses exposed more clearly - [Tests] perf_determinism - multi gpu now properly runs through with full resets as needed - [Tests] volt_freq_curv_read - better error handling with more verbose output Change-Id: Ie94c6abb6a9aab95c345996d3ad3843cf6734977 Signed-off-by: Charis Poag [ROCm/amdsmi commit: 57b6135e54494a4a8afb631b914bdeb0608a0543] --- projects/amdsmi/CMakeLists.txt | 2 +- projects/amdsmi/include/rocm_smi/rocm_smi.h | 28 ++- .../amdsmi/include/rocm_smi/rocm_smi_device.h | 3 +- .../amdsmi/include/rocm_smi/rocm_smi_kfd.h | 3 + .../amdsmi/include/rocm_smi/rocm_smi_utils.h | 21 +- projects/amdsmi/python_smi_tools/rocm_smi.py | 12 + .../rocm_smi/example/rocm_smi_example.cc | 128 ++++++++--- projects/amdsmi/src/rocm_smi.cc | 68 +++++- projects/amdsmi/src/rocm_smi_device.cc | 87 ++++++-- projects/amdsmi/src/rocm_smi_gpu_metrics.cc | 6 + projects/amdsmi/src/rocm_smi_kfd.cc | 21 ++ projects/amdsmi/src/rocm_smi_main.cc | 6 + projects/amdsmi/src/rocm_smi_utils.cc | 208 +++++++++++++++++- .../amdsmi/tests/rocm_smi_test/CMakeLists.txt | 8 + .../functional/computepartition_read_write.cc | 113 ++++++---- .../functional/perf_determinism.cc | 44 +++- .../functional/volt_freq_curv_read.cc | 142 ++++++------ projects/amdsmi/tests/rocm_smi_test/main.cc | 16 +- 18 files changed, 701 insertions(+), 215 deletions(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 6a9a003561..3ff760b83c 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -72,7 +72,7 @@ endif() ## Compiler flags set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti") + "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -std=c++17") if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2") diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/include/rocm_smi/rocm_smi.h index a3396ae4a2..9b169f9827 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi.h @@ -363,16 +363,16 @@ typedef rsmi_clk_type_t rsmi_clk_type; */ typedef enum { RSMI_COMPUTE_PARTITION_INVALID = 0, - RSMI_COMPUTE_PARTITION_CPX, //!< Core mode (CPX)- Per-chip XCC with - //!< shared memory - RSMI_COMPUTE_PARTITION_SPX, //!< Single GPU mode (SPX)- All XCCs work - //!< together with shared memory - RSMI_COMPUTE_PARTITION_DPX, //!< Dual GPU mode (DPX)- Half XCCs work - //!< together with shared memory - RSMI_COMPUTE_PARTITION_TPX, //!< Triple GPU mode (TPX)- One-third XCCs - //!< work together with shared memory - RSMI_COMPUTE_PARTITION_QPX //!< Quad GPU mode (QPX)- Quarter XCCs - //!< work together with shared memory + RSMI_COMPUTE_PARTITION_CPX = 1, //!< Core mode (CPX)- Per-chip XCC with + //!< shared memory + RSMI_COMPUTE_PARTITION_SPX = 2, //!< Single GPU mode (SPX)- All XCCs work + //!< together with shared memory + RSMI_COMPUTE_PARTITION_DPX = 3, //!< Dual GPU mode (DPX)- Half XCCs work + //!< together with shared memory + RSMI_COMPUTE_PARTITION_TPX = 4, //!< Triple GPU mode (TPX)- One-third XCCs + //!< work together with shared memory + RSMI_COMPUTE_PARTITION_QPX = 5, //!< Quad GPU mode (QPX)- Quarter XCCs + //!< work together with shared memory } rsmi_compute_partition_type_t; /// \cond Ignore in docs. typedef rsmi_compute_partition_type_t rsmi_compute_partition_type; @@ -3783,6 +3783,8 @@ rsmi_dev_compute_partition_get(uint32_t dv_ind, char *compute_partition, * unavailable for current device * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not * support this function + * @retval ::RSMI_STATUS_BUSY A resource or mutex could not be acquired + * because it is already being used - device is busy * */ rsmi_status_t @@ -3802,6 +3804,8 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, * @retval ::RSMI_STATUS_PERMISSION function requires root access * @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not * support this function + * @retval ::RSMI_STATUS_BUSY A resource or mutex could not be acquired + * because it is already being used - device is busy * */ rsmi_status_t rsmi_dev_compute_partition_reset(uint32_t dv_ind); @@ -3866,6 +3870,8 @@ rsmi_dev_memory_partition_get(uint32_t dv_ind, char *memory_partition, * support this function * @retval ::RSMI_STATUS_AMDGPU_RESTART_ERR could not successfully restart * the amdgpu driver + * @retval ::RSMI_STATUS_BUSY A resource or mutex could not be acquired + * because it is already being used - device is busy * */ rsmi_status_t @@ -3887,6 +3893,8 @@ rsmi_dev_memory_partition_set(uint32_t dv_ind, * support this function * @retval ::RSMI_STATUS_AMDGPU_RESTART_ERR could not successfully restart * the amdgpu driver + * @retval ::RSMI_STATUS_BUSY A resource or mutex could not be acquired + * because it is already being used - device is busy * */ rsmi_status_t rsmi_dev_memory_partition_reset(uint32_t dv_ind); diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi_device.h b/projects/amdsmi/include/rocm_smi/rocm_smi_device.h index 0880350a3e..21b8101407 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi_device.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi_device.h @@ -260,7 +260,8 @@ class Device { std::vector *retVec); int readDevInfoBinary(DevInfoTypes type, std::size_t b_size, void *p_binary_data); - int writeDevInfoStr(DevInfoTypes type, std::string valStr); + int writeDevInfoStr(DevInfoTypes type, std::string valStr, + bool returnWriteErr = false); rsmi_status_t run_amdgpu_property_reinforcement_query(const AMDGpuPropertyQuery_t& amdgpu_property_query); diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi_kfd.h b/projects/amdsmi/include/rocm_smi/rocm_smi_kfd.h index 90c7f6ff3b..e13ea003ba 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi_kfd.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi_kfd.h @@ -84,6 +84,9 @@ class KFDNode { int get_total_memory(uint64_t* total); int get_used_memory(uint64_t* used); + // Get gfx target version from kfd + int get_gfx_target_version(uint64_t* gfx_target_version); + private: uint32_t node_indx_; uint32_t amdgpu_dev_index_; diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h b/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h index 9c1ef0290d..9d255d9c90 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi_utils.h @@ -51,6 +51,8 @@ #include #include #include +#include +#include #include "rocm_smi/rocm_smi_device.h" @@ -97,10 +99,10 @@ rsmi_status_t GetDevBinaryBlob(amd::smi::DevInfoTypes type, uint32_t dv_ind, std::size_t b_size, void* p_binary_data); rsmi_status_t ErrnoToRsmiStatus(int err); -std::string getRSMIStatusString(rsmi_status_t ret); +std::string getRSMIStatusString(rsmi_status_t ret, bool fullStatus = true); std::tuple + std::string, std::string, std::string, std::string, std::string> getSystemDetails(void); void logSystemDetails(void); rsmi_status_t getBDFString(uint64_t bdf_id, std::string& bfd_str); @@ -109,11 +111,20 @@ void logHexDump(const char *desc, const void *addr, const size_t len, bool isSystemBigEndian(); std::string getBuildType(); std::string getMyLibPath(); +std::string getFileCreationDate(std::string path); int subDirectoryCountInPath(const std::string path); +std::queue getAllDeviceGfxVers(); std::string monitor_type_string(amd::smi::MonitorTypes type); std::string power_type_string(RSMI_POWER_TYPE type); +std::string splitString(std::string str, char delim); +std::string print_rsmi_od_volt_freq_data_t(rsmi_od_volt_freq_data_t *odv); +std::string print_rsmi_od_volt_freq_regions(uint32_t num_regions, + rsmi_freq_volt_region_t *regions); +bool is_sudo_user(); +rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind, + std::string *gfx_version); template -std::string print_int_as_hex(T i, bool showHexNotation=true) { + std::string print_int_as_hex(T i, bool showHexNotation = true) { std::stringstream ss; if (showHexNotation) { ss << "0x" << std::setfill('0') << std::setw(sizeof(T) * 2) << std::hex; @@ -132,7 +143,7 @@ std::string print_int_as_hex(T i, bool showHexNotation=true) { } ss << std::dec; return ss.str(); -}; +} template std::string print_unsigned_int(T i) { @@ -263,7 +274,7 @@ class ScopedAcquire { LockType* lock_; bool doRelease; /// @brief: Disable copiable and assignable ability. - DISALLOW_COPY_AND_ASSIGN(ScopedAcquire); + DISALLOW_COPY_AND_ASSIGN(ScopedAcquire) }; } // namespace smi diff --git a/projects/amdsmi/python_smi_tools/rocm_smi.py b/projects/amdsmi/python_smi_tools/rocm_smi.py index 6af7ac098b..6c1de2d7a7 100755 --- a/projects/amdsmi/python_smi_tools/rocm_smi.py +++ b/projects/amdsmi/python_smi_tools/rocm_smi.py @@ -966,6 +966,9 @@ def resetComputePartition(deviceList): printLog(device, 'Permission denied', None) elif ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: printLog(device, 'Not supported on the given system', None) + elif ret == rsmi_status_t.RSMI_STATUS_BUSY: + printLog(device, 'Device is currently busy, try again later', + None) else: rsmi_ret_ok(ret, device, 'reset_compute_partition') printErrLog(device, 'Failed to reset the compute partition to boot state') @@ -1002,6 +1005,9 @@ def resetMemoryPartition(deviceList): printLog(device, 'Permission denied', None, addExtraLine) elif ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: printLog(device, 'Not supported on the given system', None, addExtraLine) + elif ret == rsmi_status_t.RSMI_STATUS_BUSY: + printLog(device, 'Device is currently busy, try again later', + None) else: rsmi_ret_ok(ret, device, 'reset_memory_partition') printErrLog(device, 'Failed to reset memory partition to boot state') @@ -1603,6 +1609,9 @@ def setComputePartition(deviceList, computePartitionType): %computePartitionType, None) elif ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: printLog(device, 'Not supported on the given system', None) + elif ret == rsmi_status_t.RSMI_STATUS_BUSY: + printLog(device, 'Device is currently busy, try again later', + None) else: rsmi_ret_ok(ret, device, 'set_compute_partition') printErrLog(device, 'Failed to retrieve compute partition, even though device supports it.') @@ -1673,6 +1682,9 @@ def setMemoryPartition(deviceList, memoryPartition): printLog(device, 'Permission denied', None, addExtraLine) elif ret == rsmi_status_t.RSMI_STATUS_NOT_SUPPORTED: printLog(device, 'Not supported on the given system', None, addExtraLine) + elif ret == rsmi_status_t.RSMI_STATUS_BUSY: + printLog(device, 'Device is currently busy, try again later', + None, addExtraLine) else: rsmi_ret_ok(ret, device, 'set_memory_partition') printErrLog(device, 'Failed to retrieve memory partition, even though device supports it.') diff --git a/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc b/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc index fa01b42978..0515d75d3c 100755 --- a/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc +++ b/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc @@ -156,6 +156,15 @@ } \ } +void print_function_header_with_rsmi_ret( + rsmi_status_t myReturn, std::string header = "") { + std::cout << "\t** "; + if (!header.empty()) { + std::cout << header << ": "; + } + std::cout << amd::smi::getRSMIStatusString(myReturn, false) << "\n"; +} + static void print_test_header(const char *str, uint32_t dv_ind) { std::cout << "********************************" << "\n"; std::cout << "*** " << str << "\n"; @@ -254,14 +263,24 @@ perf_level_string(rsmi_dev_perf_level_t perf_lvl) { } } -static bool isUserRunningAsSudo() { - bool isRunningWithSudo = false; - auto myUID = getuid(); - auto myPrivledges = geteuid(); - if ((myUID == myPrivledges) && (myPrivledges == 0)) { - isRunningWithSudo = true; +static const std::string +clock_type_string(rsmi_clk_type_t clk) { + switch (clk) { + case RSMI_CLK_TYPE_SYS: + return "RSMI_CLK_TYPE_SYS"; + case RSMI_CLK_TYPE_DF: + return "RSMI_CLK_TYPE_DF"; + case RSMI_CLK_TYPE_DCEF: + return "RSMI_CLK_TYPE_DCEF"; + case RSMI_CLK_TYPE_SOC: + return "RSMI_CLK_TYPE_SOC"; + case RSMI_CLK_TYPE_MEM: + return "RSMI_CLK_TYPE_MEM"; + case RSMI_CLK_TYPE_PCIE: + return "RSMI_CLK_TYPE_PCIE"; + default: + return "RSMI_CLK_INVALID"; } - return isRunningWithSudo; } static bool isFileWritable(rsmi_status_t response) { @@ -271,7 +290,7 @@ static bool isFileWritable(rsmi_status_t response) { // isFileWritable(ret) - intends to capture this // response situation. bool fileWritable = true; - if (isUserRunningAsSudo() && (response == RSMI_STATUS_PERMISSION)) { + if (amd::smi::is_sudo_user() && (response == RSMI_STATUS_PERMISSION)) { std::cout << "[WARN] User is running with sudo " << "permissions, file is not writable." << "\n"; fileWritable = false; @@ -574,9 +593,19 @@ static rsmi_status_t test_set_freq(uint32_t dv_ind) { } static void print_frequencies(rsmi_frequencies_t *f) { - assert(f != nullptr); + bool hasDeepSleep = false; + if (f == nullptr) { + std::cout << "Freq was nullptr\n"; + return; + } for (uint32_t j = 0; j < f->num_supported; ++j) { - std::cout << "\t** " << j << ": " << std::to_string(f->frequency[j]); + if (f->has_deep_sleep && j == 0) { + std::cout << "\t** S: " << std::to_string(f->frequency[j]); + hasDeepSleep = true; + } else { + std::cout << "\t** " << (hasDeepSleep ? j-1 : j) + << ": " << std::to_string(f->frequency[j]); + } if (j == f->current) { std::cout << " *"; } @@ -714,6 +743,7 @@ int main() { rsmi_frequencies_t f; uint32_t num_monitor_devs = 0; rsmi_gpu_metrics_t p; + std::string val_str; RSMI_POWER_TYPE power_type = RSMI_INVALID_POWER; rsmi_num_monitor_devices(&num_monitor_devs); @@ -725,6 +755,8 @@ int main() { ret = rsmi_dev_revision_get(i, &val_ui16); CHK_RSMI_RET_I(ret) std::cout << "\t**Dev.Rev.ID: 0x" << std::hex << val_ui16 << "\n"; + ret = amd::smi::rsmi_get_gfx_target_version(i , &val_str); + std::cout << "\t**Target Graphics Version: " << val_str << "\n"; char current_compute_partition[256]; current_compute_partition[0] = '\0'; @@ -736,7 +768,7 @@ int main() { ? "UNKNOWN" : current_compute_partition); if (ret != RSMI_STATUS_SUCCESS) { std::cout << ", RSMI_STATUS = "; -} else { + } else { std::cout << "\n"; } CHK_RSMI_NOT_SUPPORTED_OR_UNEXPECTED_DATA_RET(ret) @@ -773,8 +805,38 @@ int main() { } ret = rsmi_dev_gpu_metrics_info_get(i, &p); - CHK_AND_PRINT_RSMI_ERR_RET(ret) - std::cout << "\t**GPU METRICS" << "\n"; + print_test_header("GPU METRICS", i); + print_function_header_with_rsmi_ret(ret, + "rsmi_dev_gpu_metrics_info_get(" + std::to_string(i) + ", &p)"); + std::cout << "\t**p.average_gfxclk_frequency: " << std::dec + << p.average_gfxclk_frequency << "\n"; + std::cout << "\t**p.average_socclk_frequency: " << std::dec + << p.average_socclk_frequency << "\n"; + std::cout << "\t**p.average_uclk_frequency: " << std::dec + << p.average_uclk_frequency << "\n"; + std::cout << "\t**p.average_vclk0_frequency: " << std::dec + << p.average_vclk0_frequency << "\n"; + std::cout << "\t**p.average_dclk0_frequency: " << std::dec + << p.average_dclk0_frequency << "\n"; + std::cout << "\t**p.average_vclk1_frequency: " << std::dec + << p.average_vclk1_frequency << "\n"; + std::cout << "\t**p.average_dclk1_frequency: " << std::dec + << p.average_dclk1_frequency << "\n"; + + std::cout << "\t**p.current_gfxclk: " << std::dec + << p.current_gfxclk << "\n"; + std::cout << "\t**p.current_socclk: " << std::dec + << p.current_socclk << "\n"; + std::cout << "\t**p.current_uclk: " << std::dec + << p.current_uclk << "\n"; + std::cout << "\t**p.current_vclk0: " << std::dec + << p.current_vclk0 << "\n"; + std::cout << "\t**p.current_dclk0: " << std::dec + << p.current_dclk0 << "\n"; + std::cout << "\t**p.current_vclk1: " << std::dec + << p.current_vclk1 << "\n"; + std::cout << "\t**p.current_dclk1: " << std::dec + << p.current_dclk1 << "\n"; ret = rsmi_dev_perf_level_get(i, &pfl); CHK_AND_PRINT_RSMI_ERR_RET(ret) @@ -784,25 +846,25 @@ int main() { CHK_AND_PRINT_RSMI_ERR_RET(ret) std::cout << "\t**OverDrive Level:" << val_ui32 << "\n"; - ret = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_MEM, &f); - CHK_AND_PRINT_RSMI_ERR_RET(ret) - std::cout << "\t**Supported GPU Memory clock frequencies: "; - std::cout << f.num_supported << "\n"; - print_frequencies(&f); - - ret = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_SYS, &f); - CHK_AND_PRINT_RSMI_ERR_RET(ret) - std::cout << "\t**Supported GPU clock frequencies: "; - std::cout << f.num_supported << "\n"; - print_frequencies(&f); - - ret = rsmi_dev_gpu_clk_freq_get(i, RSMI_CLK_TYPE_SOC, &f); - CHK_RSMI_NOT_SUPPORTED_OR_UNEXPECTED_DATA_RET(ret) - std::cout << "\t**Supported GPU clock frequencies (SOC clk): "; - std::cout << f.num_supported << "\n"; - std::cout << "\t**Current value (SOC clk): "; - std::cout << f.current << "\n"; - print_frequencies(&f); + print_test_header("GPU Clocks", i); + for (int clkType = static_cast(RSMI_CLK_TYPE_SYS); + clkType <= static_cast(RSMI_CLK_TYPE_PCIE); + clkType++) { + rsmi_clk_type_t type = static_cast(clkType); + ret = rsmi_dev_gpu_clk_freq_get(i, type, &f); + print_function_header_with_rsmi_ret(ret, + "rsmi_dev_gpu_clk_freq_get(" + std::to_string(i) + + ", " + clock_type_string(type) + ", &f)"); + if (ret != RSMI_STATUS_SUCCESS) { + continue; + } + std::cout << "\t** " << clock_type_string(type) + << " - Supported # of freqs: "; + std::cout << f.num_supported << "\n"; + std::cout << "\t** " << clock_type_string(type) << " f.current: " + << f.current << "\n"; + print_frequencies(&f); + } std::cout << "\t**Monitor name: "; char name[128]; @@ -892,7 +954,7 @@ int main() { } std::cout << "***** Testing write api's" << "\n"; - if (isUserRunningAsSudo() == false) { + if (amd::smi::is_sudo_user() == false) { std::cout << "Write APIs require users to execute with sudo. " << "Cannot proceed." << "\n"; return 0; diff --git a/projects/amdsmi/src/rocm_smi.cc b/projects/amdsmi/src/rocm_smi.cc index 93536bedc9..9a7bd5d3ac 100755 --- a/projects/amdsmi/src/rocm_smi.cc +++ b/projects/amdsmi/src/rocm_smi.cc @@ -929,6 +929,9 @@ rsmi_status_t rsmi_perf_determinism_mode_set(uint32_t dv_ind, uint64_t clkvalue) { TRY DEVICE_MUTEX + std::ostringstream ss; + ss << __PRETTY_FUNCTION__ << " | ======= start ======="; + LOG_TRACE(ss); // Set perf. level to performance determinism so that we can then set the power profile rsmi_status_t ret = rsmi_dev_perf_level_set_v1(dv_ind, @@ -1510,6 +1513,9 @@ rsmi_status_t rsmi_dev_od_volt_info_set(uint32_t dv_ind, uint32_t vpoint, static void get_vc_region(uint32_t start_ind, std::vector *val_vec, rsmi_freq_volt_region_t *p) { + std::ostringstream ss; + ss << __PRETTY_FUNCTION__ << " | ======= start ======="; + LOG_TRACE(ss); assert(p != nullptr); assert(val_vec != nullptr); THROW_IF_NULLPTR_DEREF(p) @@ -1520,6 +1526,9 @@ static void get_vc_region(uint32_t start_ind, assert((*val_vec)[kOD_OD_RANGE_label_array_index] == "OD_RANGE:"); if ((val_vec->size() < kOD_OD_RANGE_label_array_index + 2) || ((*val_vec)[kOD_OD_RANGE_label_array_index] != "OD_RANGE:") ) { + ss << __PRETTY_FUNCTION__ << " | ======= end ======= | returning " + << getRSMIStatusString(RSMI_STATUS_UNEXPECTED_DATA); + LOG_TRACE(ss); throw amd::smi::rsmi_exception(RSMI_STATUS_UNEXPECTED_DATA, __FUNCTION__); } od_value_pair_str_to_range((*val_vec)[start_ind], &p->freq_range); @@ -1539,6 +1548,7 @@ static rsmi_status_t get_od_clk_volt_curve_regions(uint32_t dv_ind, TRY std::vector val_vec; rsmi_status_t ret; + std::ostringstream ss; assert(num_regions != nullptr); assert(p != nullptr); @@ -1547,12 +1557,20 @@ static rsmi_status_t get_od_clk_volt_curve_regions(uint32_t dv_ind, ret = GetDevValueVec(amd::smi::kDevPowerODVoltage, dv_ind, &val_vec); if (ret != RSMI_STATUS_SUCCESS) { + ss << __PRETTY_FUNCTION__ + << " | Issue: could not retreive kDevPowerODVoltage" << "; returning " + << getRSMIStatusString(ret); + LOG_ERROR(ss); return ret; } // This is a work-around to handle systems where kDevPowerODVoltage is not // fully supported yet. if (val_vec.size() < 2) { + ss << __PRETTY_FUNCTION__ + << " | Issue: val_vec.size() < 2" << "; returning " + << getRSMIStatusString(RSMI_STATUS_NOT_YET_IMPLEMENTED); + LOG_ERROR(ss); return RSMI_STATUS_NOT_YET_IMPLEMENTED; } @@ -1560,8 +1578,17 @@ static rsmi_status_t get_od_clk_volt_curve_regions(uint32_t dv_ind, assert((val_vec_size - kOD_VDDC_CURVE_start_index) > 0); assert((val_vec_size - kOD_VDDC_CURVE_start_index)%2 == 0); + ss << __PRETTY_FUNCTION__ + << " | val_vec_size = " << std::dec + << val_vec_size + << " | kOD_VDDC_CURVE_start_index = " << kOD_VDDC_CURVE_start_index; + LOG_DEBUG(ss); if (((val_vec_size - kOD_VDDC_CURVE_start_index) <= 0) || (((val_vec_size - kOD_VDDC_CURVE_start_index)%2 != 0))) { + ss << __PRETTY_FUNCTION__ << " | Issue: od vdd curve returned unexpected " + << "data" << "; returning " + << getRSMIStatusString(RSMI_STATUS_UNEXPECTED_SIZE); + LOG_ERROR(ss); throw amd::smi::rsmi_exception(RSMI_STATUS_UNEXPECTED_SIZE, __FUNCTION__); } @@ -2749,6 +2776,9 @@ rsmi_dev_od_volt_info_get(uint32_t dv_ind, rsmi_od_volt_freq_data_t *odv) { ss << __PRETTY_FUNCTION__ << "| ======= start ======="; LOG_TRACE(ss); DEVICE_MUTEX + if (odv == nullptr) { + return RSMI_STATUS_INVALID_ARGS; + } CHK_SUPPORT_NAME_ONLY(odv) rsmi_status_t ret = get_od_clk_volt_info(dv_ind, odv); @@ -2779,7 +2809,7 @@ rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, uint32_t *num_regions, rsmi_freq_volt_region_t *buffer) { TRY std::ostringstream ss; - ss << __PRETTY_FUNCTION__ << "| ======= start ======="; + ss << __PRETTY_FUNCTION__ << " | ======= start ======="; LOG_TRACE(ss); CHK_SUPPORT_NAME_ONLY((num_regions == nullptr || buffer == nullptr) ? @@ -2791,6 +2821,12 @@ rsmi_status_t rsmi_dev_od_volt_curve_regions_get(uint32_t dv_ind, DEVICE_MUTEX rsmi_status_t ret = get_od_clk_volt_curve_regions(dv_ind, num_regions, buffer); + if (*num_regions == 0) { + ret = RSMI_STATUS_NOT_SUPPORTED; + } + ss << __PRETTY_FUNCTION__ << " | ======= end ======= | returning " + << getRSMIStatusString(ret); + LOG_TRACE(ss); return ret; CATCH } @@ -4468,7 +4504,7 @@ get_compute_partition(uint32_t dv_ind, std::string &compute_partition) { return ret; } - switch (mapStringToRSMIComputePartitionTypes[compute_partition_str]) { + switch (mapStringToRSMIComputePartitionTypes.at(compute_partition_str)) { case RSMI_COMPUTE_PARTITION_CPX: case RSMI_COMPUTE_PARTITION_SPX: case RSMI_COMPUTE_PARTITION_DPX: @@ -4585,9 +4621,12 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, ss << __PRETTY_FUNCTION__ << "| ======= start ======="; LOG_TRACE(ss); REQUIRE_ROOT_ACCESS + if (!amd::smi::is_sudo_user()) { + return RSMI_STATUS_PERMISSION; + } DEVICE_MUTEX std::string newComputePartitionStr - = mapRSMIToStringComputePartitionTypes[compute_partition]; + = mapRSMIToStringComputePartitionTypes.at(compute_partition); std::string currentComputePartition; switch (compute_partition) { @@ -4605,6 +4644,7 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, << " | Device #: " << dv_ind << " | Type: " << devInfoTypesStrings.at(amd::smi::kDevComputePartition) + << " | Data: " << newComputePartitionStr << " | Cause: requested setting was invalid" << " | Returning = " << getRSMIStatusString(RSMI_STATUS_INVALID_ARGS) << " |"; @@ -4623,6 +4663,7 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, << " | Device #: " << dv_ind << " | Type: " << devInfoTypesStrings.at(amd::smi::kDevComputePartition) + << " | Data: " << newComputePartitionStr << " | Cause: not an available compute partition setting" << " | Returning = " << getRSMIStatusString(available_ret) << " |"; @@ -4650,7 +4691,7 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, return ret_get; } rsmi_compute_partition_type_t currRSMIComputePartition - = mapStringToRSMIComputePartitionTypes[currentComputePartition]; + = mapStringToRSMIComputePartitionTypes.at(currentComputePartition); if (currRSMIComputePartition == compute_partition) { ss << __PRETTY_FUNCTION__ << " | ======= end ======= " @@ -4665,6 +4706,15 @@ rsmi_dev_compute_partition_set(uint32_t dv_ind, return RSMI_STATUS_SUCCESS; } + ss << __PRETTY_FUNCTION__ << " | about to try writing |" + << newComputePartitionStr + << "| size of string = " << newComputePartitionStr.size() + << "| size of c-string = "<< std::dec + << sizeof(newComputePartitionStr.c_str())/sizeof(newComputePartitionStr[0]) + << "| sizeof string = " << std::dec + << sizeof(newComputePartitionStr); + LOG_DEBUG(ss); + GET_DEV_FROM_INDX int ret = dev->writeDevInfo(amd::smi::kDevComputePartition, newComputePartitionStr); @@ -4699,7 +4749,7 @@ static rsmi_status_t get_memory_partition(uint32_t dv_ind, return ret; } - switch (mapStringToMemoryPartitionTypes[val_str]) { + switch (mapStringToMemoryPartitionTypes.at(val_str)) { case RSMI_MEMORY_PARTITION_NPS1: case RSMI_MEMORY_PARTITION_NPS2: case RSMI_MEMORY_PARTITION_NPS4: @@ -4755,7 +4805,7 @@ rsmi_dev_memory_partition_set(uint32_t dv_ind, } std::string newMemoryPartition - = mapRSMIToStringMemoryPartitionTypes[memory_partition]; + = mapRSMIToStringMemoryPartitionTypes.at(memory_partition); std::string currentMemoryPartition; switch (memory_partition) { @@ -4798,7 +4848,7 @@ rsmi_dev_memory_partition_set(uint32_t dv_ind, return ret_get; } rsmi_memory_partition_type_t currRSMIMemoryPartition - = mapStringToMemoryPartitionTypes[currentMemoryPartition]; + = mapStringToMemoryPartitionTypes.at(currentMemoryPartition); if (currRSMIMemoryPartition == memory_partition) { ss << __PRETTY_FUNCTION__ << " | ======= end ======= " @@ -4942,7 +4992,7 @@ rsmi_status_t rsmi_dev_compute_partition_reset(uint32_t dv_ind) { // Likely due to device not supporting it if (bootState != "UNKNOWN") { rsmi_compute_partition_type_t compute_partition = - mapStringToRSMIComputePartitionTypes[bootState]; + mapStringToRSMIComputePartitionTypes.at(bootState); ret = rsmi_dev_compute_partition_set(dv_ind, compute_partition); } ss << __PRETTY_FUNCTION__ @@ -4981,7 +5031,7 @@ rsmi_status_t rsmi_dev_memory_partition_reset(uint32_t dv_ind) { // Likely due to device not supporting it if (bootState != "UNKNOWN") { rsmi_memory_partition_type_t memory_partition = - mapStringToMemoryPartitionTypes[bootState]; + mapStringToMemoryPartitionTypes.at(bootState); ret = rsmi_dev_memory_partition_set(dv_ind, memory_partition); } ss << __PRETTY_FUNCTION__ diff --git a/projects/amdsmi/src/rocm_smi_device.cc b/projects/amdsmi/src/rocm_smi_device.cc index bd3ac5da9d..bd357c35d1 100755 --- a/projects/amdsmi/src/rocm_smi_device.cc +++ b/projects/amdsmi/src/rocm_smi_device.cc @@ -598,14 +598,17 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) { int ret = isRegularFile(sysfs_path, ®_file); if (ret != 0) { - ss << "File did not exist - SYSFS file (" << sysfs_path + ss << __PRETTY_FUNCTION__ << " | Issue: File did not exist - SYSFS file (" + << sysfs_path << ") for DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << "), returning " << std::to_string(ret); LOG_ERROR(ss); return ret; } if (!reg_file) { - ss << "File is not a regular file - SYSFS file (" << sysfs_path << ") for " + ss << __PRETTY_FUNCTION__ + << " | Issue: File is not a regular file - SYSFS file (" + << sysfs_path << ") for " << "DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << ")," << " returning ENOENT (" << std::strerror(ENOENT) << ")"; LOG_ERROR(ss); @@ -615,7 +618,8 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) { fs->open(sysfs_path); if (!fs->is_open()) { - ss << "Could not open - SYSFS file (" << sysfs_path << ") for " + ss << __PRETTY_FUNCTION__ + << " | Issue: Could not open - SYSFS file (" << sysfs_path << ") for " << "DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << "), " << ", returning " << std::to_string(errno) << " (" << std::strerror(errno) << ")"; @@ -623,7 +627,8 @@ int Device::openSysfsFileStream(DevInfoTypes type, T *fs, const char *str) { return errno; } - ss << "Successfully opened SYSFS file (" << sysfs_path + ss << __PRETTY_FUNCTION__ << " | Successfully opened SYSFS file (" + << sysfs_path << ") for DevInfoInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << ")"; LOG_INFO(ss); @@ -671,32 +676,51 @@ int Device::readDevInfoStr(DevInfoTypes type, std::string *retStr) { ret = openSysfsFileStream(type, &fs); if (ret != 0) { ss << "Could not read device info string for DevInfoType (" - << RocmSMI::devInfoTypesStrings.at(type)<< "), returning " + << RocmSMI::devInfoTypesStrings.at(type) << "), returning " << std::to_string(ret); LOG_ERROR(ss); return ret; } fs >> *retStr; - std::string info = "Successfully read device info string for DevInfoType (" + - RocmSMI::devInfoTypesStrings.at(type) + "): " + - *retStr; - LOG_INFO(info); fs.close(); - + ss << __PRETTY_FUNCTION__ + << "Successfully read device info string for DevInfoType (" + + RocmSMI::devInfoTypesStrings.at(type) + "): " + *retStr + << " | " + << (fs.is_open() ? " File stream is opened" : " File stream is closed") + << " | " << (fs.bad() ? "[ERROR] Bad read operation" : + "[GOOD] No bad bit read, successful read operation") + << " | " << (fs.fail() ? "[ERROR] Failed read - format error" : + "[GOOD] No fail - Successful read operation") + << " | " << (fs.eof() ? "[ERROR] Failed read - EOF error" : + "[GOOD] No eof error - Successful read operation") + << " | " << (fs.good() ? "[GOOD] read good - Successful read operation" : + "[ERROR] Failed read - good error"); + LOG_INFO(ss); return 0; } -int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr) { - auto tempPath = path_; +int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr, + bool returnWriteErr) { + // returnWriteErr = false, backwards compatability (old calls) + // returnWriteErr = true, improvement - allows us to detect errors + // when writing to file + // (such as EBUSY) + auto sysfs_path = path_; + sysfs_path += "/device/"; + sysfs_path += kDevAttribNameMap.at(type); std::ofstream fs; int ret; std::ostringstream ss; - fs.rdbuf()->pubsetbuf(nullptr,0); + fs.flush(); + fs.rdbuf()->pubsetbuf(0, 0); ret = openSysfsFileStream(type, &fs, valStr.c_str()); if (ret != 0) { - ss << "Could not write device info string (" << valStr + fs.close(); + ss << __PRETTY_FUNCTION__ << " | Issue: Could not open fileStream; " + << "Could not write device info string (" << valStr << ") for DevInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << "), returning " << std::to_string(ret); LOG_ERROR(ss); @@ -705,19 +729,39 @@ int Device::writeDevInfoStr(DevInfoTypes type, std::string valStr) { // We'll catch any exceptions in rocm_smi.cc code. if (fs << valStr) { + fs.flush(); + fs.close(); ss << "Successfully wrote device info string (" << valStr << ") for DevInfoType (" << RocmSMI::devInfoTypesStrings.at(type) << "), returning RSMI_STATUS_SUCCESS"; LOG_INFO(ss); ret = RSMI_STATUS_SUCCESS; } else { - ss << "Could not write device info string (" << valStr + if (returnWriteErr) { + ret = errno; + } else { + ret = RSMI_STATUS_NOT_SUPPORTED; + } + fs.flush(); + fs.close(); + ss << __PRETTY_FUNCTION__ << " | Issue: Could not write to file; " + << "Could not write device info string (" << valStr << ") for DevInfoType (" << RocmSMI::devInfoTypesStrings.at(type) - << "), returning RSMI_STATUS_NOT_SUPPORTED"; + << "), returning " << getRSMIStatusString(ErrnoToRsmiStatus(ret)); + ss << " | " + << (fs.is_open() ? "[ERROR] File stream open" : + "[GOOD] File stream closed") + << " | " << (fs.bad() ? "[ERROR] Bad write operation" : + "[GOOD] No bad bit write, successful write operation") + << " | " << (fs.fail() ? "[ERROR] Failed write - format error" : + "[GOOD] No fail - Successful write operation") + << " | " << (fs.eof() ? "[ERROR] Failed write - EOF error" : + "[GOOD] No eof error - Successful write operation") + << " | " << (fs.good() ? + "[GOOD] Write good - Successful write operation" : + "[ERROR] Failed write - good error"); LOG_ERROR(ss); - ret = RSMI_STATUS_NOT_SUPPORTED; } - fs.close(); return ret; } @@ -756,6 +800,9 @@ int Device::writeDevInfo(DevInfoTypes type, uint64_t val) { } int Device::writeDevInfo(DevInfoTypes type, std::string val) { + auto sysfs_path = path_; + sysfs_path += "/device/"; + sysfs_path += kDevAttribNameMap.at(type); switch (type) { case kDevGPUMClk: case kDevDCEFClk: @@ -764,9 +811,10 @@ int Device::writeDevInfo(DevInfoTypes type, std::string val) { case kDevPCIEClk: case kDevPowerODVoltage: case kDevSOCClk: + return writeDevInfoStr(type, val); case kDevComputePartition: case kDevMemoryPartition: - return writeDevInfoStr(type, val); + return writeDevInfoStr(type, val, true); default: return EINVAL; @@ -899,6 +947,7 @@ int Device::readDevInfo(DevInfoTypes type, uint64_t *val) { std::string tempStr; int ret; int tmp_val; + std::ostringstream ss; switch (type) { case kDevDevID: diff --git a/projects/amdsmi/src/rocm_smi_gpu_metrics.cc b/projects/amdsmi/src/rocm_smi_gpu_metrics.cc index 6123eae147..b055876398 100755 --- a/projects/amdsmi/src/rocm_smi_gpu_metrics.cc +++ b/projects/amdsmi/src/rocm_smi_gpu_metrics.cc @@ -496,6 +496,12 @@ rsmi_dev_gpu_metrics_info_get(uint32_t dv_ind, rsmi_gpu_metrics_t *smu) { // a specific version. *smu = {}; + uint8_t dev_content_revision = dev->gpu_metrics_ver().content_revision; + if (dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_1 || + dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_2 || + dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_3) { + return RSMI_STATUS_NOT_SUPPORTED; + } if (dev->gpu_metrics_ver().content_revision == RSMI_GPU_METRICS_API_CONTENT_VER_1) { ret = GetDevBinaryBlob(amd::smi::kDevGpuMetrics, dv_ind, diff --git a/projects/amdsmi/src/rocm_smi_kfd.cc b/projects/amdsmi/src/rocm_smi_kfd.cc index 40984b430b..3109781e39 100755 --- a/projects/amdsmi/src/rocm_smi_kfd.cc +++ b/projects/amdsmi/src/rocm_smi_kfd.cc @@ -971,5 +971,26 @@ int get_gpu_id(uint32_t node, uint64_t *gpu_id) { return retVal; } +// /sys/class/kfd/kfd/topology/nodes/*/properties | grep gfx_target_version +int KFDNode::get_gfx_target_version(uint64_t *gfx_target_version) { + std::ostringstream ss; + std::string properties_path = "/sys/class/kfd/kfd/topology/nodes/" + + std::to_string(this->node_indx_) + "/properties"; + uint64_t gfx_version = 0; + int ret = read_node_properties(this->node_indx_, "gfx_target_version", + &gfx_version); + *gfx_target_version = gfx_version; + ss << __PRETTY_FUNCTION__ + << " | File: " << properties_path + << " | Successfully read node #" << std::to_string(this->node_indx_) + << " for gfx_target_version" + << " | Data (gfx_target_version) *gfx_target_version = " + << std::to_string(*gfx_target_version) + << " | return = " << std::to_string(ret) + << " | "; + LOG_DEBUG(ss); + return ret; +} + } // namespace smi } // namespace amd diff --git a/projects/amdsmi/src/rocm_smi_main.cc b/projects/amdsmi/src/rocm_smi_main.cc index 3647f8e35d..44b40646d3 100755 --- a/projects/amdsmi/src/rocm_smi_main.cc +++ b/projects/amdsmi/src/rocm_smi_main.cc @@ -445,6 +445,12 @@ RocmSMI::Initialize(uint64_t flags) { // store each device boot partition state, if file doesn't exist dev->storeDevicePartitions(dv_ind); } + + // Assists displaying GPU information after device enumeration + // Otherwise GPU related info will not be discoverable + if (ROCmLogging::Logger::getInstance()->isLoggerEnabled()) { + logSystemDetails(); + } // Leaving below to help debug temp file issues // displayAppTmpFilesContent(); std::string amdGPUDeviceList = displayAllDevicePaths(devices_); diff --git a/projects/amdsmi/src/rocm_smi_utils.cc b/projects/amdsmi/src/rocm_smi_utils.cc index 3d74c7e7f1..680352055b 100755 --- a/projects/amdsmi/src/rocm_smi_utils.cc +++ b/projects/amdsmi/src/rocm_smi_utils.cc @@ -599,9 +599,19 @@ std::tuple readTmpFile(uint32_t dv_ind, } // wrapper to return string expression of a rsmi_status_t return -std::string getRSMIStatusString(rsmi_status_t ret) { +// rsmi_status_t ret - return value of RSMI API function +// bool fullStatus - defaults to true, set to false to chop off description +// Returns: +// string - if fullStatus == true, returns full decription of return value +// ex. 'RSMI_STATUS_SUCCESS: The function has been executed successfully.' +// string - if fullStatus == false, returns a minimalized return value +// ex. 'RSMI_STATUS_SUCCESS' +std::string getRSMIStatusString(rsmi_status_t ret, bool fullStatus) { const char *err_str; rsmi_status_string(ret, &err_str); + if (!fullStatus) { + return splitString(std::string(err_str), ':'); + } return std::string(err_str); } @@ -620,9 +630,13 @@ std::string getRSMIStatusString(rsmi_status_t ret) { // Expressed as big endian or little endian. // Big Endian (BE), multi-bit symbols encoded as big endian (MSB first) // Little Endian (LE), multi-bit symbols encoded as little endian (LSB first) +// string rocm_lib_path = Path to library +// string rocm_build_type = Release or debug +// string rocm_build_date = Creation date of library +// string dev_gfx_versions = GPU target graphics version std::tuple + std::string, std::string, std::string, std::string, std::string> getSystemDetails(void) { struct utsname buf; bool errorDetected = false; @@ -637,7 +651,9 @@ std::tuple devGraphicsVersions = getAllDeviceGfxVers(); + if (devGraphicsVersions.empty() == false) { + dev_gfx_versions = ""; + while (devGraphicsVersions.empty() == false) { + dev_gfx_versions += "\n\t" + devGraphicsVersions.front(); + devGraphicsVersions.pop(); + } + } return std::make_tuple(errorDetected, sysname, nodename, release, version, machine, domainName, os_distribution, endianness, rocm_build_type, rocm_lib_path, - rocm_env_variables); + rocm_build_date, rocm_env_variables, dev_gfx_versions); } // If logging is enabled through RSMI_LOGGING environment variable. @@ -687,10 +712,11 @@ void logSystemDetails(void) { std::ostringstream ss; bool errorDetected; std::string sysname, node, release, version, machine, domain, distName, - endianness, rocm_build_type, lib_path, rocm_env_vars; + endianness, rocm_build_type, lib_path, build_date, rocm_env_vars, + dev_gfx_versions; std::tie(errorDetected, sysname, node, release, version, machine, domain, - distName, endianness, rocm_build_type, lib_path, - rocm_env_vars) = getSystemDetails(); + distName, endianness, rocm_build_type, lib_path, build_date, + rocm_env_vars, dev_gfx_versions) = getSystemDetails(); if (errorDetected == false) { ss << "====== Gathered system details ============\n" << "SYSTEM NAME: " << sysname << "\n" @@ -703,7 +729,9 @@ void logSystemDetails(void) { << "ENDIANNESS: " << endianness << "\n" << "ROCM BUILD TYPE: " << rocm_build_type << "\n" << "ROCM-SMI-LIB PATH: " << lib_path << "\n" - << "ROCM ENV VARIABLES: " << rocm_env_vars << "\n"; + << "ROCM-SMI-LIB BUILD DATE: " << build_date << "\n" + << "ROCM ENV VARIABLES: " << rocm_env_vars + << "AMD GFX VERSIONS: " << dev_gfx_versions << "\n"; LOG_INFO(ss); } else { ss << "====== Gathered system details ============\n" @@ -831,6 +859,13 @@ std::string getMyLibPath(void) { return path; } +std::string getFileCreationDate(std::string path) { + struct stat t_stat; + stat(path.c_str(), &t_stat); + struct tm *timeinfo = localtime(&t_stat.st_ctime); // NOLINT + return removeNewLines(std::string(asctime(timeinfo))); // NOLINT +} + rsmi_status_t getBDFString(uint64_t bdf_id, std::string& bfd_str) { auto result = rsmi_status_t::RSMI_STATUS_SUCCESS; @@ -974,5 +1009,164 @@ std::string power_type_string(RSMI_POWER_TYPE type) { return powerTypesToString.at(type); } +std::string splitString(std::string str, char delim) { + std::vector tokens; + std::stringstream ss(str); + std::string token; + + if (str.empty()) { + return ""; + } + + while (std::getline(ss, token, delim)) { + tokens.push_back(token); + return token; // return 1st match + } +} + +static std::string pt_rng_Mhz(std::string title, rsmi_range *r) { + std::ostringstream ss; + if (r == nullptr) { + ss << "pt_rng_Mhz | rsmi_range r = nullptr\n"; + return ss.str(); + } + + ss << title; + ss << r->lower_bound/1000000 << " to " + << r->upper_bound/1000000 << " MHz" << "\n"; + return ss.str(); +} + +static std::string pt_rng_mV(std::string title, rsmi_range *r) { + std::ostringstream ss; + if (r == nullptr) { + ss << "pt_rng_mV | rsmi_range r = nullptr\n"; + return ss.str(); + } + + ss << title; + ss << r->lower_bound << " to " << r->upper_bound + << " mV" << "\n"; + return ss.str(); +} + +static std::string print_pnt(rsmi_od_vddc_point_t *pt) { + std::ostringstream ss; + ss << "\t\t** Frequency: " << pt->frequency/1000000 << " MHz\n"; + ss << "\t\t** Voltage: " << pt->voltage << " mV\n"; + return ss.str(); +} +static std::string pt_vddc_curve(rsmi_od_volt_curve *c) { + std::ostringstream ss; + if (c == nullptr) { + ss << "pt_vddc_curve | rsmi_od_volt_curve c = nullptr\n"; + return ss.str(); + } + + for (uint32_t i = 0; i < RSMI_NUM_VOLTAGE_CURVE_POINTS; ++i) { + ss << print_pnt(&c->vc_points[i]); + } + return ss.str(); +} + +std::string print_rsmi_od_volt_freq_data_t(rsmi_od_volt_freq_data_t *odv) { + std::ostringstream ss; + if (odv == nullptr) { + ss << "rsmi_od_volt_freq_data_t odv = nullptr\n"; + return ss.str(); + } + + ss << pt_rng_Mhz("\t**Current SCLK frequency range: ", &odv->curr_sclk_range); + ss << pt_rng_Mhz("\t**Current MCLK frequency range: ", &odv->curr_mclk_range); + ss << pt_rng_Mhz("\t**Min/Max Possible SCLK frequency range: ", + &odv->sclk_freq_limits); + ss << pt_rng_Mhz("\t**Min/Max Possible MCLK frequency range: ", + &odv->mclk_freq_limits); + + ss << "\t**Current Freq/Volt. curve: " << "\n"; + ss << pt_vddc_curve(&odv->curve); + + ss << "\t**Number of Freq./Volt. regions: " << odv->num_regions << "\n\n"; + return ss.str(); +} + +std::string print_odv_region(rsmi_freq_volt_region_t *region) { + std::ostringstream ss; + ss << pt_rng_Mhz("\t\tFrequency range: ", ®ion->freq_range); + ss << pt_rng_mV("\t\tVoltage range: ", ®ion->volt_range); + return ss.str(); +} + +std::string print_rsmi_od_volt_freq_regions(uint32_t num_regions, + rsmi_freq_volt_region_t *regions) { + std::ostringstream ss; + if (regions == nullptr) { + ss << "rsmi_freq_volt_region_t regions = nullptr\n"; + return ss.str(); + } + for (uint32_t i = 0; i < num_regions; ++i) { + ss << "\tRegion " << i << ": " << "\n"; + ss << print_odv_region(®ions[i]); + } + return ss.str(); +} + +bool is_sudo_user() { + std::ostringstream ss; + bool isRunningWithSudo = false; + auto myUID = getuid(); + auto myPrivledges = geteuid(); + if ((myUID == myPrivledges) && (myPrivledges == 0)) { + isRunningWithSudo = true; + } + ss << __PRETTY_FUNCTION__ << (isRunningWithSudo ? " | running as sudoer" : + " | NOT running as sudoer"); + LOG_DEBUG(ss); + return isRunningWithSudo; +} + +rsmi_status_t rsmi_get_gfx_target_version(uint32_t dv_ind, + std::string *gfx_version) { + std::ostringstream ss; + uint64_t kfd_gfx_version = 0; + GET_DEV_AND_KFDNODE_FROM_INDX + + int ret = kfd_node->get_gfx_target_version(&kfd_gfx_version); + if (ret == 0) { + ss << "gfx" << kfd_gfx_version; + *gfx_version = ss.str(); + return RSMI_STATUS_SUCCESS; + } else { + *gfx_version = "Unknown"; + return RSMI_STATUS_NOT_SUPPORTED; + } +} + +std::queue getAllDeviceGfxVers() { + uint32_t num_monitor_devs = 0; + rsmi_status_t ret; + std::queue deviceGfxVersions; + std::string response = ""; + std::string dev_gfx_ver = ""; + + ret = rsmi_num_monitor_devices(&num_monitor_devs); + if (ret != RSMI_STATUS_SUCCESS || num_monitor_devs == 0) { + response = "N/A - No AMD devices detected"; + deviceGfxVersions.push(response); + return deviceGfxVersions; + } + + for (uint32_t i = 0; i < num_monitor_devs; ++i) { + ret = amd::smi::rsmi_get_gfx_target_version(i , &dev_gfx_ver); + response = "Device[" + std::to_string(i) + "]: "; + if (ret != RSMI_STATUS_SUCCESS) { + deviceGfxVersions.push(response + getRSMIStatusString(ret, false)); + } else { + deviceGfxVersions.push(response + std::string(dev_gfx_ver)); + } + } + return deviceGfxVersions; +} + } // namespace smi } // namespace amd diff --git a/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt b/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt index 2253327813..bd7c827ce4 100755 --- a/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt +++ b/projects/amdsmi/tests/rocm_smi_test/CMakeLists.txt @@ -21,6 +21,14 @@ message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib) message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin) message("") +## Compiler flags +set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-rtti -std=c++17") +if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -m64 -msse -msse2") +endif() + set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(RSMITST "rsmitst") diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/computepartition_read_write.cc b/projects/amdsmi/tests/rocm_smi_test/functional/computepartition_read_write.cc index 06297a9371..ebfc9488f7 100755 --- a/projects/amdsmi/tests/rocm_smi_test/functional/computepartition_read_write.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/computepartition_read_write.cc @@ -54,6 +54,7 @@ #include "gtest/gtest.h" #include "rocm_smi/rocm_smi.h" +#include "rocm_smi/rocm_smi_utils.h" #include "rocm_smi_test/functional/computepartition_read_write.h" #include "rocm_smi_test/test_common.h" @@ -118,6 +119,24 @@ computePartitionString(rsmi_compute_partition_type computeParitionType) { } } +static void system_wait(int seconds) { + // Adding a delay - since changing partitions depends on gpus not + // being in an active state, we'll wait a few seconds before starting + // full testing + auto start = std::chrono::high_resolution_clock::now(); + int waitTime = seconds; + std::cout << "** Waiting for " + << std::dec << waitTime + << " seconds, for any GPU" + << " activity to clear up. **" << std::endl; + sleep(waitTime); + auto stop = std::chrono::high_resolution_clock::now(); + auto duration = + std::chrono::duration_cast(stop - start); + std::cout << "** Waiting took " << duration.count() / 1000000 + << " seconds **" << std::endl; +} + static const std::map mapStringToRSMIComputePartitionTypes { {"CPX", RSMI_COMPUTE_PARTITION_CPX}, @@ -141,21 +160,7 @@ void TestComputePartitionReadWrite::Run(void) { // Confirm system supports compute partition, before executing wait ret = rsmi_dev_compute_partition_get(0, orig_char_computePartition, 255); if (ret == RSMI_STATUS_SUCCESS) { - // Adding a delay - since changing partitions depends on gpus not - // being in an active state, we'll wait a few seconds before starting - // full testing - auto start = std::chrono::high_resolution_clock::now(); - int waitTime = 20; - std::cout << "** Waiting for " - << std::dec << waitTime - << " seconds, for any GPU" - << " activity to clear up. **" << std::endl; - sleep(waitTime); - auto stop = std::chrono::high_resolution_clock::now(); - auto duration = - std::chrono::duration_cast(stop - start); - std::cout << "** Waiting took " << duration.count() / 1000000 - << " seconds **" << std::endl; + system_wait(25); } for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) { @@ -165,6 +170,7 @@ void TestComputePartitionReadWrite::Run(void) { } } PrintDeviceHeader(dv_ind); + bool devicePartitionUpdated = false; // Standard checks to see if API is supported, before running full tests ret = rsmi_dev_compute_partition_get(dv_ind, orig_char_computePartition, @@ -231,9 +237,8 @@ void TestComputePartitionReadWrite::Run(void) { } // Verify api support checking functionality is working - rsmi_compute_partition_type_t newPartition - = rsmi_compute_partition_type_t::RSMI_COMPUTE_PARTITION_INVALID; - err = rsmi_dev_compute_partition_set(dv_ind, newPartition); + err = rsmi_dev_compute_partition_set(dv_ind, + RSMI_COMPUTE_PARTITION_INVALID); ASSERT_TRUE((err == RSMI_STATUS_INVALID_ARGS) || (err == RSMI_STATUS_NOT_SUPPORTED) || (err == RSMI_STATUS_PERMISSION)); @@ -270,27 +275,40 @@ void TestComputePartitionReadWrite::Run(void) { * //!< work together with shared memory */ - for (int partition = - rsmi_compute_partition_type_t::RSMI_COMPUTE_PARTITION_CPX; - partition <= rsmi_compute_partition_type_t::RSMI_COMPUTE_PARTITION_QPX; + for (int partition = static_cast(RSMI_COMPUTE_PARTITION_CPX); + partition <= static_cast(RSMI_COMPUTE_PARTITION_QPX); partition++) { - newPartition = static_cast(partition); + rsmi_compute_partition_type_t updatePartition + = static_cast(partition); IF_VERB(STANDARD) { std::cout << std::endl; std::cout << "\t**" << "======== TEST RSMI_COMPUTE_PARTITION_" - << computePartitionString(newPartition) + << computePartitionString(updatePartition) << " ===============" << std::endl; } + ret = rsmi_dev_compute_partition_set(dv_ind, updatePartition); IF_VERB(STANDARD) { std::cout << "\t**" - << "Attempting to set compute partition to: " - << computePartitionString(newPartition) << std::endl; + << "rsmi_dev_compute_partition_set(dv_ind, updatePartition): " + << amd::smi::getRSMIStatusString(ret, false) << "\n" + << "\t**New Partition (set): " + << computePartitionString(updatePartition) << "\n"; } - ret = rsmi_dev_compute_partition_set(dv_ind, newPartition); + ASSERT_TRUE((ret == RSMI_STATUS_SETTING_UNAVAILABLE) + || (ret== RSMI_STATUS_PERMISSION) + || (ret == RSMI_STATUS_SUCCESS) + || ret == RSMI_STATUS_BUSY); + + if (ret == RSMI_STATUS_BUSY) { + IF_VERB(STANDARD) { + std::cout << "\t**Device is currently busy.. continue\n"; + } + system_wait(5); + continue; + } + bool isSettingUnavailable = false; - ASSERT_TRUE((ret == RSMI_STATUS_SUCCESS) || - (ret == RSMI_STATUS_SETTING_UNAVAILABLE)); if (ret == RSMI_STATUS_SETTING_UNAVAILABLE) { isSettingUnavailable = true; } @@ -306,7 +324,7 @@ void TestComputePartitionReadWrite::Run(void) { } if (isSettingUnavailable) { ASSERT_EQ(RSMI_STATUS_SETTING_UNAVAILABLE, ret); - ASSERT_STRNE(computePartitionString(newPartition).c_str(), + ASSERT_STRNE(computePartitionString(updatePartition).c_str(), current_char_computePartition); IF_VERB(STANDARD) { std::cout << "\t**" @@ -314,23 +332,30 @@ void TestComputePartitionReadWrite::Run(void) { << "RSMI_STATUS_SETTING_UNAVAILABLE,\n\t current compute " << "partition (" << current_char_computePartition << ") did not update to (" - << computePartitionString(newPartition) << ")" + << computePartitionString(updatePartition) << ")" << std::endl; } } else { + if (strcmp(orig_char_computePartition, current_char_computePartition) != + 0) { + devicePartitionUpdated = true; + } else { + devicePartitionUpdated = false; + } + ASSERT_EQ(RSMI_STATUS_SUCCESS, ret); - ASSERT_STREQ(computePartitionString(newPartition).c_str(), + ASSERT_STREQ(computePartitionString(updatePartition).c_str(), current_char_computePartition); IF_VERB(STANDARD) { std::cout << "\t**" << "Confirmed current compute partition (" << current_char_computePartition << ") matches" << "\n\t requested compute partition (" - << computePartitionString(newPartition) << ")" + << computePartitionString(updatePartition) << ")" << std::endl; } } - } + } // END looping through partition changes /* TEST RETURN TO BOOT COMPUTE PARTITION SETTING */ IF_VERB(STANDARD) { @@ -342,8 +367,14 @@ void TestComputePartitionReadWrite::Run(void) { std::string oldPartition = current_char_computePartition; bool wasResetSuccess = false; ret = rsmi_dev_compute_partition_reset(dv_ind); + IF_VERB(STANDARD) { + std::cout << "\t**" + << "rsmi_dev_compute_partition_reset(dv_ind): " + << amd::smi::getRSMIStatusString(ret, false) << "\n"; + } ASSERT_TRUE((ret == RSMI_STATUS_SUCCESS) || - (ret == RSMI_STATUS_NOT_SUPPORTED)); + (ret == RSMI_STATUS_NOT_SUPPORTED) || + (ret == RSMI_STATUS_BUSY)); if (ret == RSMI_STATUS_SUCCESS) { wasResetSuccess = true; } @@ -352,9 +383,15 @@ void TestComputePartitionReadWrite::Run(void) { CHK_ERR_ASRT(ret) IF_VERB(STANDARD) { std::cout << "\t**" << "Current compute partition: " - << current_char_computePartition << std::endl; + << current_char_computePartition << "\n" + << "\t**" << "Original compute partition: " + << orig_char_computePartition << "\n" + << "\t**" << "Reset Successful: " + << (wasResetSuccess ? "TRUE" : "FALSE") << "\n" + << "\t**" << "Partitions Updated: " + << (devicePartitionUpdated ? "TRUE" : "FALSE") << "\n"; } - if (wasResetSuccess) { + if (wasResetSuccess && devicePartitionUpdated) { ASSERT_STRNE(oldPartition.c_str(), current_char_computePartition); IF_VERB(STANDARD) { std::cout << "\t**" @@ -379,7 +416,7 @@ void TestComputePartitionReadWrite::Run(void) { << "=========== TEST RETURN TO ORIGINAL COMPUTE PARTITION " << "SETTING ========" << std::endl; } - newPartition + rsmi_compute_partition_type_t newPartition = mapStringToRSMIComputePartitionTypes.at( std::string(orig_char_computePartition)); ret = rsmi_dev_compute_partition_set(dv_ind, newPartition); @@ -401,5 +438,5 @@ void TestComputePartitionReadWrite::Run(void) { ASSERT_EQ(RSMI_STATUS_SUCCESS, ret); ASSERT_STREQ(computePartitionString(newPartition).c_str(), current_char_computePartition); - } + } // END looping through devices } diff --git a/projects/amdsmi/tests/rocm_smi_test/functional/perf_determinism.cc b/projects/amdsmi/tests/rocm_smi_test/functional/perf_determinism.cc index b52fcb2690..790fc13fc3 100644 --- a/projects/amdsmi/tests/rocm_smi_test/functional/perf_determinism.cc +++ b/projects/amdsmi/tests/rocm_smi_test/functional/perf_determinism.cc @@ -5,7 +5,7 @@ * The University of Illinois/NCSA * Open Source License (NCSA) * - * Copyright (c) 2020, Advanced Micro Devices, Inc. + * Copyright (c) 2020-2023, Advanced Micro Devices, Inc. * All rights reserved. * * Developed by: @@ -56,6 +56,7 @@ #include "rocm_smi/rocm_smi.h" #include "rocm_smi_test/functional/perf_determinism.h" #include "rocm_smi_test/test_common.h" +#include "rocm_smi/rocm_smi_utils.h" TestPerfDeterminism::TestPerfDeterminism() : TestBase() { @@ -103,23 +104,49 @@ void TestPerfDeterminism::Run(void) { for (uint32_t i = 0; i < num_monitor_devs(); ++i) { PrintDeviceHeader(i); + std::cout << "\t**Resetting performance determinism\n"; + err = rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO): " + << amd::smi::getRSMIStatusString(err, false) + << "\n"; + } + CHK_ERR_ASRT(err) + ret = rsmi_dev_perf_level_get(i, &pfl); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_perf_level_get(i, &pfl): " + << amd::smi::getRSMIStatusString(ret, false) << "\n"; + } + CHK_ERR_ASRT(ret) err = rsmi_dev_od_volt_info_get(i, &odv); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_info_get(i, &odv): " + << amd::smi::getRSMIStatusString(err, false) + << "\n" + << amd::smi::print_rsmi_od_volt_freq_data_t(&odv) + << "\n"; + } if (err == RSMI_STATUS_NOT_SUPPORTED) { IF_VERB(STANDARD) { - std::cout << "\t** Not supported on this machine" << std::endl; + std::cout << "\t** Not supported on this machine\n"; } return; - } - else{ + } else if (err == RSMI_STATUS_SUCCESS) { clkvalue = (odv.curr_sclk_range.lower_bound/1000000) + 50; + } else { + IF_VERB(STANDARD) { + std::cout << "\t** Unable to retrieve lower bound sclk, continue.. \n"; + } + continue; } + std::cout << "About to rsmi_perf_determinism_mode_set() -->\n"; err = rsmi_perf_determinism_mode_set(i, clkvalue); if (err == RSMI_STATUS_NOT_SUPPORTED) { IF_VERB(STANDARD) { std::cout << "\t**Not supported on this machine" << std::endl; } - return; + continue; } else { ret = rsmi_dev_perf_level_get(i, &pfl); CHK_ERR_ASRT(ret) @@ -130,7 +157,7 @@ void TestPerfDeterminism::Run(void) { } std::cout << "\t**Resetting performance determinism" << std::endl; - err = rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO);; + err = rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO); CHK_ERR_ASRT(err) ret = rsmi_dev_perf_level_get(i, &pfl); CHK_ERR_ASRT(ret) @@ -138,7 +165,6 @@ void TestPerfDeterminism::Run(void) { std::cout << "\t**New Perf Level:" << GetPerfLevelStr(pfl) << std::endl; } - return; - } - } + } // END - SET SUPPORTED + } // END - DEVICE LOOP } 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 84f77d6afc..50b6ac057c 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 @@ -5,7 +5,7 @@ * The University of Illinois/NCSA * Open Source License (NCSA) * - * Copyright (c) 2019, Advanced Micro Devices, Inc. + * Copyright (c) 2019-2023, Advanced Micro Devices, Inc. * All rights reserved. * * Developed by: @@ -53,6 +53,7 @@ #include "rocm_smi/rocm_smi.h" #include "rocm_smi_test/functional/volt_freq_curv_read.h" #include "rocm_smi_test/test_common.h" +#include "rocm_smi/rocm_smi_utils.h" TestVoltCurvRead::TestVoltCurvRead() : TestBase() { set_title("RSMI Voltage-Frequency Curve Read Test"); @@ -84,69 +85,10 @@ void TestVoltCurvRead::Close() { TestBase::Close(); } -static void pt_rng_Mhz(std::string title, rsmi_range *r) { - assert(r != nullptr); - - std::cout << title << std::endl; - std::cout << "\t\t** " << r->lower_bound/1000000 << " to " << - r->upper_bound/1000000 << " MHz" << std::endl; -} - -static void pt_rng_mV(std::string title, rsmi_range *r) { - assert(r != nullptr); - - std::cout << title << std::endl; - std::cout << "\t\t** " << r->lower_bound << " to " << r->upper_bound << - " mV" << std::endl; -} - -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; -} -static void pt_vddc_curve(rsmi_od_volt_curve *c) { - assert(c != nullptr); - - for (uint32_t i = 0; i < RSMI_NUM_VOLTAGE_CURVE_POINTS; ++i) { - print_pnt(&c->vc_points[i]); - } -} - -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); - pt_rng_Mhz("\t\tCurrent SCLK frequency range:", &odv->curr_sclk_range); - pt_rng_Mhz("\t\tCurrent MCLK frequency range:", &odv->curr_mclk_range); - pt_rng_Mhz("\t\tMin/Max Possible SCLK frequency range:", - &odv->sclk_freq_limits); - pt_rng_Mhz("\t\tMin/Max Possible MCLK frequency range:", - &odv->mclk_freq_limits); - - std::cout << "\t\tCurrent Freq/Volt. curve:" << std::endl; - pt_vddc_curve(&odv->curve); - - std::cout << "\tNumber of Freq./Volt. regions: " << - odv->num_regions << std::endl; -} - -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_t *regions) { - for (uint32_t i = 0; i < num_regions; ++i) { - std::cout << "\tRegion " << i << ":" << std::endl; - print_odv_region(®ions[i]); - } -} - void TestVoltCurvRead::Run(void) { - rsmi_status_t err; + rsmi_status_t err, ret; rsmi_od_volt_freq_data_t odv; + rsmi_dev_perf_level_t pfl; TestBase::Run(); if (setup_failed_) { @@ -157,26 +99,57 @@ void TestVoltCurvRead::Run(void) { for (uint32_t i = 0; i < num_monitor_devs(); ++i) { PrintDeviceHeader(i); + std::cout << "\n\t**Resetting performance determinism to auto\n"; + err = rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_perf_level_set(i, RSMI_DEV_PERF_LEVEL_AUTO): " + << amd::smi::getRSMIStatusString(err, false) + << "\n"; + } + CHK_ERR_ASRT(err) + ret = rsmi_dev_perf_level_get(i, &pfl); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_perf_level_get(i, &pfl): " + << amd::smi::getRSMIStatusString(ret, false) << "\n"; + } + CHK_ERR_ASRT(ret) err = rsmi_dev_od_volt_info_get(i, &odv); - if (err == RSMI_STATUS_NOT_SUPPORTED) { + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_info_get(i, &odv): " + << amd::smi::getRSMIStatusString(err, false) + << "\n" + << amd::smi::print_rsmi_od_volt_freq_data_t(&odv) + << "\n"; + } + if (err != RSMI_STATUS_SUCCESS) { IF_VERB(STANDARD) { std::cout << "\t**rsmi_dev_od_volt_info_get: Not supported on this machine" << std::endl; } - // Verify api support checking functionality is working - err = rsmi_dev_od_volt_info_get(i, nullptr); - ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED); - } else { - CHK_ERR_ASRT(err) - // Verify api support checking functionality is working - err = rsmi_dev_od_volt_info_get(i, nullptr); - ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS); + continue; + } + // Verify api support checking functionality is working + err = rsmi_dev_od_volt_info_get(i, nullptr); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_info_get(i, nullptr): " + << amd::smi::getRSMIStatusString(err, false) << "\n"; + // << "\n" + // << amd::smi::print_rsmi_od_volt_freq_data_t(&odv) + // << "\n"; + } + ASSERT_TRUE(err == RSMI_STATUS_INVALID_ARGS); + err = rsmi_dev_od_volt_info_get(i, &odv); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_info_get(i, &odv): " + << amd::smi::getRSMIStatusString(err, false) << "\n" + << amd::smi::print_rsmi_od_volt_freq_data_t(&odv) + << "\t**odv.num_regions = " << std::dec + << odv.num_regions << "\n"; } - if (err == RSMI_STATUS_SUCCESS) { - std::cout << "\t**Frequency-voltage curve data:" << std::endl; - print_rsmi_od_volt_freq_data_t(&odv); + std::cout << "\t**Frequency-voltage curve data:" << "\n"; + std::cout << amd::smi::print_rsmi_od_volt_freq_data_t(&odv); rsmi_freq_volt_region_t *regions; uint32_t num_regions; @@ -185,11 +158,30 @@ void TestVoltCurvRead::Run(void) { num_regions = odv.num_regions; err = rsmi_dev_od_volt_curve_regions_get(i, &num_regions, regions); + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_curve_regions_get(" + << "i, &num_regions, regions): " + << amd::smi::getRSMIStatusString(err, false) << "\n" + << "\t**Number of regions: " << std::dec << num_regions + << "\n"; + } + ASSERT_TRUE(err == RSMI_STATUS_SUCCESS + || err == RSMI_STATUS_NOT_SUPPORTED + || err == RSMI_STATUS_UNEXPECTED_DATA + || err == RSMI_STATUS_UNEXPECTED_SIZE); + if (err != RSMI_STATUS_SUCCESS) { + IF_VERB(STANDARD) { + std::cout << "\t**rsmi_dev_od_volt_curve_regions_get: " + "Not supported on this machine" << std::endl; + } + continue; + } CHK_ERR_ASRT(err) ASSERT_TRUE(num_regions == odv.num_regions); std::cout << "\t**Frequency-voltage curve regions:" << std::endl; - print_rsmi_od_volt_freq_regions(num_regions, regions); + std::cout << amd::smi::print_rsmi_od_volt_freq_regions(num_regions, + regions); delete []regions; } diff --git a/projects/amdsmi/tests/rocm_smi_test/main.cc b/projects/amdsmi/tests/rocm_smi_test/main.cc index 8e140f4634..638b4224c8 100755 --- a/projects/amdsmi/tests/rocm_smi_test/main.cc +++ b/projects/amdsmi/tests/rocm_smi_test/main.cc @@ -163,6 +163,14 @@ TEST(rsmitstReadOnly, TestPerfLevelRead) { TestPerfLevelRead tst; RunGenericTest(&tst); } +TEST(rsmitstReadWrite, TestComputePartitionReadWrite) { + TestComputePartitionReadWrite tst; + RunGenericTest(&tst); +} +TEST(rsmitstReadWrite, TestMemoryPartitionReadWrite) { + TestMemoryPartitionReadWrite tst; + RunGenericTest(&tst); +} TEST(rsmitstReadWrite, TestPerfLevelReadWrite) { TestPerfLevelReadWrite tst; RunGenericTest(&tst); @@ -267,14 +275,6 @@ TEST(rsmitstReadOnly, TestMutualExclusion) { tst.Run(); RunCustomTestEpilog(&tst); } -TEST(rsmitstReadWrite, TestComputePartitionReadWrite) { - TestComputePartitionReadWrite tst; - RunGenericTest(&tst); -} -TEST(rsmitstReadWrite, TestMemoryPartitionReadWrite) { - TestMemoryPartitionReadWrite tst; - RunGenericTest(&tst); -} TEST(rsmitstReadWrite, TestEvtNotifReadWrite) { TestEvtNotifReadWrite tst; RunGenericTest(&tst); From c1fb7e3dc30426973248528e156f7e43165f1472 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 24 Oct 2023 20:08:48 -0500 Subject: [PATCH 09/33] Fixed firmware version from int to hex Signed-off-by: Maisam Arif Change-Id: Ie09c5b14f108f1eb5c3fd60fe37fb731173a9478 [ROCm/amdsmi commit: 6d59e9b71dd570c3a0134e43444f3731c8d63447] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 5 ++--- projects/amdsmi/py-interface/README.md | 2 +- projects/amdsmi/py-interface/amdsmi_interface.py | 7 +++++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index ca01290628..7300e6b69d 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -592,12 +592,11 @@ class AMDSMICommands(): for fw_index, fw_entry in enumerate(fw_info['fw_list']): # Change fw_name to fw_id fw_entry['fw_id'] = fw_entry.pop('fw_name').name.strip('FW_ID_') - fw_entry['fw_version'] = fw_entry.pop('fw_version') - firmware_identifier = 'FW' + fw_entry['fw_version'] = fw_entry.pop('fw_version') # popping to ensure order # Add custom human readable formatting if self.logger.is_human_readable_format(): - fw_info['fw_list'][fw_index] = {f'{firmware_identifier} {fw_index}': fw_entry} + fw_info['fw_list'][fw_index] = {f'FW {fw_index}': fw_entry} else: fw_info['fw_list'][fw_index] = fw_entry diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 25845075c1..55f36ba0eb 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -576,7 +576,7 @@ try: firmware_list = amdsmi_get_fw_info(device)['fw_list'] for firmware_block in firmware_list: print(firmware_block['fw_name']) - print(firmware_block['fw_version']) + print(firmware_block['fw_version']) # String formated hex version ie: 21.00.00.AC except AmdSmiException as e: print(e) ``` diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 2b832eb7cd..02be4c5086 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1365,11 +1365,14 @@ def amdsmi_get_fw_info( fw_info = amdsmi_wrapper.amdsmi_fw_info_t() _check_res(amdsmi_wrapper.amdsmi_get_fw_info( processor_handle, ctypes.byref(fw_info))) - firmwares = list() + + firmwares = [] for i in range(0, fw_info.num_fw_info): + fw_version = hex(fw_info.fw_info_list[i].fw_version) + fw_version_string = ".".join(re.findall('..?', fw_version[2:])) firmwares.append({ 'fw_name': AmdSmiFwBlock(fw_info.fw_info_list[i].fw_id), - 'fw_version': fw_info.fw_info_list[i].fw_version, + 'fw_version': fw_version_string.upper(), }) return { 'fw_list': firmwares From a5e1a85a43bbc0d83cbb7b10c967580a114ad9ff Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 24 Oct 2023 20:14:58 -0500 Subject: [PATCH 10/33] Type & import clean-up Signed-off-by: Maisam Arif Change-Id: Ie09b583a0eb930afc429904e84fe46433ef33b3b [ROCm/amdsmi commit: 741839d8e47476e0dbfcd02c8f2b979ff83862b4] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 1 - projects/amdsmi/py-interface/amdsmi_interface.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 7300e6b69d..3cf1704e62 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -20,7 +20,6 @@ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -import argparse import logging import sys import threading diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 02be4c5086..1c3d6ec1e7 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -385,7 +385,7 @@ class AmdSmiEventReader: ) ) - ret = list() + ret = [] for i in range(0, num_elem): unique_event_values = set(event.value for event in AmdSmiEvtNotificationType) if self.event_info[i].event in unique_event_values: @@ -436,7 +436,7 @@ def _format_bad_page_info(bad_page_info, bad_page_count: ctypes.c_uint32) -> Lis amdsmi_wrapper.amdsmi_retired_page_record_t) ) - table_records = list() + table_records = [] for i in range(bad_page_count.value): table_records.append( { From b14d1ca543fcfdafa3fa3c765fc539e0ee09ba5f Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 25 Oct 2023 17:13:03 -0500 Subject: [PATCH 11/33] SWDEV-410051 - Updates to board_info struct & CLI Signed-off-by: Maisam Arif Change-Id: I8735d8965140ee5da0c35106b388af1dca87ec71 [ROCm/amdsmi commit: 2b4637ff9f3e3c5ea6f529f146f30c0e0b847946] --- .../amdsmi/example/amd_smi_drm_example.cc | 6 ++- .../amdsmi/example/amd_smi_nodrm_example.cc | 6 ++- projects/amdsmi/include/amd_smi/amdsmi.h | 3 +- projects/amdsmi/py-interface/README.md | 10 +++-- .../amdsmi/py-interface/amdsmi_interface.py | 2 +- .../amdsmi/py-interface/amdsmi_wrapper.py.in | 24 +++++------ projects/amdsmi/rocm_smi/src/rocm_smi.cc | 1 - projects/amdsmi/src/amd_smi/amd_smi.cc | 7 +--- projects/amdsmi/src/amd_smi/amd_smi_utils.cc | 40 ++++++++++++------- 9 files changed, 55 insertions(+), 44 deletions(-) diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 7b6997404b..9dd5f5562d 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -619,9 +619,11 @@ int main() { std::cout << "\tdevice [" << j << "]\n\t\tProduct name: " << board_info.product_name << "\n" - << "\t\tProduct number: " << board_info.product_serial + << "\t\tModel Number: " << board_info.model_number << "\n" - << "\t\tSerial number: " << board_info.serial_number + << "\t\tBoard Serial: " << board_info.product_serial + << "\n" + << "\t\tManufacturer Name: " << board_info.manufacturer_name << "\n\n"; // Get temperature diff --git a/projects/amdsmi/example/amd_smi_nodrm_example.cc b/projects/amdsmi/example/amd_smi_nodrm_example.cc index 3b4adce76a..987c8c9225 100644 --- a/projects/amdsmi/example/amd_smi_nodrm_example.cc +++ b/projects/amdsmi/example/amd_smi_nodrm_example.cc @@ -302,9 +302,11 @@ int main() { std::cout << "\tdevice [" << j << "]\n\t\tProduct name: " << board_info.product_name << "\n" - << "\t\tProduct number: " << board_info.product_serial + << "\t\tModel Number: " << board_info.model_number << "\n" - << "\t\tSerial number: " << board_info.serial_number + << "\t\tBoard Serial: " << board_info.product_serial + << "\n" + << "\t\tManufacturer Name: " << board_info.manufacturer_name << "\n\n"; // Get temperature diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index c8da0b4502..716d307682 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -501,13 +501,12 @@ typedef struct { } amdsmi_driver_info_t; typedef struct { - uint64_t serial_number; bool is_master; char model_number[AMDSMI_NORMAL_STRING_LENGTH]; char product_serial[AMDSMI_NORMAL_STRING_LENGTH]; char fru_id[AMDSMI_NORMAL_STRING_LENGTH]; - char product_name[AMDSMI_PRODUCT_NAME_LENGTH]; char manufacturer_name[AMDSMI_NORMAL_STRING_LENGTH]; + char product_name[AMDSMI_PRODUCT_NAME_LENGTH]; } amdsmi_board_info_t; typedef struct { diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 55f36ba0eb..70c4419924 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -2,7 +2,7 @@ ## Requirements -* python 3.6 64-bit +* python 3.7+ 64-bit * driver must be loaded for amdsmi_init() to pass ## Overview @@ -998,8 +998,10 @@ Output: Dictionary with fields correctable and uncorrectable Field | Description ---|--- -`serial_number` | Board serial number +`model_number` | Board serial number `product_serial` | Product serial +`fru_id` | FRU ID +`manufacturer_name` | Manufacturer name `product_name` | Product name Exceptions that can be thrown by `amdsmi_get_gpu_board_info` function: @@ -1014,8 +1016,10 @@ Example: try: device = amdsmi_get_processor_handle_from_bdf("0000:23.00.0") board_info = amdsmi_get_gpu_board_info(device) - print(board_info["serial_number"]) + print(board_info["model_number"]) print(board_info["product_serial"]) + print(board_info["fru_id"]) + print(board_info["manufacturer_name"]) print(board_info["product_name"]) except AmdSmiException as e: print(e) diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 1c3d6ec1e7..97d4dbc269 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1147,7 +1147,7 @@ def amdsmi_get_gpu_board_info( return { "model_number": board_info.model_number.decode("utf-8").strip(), - "product_serial": board_info.serial_number, + "product_serial": board_info.product_serial.decode("utf-8").strip(), "fru_id": board_info.fru_id.decode("utf-8").strip(), "manufacturer_name" : board_info.manufacturer_name.decode("utf-8").strip(), "product_name": board_info.product_name.decode("utf-8").strip() diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in index a7a16ce2de..18576d77fc 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in @@ -840,14 +840,12 @@ class struct_amdsmi_board_info_t(Structure): struct_amdsmi_board_info_t._pack_ = 1 # source:False struct_amdsmi_board_info_t._fields_ = [ - ('serial_number', ctypes.c_uint64), ('is_master', ctypes.c_bool), ('model_number', ctypes.c_char * 32), ('product_serial', ctypes.c_char * 32), ('fru_id', ctypes.c_char * 32), - ('product_name', ctypes.c_char * 128), ('manufacturer_name', ctypes.c_char * 32), - ('PADDING_0', ctypes.c_ubyte * 7), + ('product_name', ctypes.c_char * 128), ] amdsmi_board_info_t = struct_amdsmi_board_info_t @@ -894,6 +892,16 @@ amdsmi_process_handle_t = ctypes.c_uint32 class struct_amdsmi_proc_info_t(Structure): pass +class struct_engine_usage_(Structure): + pass + +struct_engine_usage_._pack_ = 1 # source:False +struct_engine_usage_._fields_ = [ + ('gfx', ctypes.c_uint64), + ('enc', ctypes.c_uint64), + ('reserved', ctypes.c_uint32 * 12), +] + class struct_memory_usage_(Structure): pass @@ -905,16 +913,6 @@ struct_memory_usage_._fields_ = [ ('reserved', ctypes.c_uint32 * 10), ] -class struct_engine_usage_(Structure): - pass - -struct_engine_usage_._pack_ = 1 # source:False -struct_engine_usage_._fields_ = [ - ('gfx', ctypes.c_uint64), - ('enc', ctypes.c_uint64), - ('reserved', ctypes.c_uint32 * 12), -] - struct_amdsmi_proc_info_t._pack_ = 1 # source:False struct_amdsmi_proc_info_t._fields_ = [ ('name', ctypes.c_char * 32), diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi.cc b/projects/amdsmi/rocm_smi/src/rocm_smi.cc index 6fe0c41d26..752e87da0d 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi.cc @@ -3969,7 +3969,6 @@ rsmi_status_t rsmi_dev_serial_number_get(uint32_t dv_ind, if (ret != RSMI_STATUS_SUCCESS) { return ret; } - uint32_t ln = static_cast(val_str.copy(serial_num, len)); serial_num[std::min(len - 1, ln)] = '\0'; diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 145f4e639b..66088cd7e2 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -466,15 +466,10 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand status = rsmi_wrapper(rsmi_dev_name_get, processor_handle, board_info->product_name, AMDSMI_PRODUCT_NAME_LENGTH); - if (board_info->product_serial[0] == '\0') { - status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle, + status = rsmi_wrapper(rsmi_dev_serial_number_get, processor_handle, board_info->product_serial, AMDSMI_NORMAL_STRING_LENGTH); - } } - // Get FRU ID - // Get manufacturer name - return AMDSMI_STATUS_SUCCESS; } diff --git a/projects/amdsmi/src/amd_smi/amd_smi_utils.cc b/projects/amdsmi/src/amd_smi/amd_smi_utils.cc index 8aef5c8dc1..d733d0b031 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi_utils.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi_utils.cc @@ -116,29 +116,41 @@ amdsmi_status_t smi_amdgpu_get_board_info(amd::smi::AMDSmiGPUDevice* device, amd return AMDSMI_STATUS_NOT_SUPPORTED; } SMIGPUDEVICE_MUTEX(device->get_mutex()) - std::string product_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_name"); - std::string product_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_number"); - std::string serial_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/serial_number"); + std::string model_number_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_number"); + std::string product_serial_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/serial_number"); + std::string fru_id_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/fru_id"); + std::string manufacturer_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/manufacturer"); + std::string product_name_path = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/product_name"); FILE *fp; - fp = fopen(product_name_path.c_str(), "rb"); - if (fp) { - fgets(info->product_name, sizeof(info->product_name), fp); - fclose(fp); - } - - - fp = fopen(product_number_path.c_str(), "rb"); + fp = fopen(model_number_path.c_str(), "rb"); if (fp) { fgets(info->model_number, sizeof(info->model_number), fp); fclose(fp); } - - fp = fopen(serial_number_path.c_str(), "rb"); + fp = fopen(product_serial_path.c_str(), "rb"); if (fp) { - fscanf(fp, "%lx", &info->product_serial); + fgets(info->product_serial, sizeof(info->product_serial), fp); + fclose(fp); + } + + fp = fopen(fru_id_path.c_str(), "rb"); + if (fp) { + fgets(info->fru_id, sizeof(info->fru_id), fp); + fclose(fp); + } + + fp = fopen(manufacturer_name_path.c_str(), "rb"); + if (fp) { + fgets(info->manufacturer_name, sizeof(info->manufacturer_name), fp); + fclose(fp); + } + + fp = fopen(product_name_path.c_str(), "rb"); + if (fp) { + fgets(info->product_name, sizeof(info->product_name), fp); fclose(fp); } From 1fd44d67f478038bd1607d5949fe2982e3e256ff Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Fri, 27 Oct 2023 09:39:31 -0500 Subject: [PATCH 12/33] Parser & Command args cleanup Change-Id: I015acc429acc6172845667fafb8f706d0a83bec1 Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 17ec59454308ec24d22389d263cb5b4332becf6d] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 205 +++++++++++------- projects/amdsmi/amdsmi_cli/amdsmi_parser.py | 28 +-- 2 files changed, 147 insertions(+), 86 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 3cf1704e62..f8f049dd64 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -51,7 +51,6 @@ class AMDSMICommands(): else: raise e self.stop = '' - self.all_arguments = False def version(self, args): @@ -132,7 +131,8 @@ class AMDSMICommands(): def static(self, args, multiple_devices=False, gpu=None, asic=None, bus=None, vbios=None, limit=None, driver=None, ras=None, - board=None, numa=None, vram=None, cache=None, partition=None): + board=None, numa=None, vram=None, cache=None, partition=None, + dfc_ucode=None, fb_info=None, num_vf=None): """Get Static information for target gpu Args: @@ -150,6 +150,9 @@ class AMDSMICommands(): vram (bool, optional): Value override for args.vram. Defaults to None. cache (bool, optional): Value override for args.cache. Defaults to None. partition (bool, optional): Value override for args.partition. Defaults to None. + dfc_ucode (bool, optional): Value override for args.dfc_ucode. Defaults to None. + fb_info (bool, optional): Value override for args.fb_info. Defaults to None. + num_vf (bool, optional): Value override for args.num_vf. Defaults to None. Raises: IndexError: Index error if gpu list is empty @@ -166,8 +169,6 @@ class AMDSMICommands(): args.bus = bus if vbios: args.vbios = vbios - if numa: - args.numa = numa if board: args.board = board if driver: @@ -176,6 +177,11 @@ class AMDSMICommands(): args.vram = vram if cache: args.cache = cache + + # Store args that are applicable to the current platform + current_platform_args = ["asic", "bus", "vbios", "driver", "vram", "cache", "board"] + current_platform_values = [args.asic, args.bus, args.vbios, args.driver, args.vram, args.cache, args.board] + if self.helpers.is_linux() and self.helpers.is_baremetal(): if ras: args.ras = ras @@ -183,6 +189,24 @@ class AMDSMICommands(): args.partition = partition if limit: args.limit = limit + current_platform_args += ["ras", "limit", "partition"] + current_platform_values += [args.ras, args.limit, args.partition] + + if self.helpers.is_linux() and not self.helpers.is_virtual_os(): + if numa: + args.numa = numa + current_platform_args += ["numa"] + current_platform_values += [args.numa] + + if self.helpers.is_hypervisor(): + if dfc_ucode: + args.dfc_ucode = dfc_ucode + if fb_info: + args.fb_info = fb_info + if num_vf: + args.num_vf = num_vf + current_platform_args += ["dfc_ucode", "fb_info", "num_vf"] + current_platform_values += [args.dfc_ucode, args.fb_info, args.num_vf] # Handle No GPU passed if args.gpu == None: @@ -194,19 +218,19 @@ class AMDSMICommands(): return # This function is recursive args.gpu = device_handle - # If all arguments are False, it means that no argument was passed and the entire static should be printed - if self.helpers.is_linux() and self.helpers.is_baremetal(): - if not any([args.asic, args.bus, args.vbios, args.limit, args.board, args.ras, args.driver, args.numa, args.vram, args.cache, args.partition]): - args.asic = args.bus = args.vbios = args.limit = args.board = args.ras = args.driver = args.numa = args.vram = args.cache = args.partition = self.all_arguments = True - if self.helpers.is_linux() and self.helpers.is_virtual_os(): - if not any([args.asic, args.bus, args.vbios, args.board, args.driver, args.vram, args.cache]): - args.asic = args.bus = args.vbios = args.board = args.driver = args.vram = args.cache = self.all_arguments = True - - static_dict = {} - # Get gpu_id for logging gpu_id = self.helpers.get_gpu_id_from_device_handle(args.gpu) + logging.debug(f"Static Arg information for GPU {gpu_id} on {self.helpers.os_info()}") + logging.debug(f"Applicable Args: {current_platform_args}") + logging.debug(f"Arg Values: {current_platform_values}") + # Set the platform applicable args to True if no args are set + if not any(current_platform_values): + for arg in current_platform_args: + setattr(args, arg, True) + + static_dict = {} + if args.asic: try: asic_info = amdsmi_interface.amdsmi_get_gpu_asic_info(args.gpu) @@ -283,8 +307,7 @@ class AMDSMICommands(): static_dict['board'] = board_info except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Failed to get board info for gpu %s | %s", gpu_id, e.get_error_info()) - - if self.helpers.is_linux() and self.helpers.is_baremetal(): + if 'limit' in current_platform_args: if args.limit: # Power limits try: @@ -397,7 +420,6 @@ class AMDSMICommands(): limit_info['shutdown_hotspot_temperature'] = shutdown_temp_hotspot_limit limit_info['shutdown_vram_temperature'] = shutdown_temp_vram_limit static_dict['limit'] = limit_info - if args.driver: driver_info = {"driver_name" : "N/A", "driver_version" : "N/A", @@ -452,8 +474,7 @@ class AMDSMICommands(): logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info()) static_dict['cache'] = cache_info - - if self.helpers.is_hypervisor() or self.helpers.is_baremetal(): + if 'ras' in current_platform_args: if args.ras: ras_dict = {"eeprom_version": "N/A", "parity_schema" : "N/A", @@ -482,6 +503,7 @@ class AMDSMICommands(): logging.debug("Failed to get ras block features for gpu %s | %s", gpu_id, e.get_error_info()) static_dict["ras"] = ras_dict + if 'partition' in current_platform_args: if args.partition: try: compute_partition = amdsmi_interface.amdsmi_dev_compute_partition_get(args.gpu) @@ -497,8 +519,7 @@ class AMDSMICommands(): static_dict['partition'] = {"compute_partition": compute_partition, "memory_partition": memory_partition} - - if self.helpers.is_linux() and self.helpers.is_baremetal(): + if 'numa' in current_platform_args: if args.numa: try: numa_node_number = amdsmi_interface.amdsmi_topo_get_numa_node_number(args.gpu) @@ -748,7 +769,8 @@ class AMDSMICommands(): usage=None, watch=None, watch_time=None, iterations=None, power=None, clock=None, temperature=None, ecc=None, ecc_block=None, pcie=None, fan=None, voltage_curve=None, overdrive=None, perf_level=None, - xgmi_err=None, energy=None, mem_usage=None): + xgmi_err=None, energy=None, mem_usage=None, schedule=None, + guard=None, guest_data=None, fb_usage=None, xgmi=None,): """Get Metric information for target gpu Args: @@ -773,6 +795,11 @@ class AMDSMICommands(): xgmi_err (bool, optional): Value override for args.xgmi_err. Defaults to None. energy (bool, optional): Value override for args.energy. Defaults to None. mem_usage (bool, optional): Value override for args.mem_usage. Defaults to None. + schedule (bool, optional): Value override for args.schedule. Defaults to None. + guard (bool, optional): Value override for args.guard. Defaults to None. + guest_data (bool, optional): Value override for args.guest_data. Defaults to None. + fb_usage (bool, optional): Value override for args.fb_usage. Defaults to None. + xgmi (bool, optional): Value override for args.xgmi. Defaults to None. Raises: IndexError: Index error if gpu list is empty @@ -789,11 +816,18 @@ class AMDSMICommands(): args.watch_time = watch_time if iterations: args.iterations = iterations - if self.helpers.is_linux(): + + # Store args that are applicable to the current platform + current_platform_args = [] + current_platform_values = [] + + if not self.helpers.is_hypervisor() and not self.helpers.is_windows(): if mem_usage: args.mem_usage = mem_usage + current_platform_args += ["mem_usage"] + current_platform_values += [args.mem_usage] - if self.helpers.is_linux() and self.helpers.is_baremetal(): + if self.helpers.is_hypervisor() or self.helpers.is_baremetal(): if usage: args.usage = usage if power: @@ -804,10 +838,14 @@ class AMDSMICommands(): args.temperature = temperature if ecc: args.ecc = ecc - if ecc_block: - args.ecc_block = ecc_block if pcie: args.pcie = pcie + current_platform_args += ["usage", "power", "clock", "temperature", "ecc", "pcie"] + current_platform_values += [args.usage, args.power, args.clock, args.temperature, args.ecc, args.pcie] + + if self.helpers.is_baremetal() and self.helpers.is_linux(): + if ecc_block: + args.ecc_block = ecc_block if fan: args.fan = fan if voltage_curve: @@ -820,6 +858,22 @@ class AMDSMICommands(): args.xgmi_err = xgmi_err if energy: args.energy = energy + current_platform_args += ["ecc_block", "fan", "voltage_curve", "overdrive", "perf_level", "xgmi_err", "energy"] + current_platform_values += [args.ecc_block, args.fan, args.voltage_curve, args.overdrive, args.perf_level, args.xgmi_err, args.energy] + + if self.helpers.is_hypervisor(): + if schedule: + args.schedule = schedule + if guard: + args.guard = guard + if guest_data: + args.guest_data = guest_data + if fb_usage: + args.fb_usage = fb_usage + if xgmi: + args.xgmi = xgmi + current_platform_args += ["schedule", "guard", "guest_data", "fb_usage", "xgmi"] + current_platform_values += [args.schedule, args.guard, args.guest_data, args.fb_usage, args.xgmi] # Handle No GPU passed if args.gpu == None: @@ -861,31 +915,27 @@ class AMDSMICommands(): else: raise IndexError("args.gpu should not be an empty list") - # Check if any of the options have been set, if not then set them all to true - if self.helpers.is_linux() and self.helpers.is_virtual_os(): - if not any([args.mem_usage]): - args.mem_usage = self.all_arguments = True - - if self.helpers.is_linux() and self.helpers.is_baremetal(): - if not any([args.usage, args.mem_usage, args.power, args.clock, args.temperature, - args.ecc, args.ecc_block, args.pcie, args.fan, args.voltage_curve, - args.overdrive, args.perf_level, args.xgmi_err, args.energy]): - args.usage = args.mem_usage = args.power = args.clock = args.temperature = \ - args.ecc = args.ecc_block = args.pcie = args.fan = args.voltage_curve = \ - args.overdrive = args.perf_level = args.xgmi_err = args.energy = \ - self.all_arguments = True - - # Add timestamp and store values for specified arguments - values_dict = {} - # Get gpu_id for logging gpu_id = self.helpers.get_gpu_id_from_device_handle(args.gpu) + + # Put the metrics table in the debug logs try: logging.debug("GPU Metrics table for %s | %s", gpu_id, amdsmi_interface.amdsmi_get_gpu_metrics_info(args.gpu)) except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Unabled to load GPU Metrics table for %s | %s", gpu_id, e.err_info) - if self.helpers.is_linux() and self.helpers.is_baremetal(): + logging.debug(f"Metric Arg information for GPU {gpu_id} on {self.helpers.os_info()}") + logging.debug(f"Args: {current_platform_args}") + logging.debug(f"Values: {current_platform_values}") + # Set the platform applicable args to True if no args are set + if not any(current_platform_values): + for arg in current_platform_args: + setattr(args, arg, True) + + # Add timestamp and store values for specified arguments + values_dict = {} + + if "usage" in current_platform_args: if args.usage: try: engine_usage = amdsmi_interface.amdsmi_get_gpu_activity(args.gpu) @@ -906,6 +956,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: values_dict['usage'] = "N/A" logging.debug("Failed to get gpu activity for gpu %s | %s", gpu_id, e.get_error_info()) + if "power" in current_platform_args: if args.power: power_dict = {'current_power': "N/A", 'current_gfx_voltage': "N/A", @@ -944,6 +995,7 @@ class AMDSMICommands(): logging.debug("Failed to get power management status for gpu %s | %s", gpu_id, e.get_error_info()) values_dict['power'] = power_dict + if "clock" in current_platform_args: if args.clock: clocks = {} clock_types = [amdsmi_interface.AmdSmiClkType.GFX, @@ -1003,6 +1055,7 @@ class AMDSMICommands(): clocks['gfx'] = {"is_clk_locked": is_clk_locked} values_dict['clock'] = clocks + if "temperature" in current_platform_args: if args.temperature: try: temperature_edge_current = amdsmi_interface.amdsmi_get_temp_metric( @@ -1047,6 +1100,7 @@ class AMDSMICommands(): temperatures[temperature_key] = f"{temperature_value} {unit}" values_dict['temperature'] = temperatures + if "ecc" in current_platform_args: if args.ecc: ecc_count = {} try: @@ -1059,29 +1113,7 @@ class AMDSMICommands(): logging.debug("Failed to get ecc count for gpu %s | %s", gpu_id, e.get_error_info()) values_dict['ecc'] = ecc_count - if args.ecc_block: - ecc_dict = {} - uncountable_blocks = ["ATHUB", "DF", "SMN", "SEM", "MP0", "MP1", "FUSE"] - try: - ras_states = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu) - for state in ras_states: - if state['status'] == amdsmi_interface.AmdSmiRasErrState.ENABLED.name: - gpu_block = amdsmi_interface.AmdSmiGpuBlock[state['block']] - # if the blocks are uncountable do not add them at all. - if gpu_block.name not in uncountable_blocks: - try: - ecc_count = amdsmi_interface.amdsmi_get_gpu_ecc_count(args.gpu, gpu_block) - ecc_dict[state['block']] = {'correctable' : ecc_count['correctable_count'], - 'uncorrectable': ecc_count['uncorrectable_count']} - except amdsmi_exception.AmdSmiLibraryException as e: - ecc_dict[state['block']] = {'correctable' : "N/A", - 'uncorrectable': "N/A"} - logging.debug("Failed to get ecc count for gpu %s at block %s | %s", gpu_id, gpu_block, e.get_error_info()) - - values_dict['ecc_block'] = ecc_dict - except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['ecc_block'] = "N/A" - logging.debug("Failed to get ecc block features for gpu %s | %s", gpu_id, e.get_error_info()) + if "pcie" in current_platform_args: if args.pcie: pcie_dict = {"current_lanes": "N/A", "current_speed": "N/A", @@ -1166,6 +1198,31 @@ class AMDSMICommands(): logging.debug("Failed to get pcie bandwidth for gpu %s | %s", gpu_id, e.get_error_info()) values_dict['pcie'] = pcie_dict + if "ecc_block" in current_platform_args: + if args.ecc_block: + ecc_dict = {} + uncountable_blocks = ["ATHUB", "DF", "SMN", "SEM", "MP0", "MP1", "FUSE"] + try: + ras_states = amdsmi_interface.amdsmi_get_gpu_ras_block_features_enabled(args.gpu) + for state in ras_states: + if state['status'] == amdsmi_interface.AmdSmiRasErrState.ENABLED.name: + gpu_block = amdsmi_interface.AmdSmiGpuBlock[state['block']] + # if the blocks are uncountable do not add them at all. + if gpu_block.name not in uncountable_blocks: + try: + ecc_count = amdsmi_interface.amdsmi_get_gpu_ecc_count(args.gpu, gpu_block) + ecc_dict[state['block']] = {'correctable' : ecc_count['correctable_count'], + 'uncorrectable': ecc_count['uncorrectable_count']} + except amdsmi_exception.AmdSmiLibraryException as e: + ecc_dict[state['block']] = {'correctable' : "N/A", + 'uncorrectable': "N/A"} + logging.debug("Failed to get ecc count for gpu %s at block %s | %s", gpu_id, gpu_block, e.get_error_info()) + + values_dict['ecc_block'] = ecc_dict + except amdsmi_exception.AmdSmiLibraryException as e: + values_dict['ecc_block'] = "N/A" + logging.debug("Failed to get ecc block features for gpu %s | %s", gpu_id, e.get_error_info()) + if "fan" in current_platform_args: if args.fan: fan_dict = {"speed" : "N/A", "max" : "N/A", @@ -1198,6 +1255,7 @@ class AMDSMICommands(): logging.debug("Failed to get fan rpms for gpu %s | %s", args.gpu, e.get_error_info()) values_dict["fan"] = fan_dict + if "voltage_curve" in current_platform_args: if args.voltage_curve: try: od_volt = amdsmi_interface.amdsmi_get_gpu_od_volt_info(args.gpu) @@ -1217,6 +1275,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: values_dict['voltage_curve'] = "N/A" logging.debug("Failed to get voltage curve for gpu %s | %s", gpu_id, e.get_error_info()) + if "overdrive" in current_platform_args: if args.overdrive: try: overdrive_level = amdsmi_interface.amdsmi_get_gpu_overdrive_level(args.gpu) @@ -1229,6 +1288,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: values_dict['overdrive'] = "N/A" logging.debug("Failed to get overdrive level for gpu %s | %s", gpu_id, e.get_error_info()) + if "perf_level" in current_platform_args: if args.perf_level: try: perf_level = amdsmi_interface.amdsmi_get_gpu_perf_level(args.gpu) @@ -1236,8 +1296,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: values_dict['perf_level'] = "N/A" logging.debug("Failed to get perf level for gpu %s | %s", gpu_id, e.get_error_info()) - - if self.helpers.is_linux() and self.helpers.is_baremetal(): + if "xgmi_err" in current_platform_args: if args.xgmi_err: try: xgmi_err_status = amdsmi_interface.amdsmi_gpu_xgmi_error_status(args.gpu) @@ -1245,6 +1304,7 @@ class AMDSMICommands(): except amdsmi_exception.AmdSmiLibraryException as e: values_dict['xgmi_err'] = "N/A" logging.debug("Failed to get xgmi error status for gpu %s | %s", gpu_id, e.get_error_info()) + if "energy" in current_platform_args: if args.energy: try: energy_dict = amdsmi_interface.amdsmi_get_energy_count(args.gpu) @@ -1261,8 +1321,7 @@ class AMDSMICommands(): except amdsmi_interface.AmdSmiLibraryException as e: values_dict['energy'] = "N/A" logging.debug("Failed to get energy usage for gpu %s | %s", args.gpu, e.get_error_info()) - - if self.helpers.is_linux() and (self.helpers.is_baremetal() or self.helpers.is_virtual_os()): + if "mem_usage" in current_platform_args: if args.mem_usage: unit = 'MB' memory_usage = {'total_vram': "N/A", @@ -1558,8 +1617,8 @@ class AMDSMICommands(): print('Press q and hit ENTER when you want to stop (listening will stop within 10 seconds)') threads = [] - for gpu in range(len(args.gpu)): - x = threading.Thread(target=self._event_thread, args=(self, gpu)) + for device_handle in range(len(args.gpu)): + x = threading.Thread(target=self._event_thread, args=(self, device_handle)) threads.append(x) x.start() diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py index c730a5785c..d37eb80872 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_parser.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_parser.py @@ -116,6 +116,7 @@ class AMDSMIParser(argparse.ArgumentParser): outputformat = self.helpers.get_output_format() raise amdsmi_cli_exceptions.AmdSmiInvalidParameterValueException(int_value, outputformat) + def _positive_int(self, int_value): # Argument type validator if int_value.isdigit(): # Is digit doesn't work on negative numbers @@ -365,9 +366,10 @@ class AMDSMIParser(argparse.ArgumentParser): if self.helpers.is_hypervisor() or self.helpers.is_baremetal(): static_parser.add_argument('-r', '--ras', action='store_true', required=False, help=ras_help) static_parser.add_argument('-p', '--partition', action='store_true', required=False, help=partition_help) - if self.helpers.is_linux(): - static_parser.add_argument('-l', '--limit', action='store_true', required=False, help=limit_help) - static_parser.add_argument('-u', '--numa', action='store_true', required=False, help=numa_help) + static_parser.add_argument('-l', '--limit', action='store_true', required=False, help=limit_help) + + if self.helpers.is_linux() and not self.helpers.is_virtual_os(): + static_parser.add_argument('-u', '--numa', action='store_true', required=False, help=numa_help) # Options to only display on a Hypervisor if self.helpers.is_hypervisor(): @@ -445,7 +447,7 @@ class AMDSMIParser(argparse.ArgumentParser): # Optional arguments help text usage_help = "Displays engine usage information" - # Help text for Arguments only Available on Virtual OS and Baremetal platforms + # Help text for Arguments only Available on Linux Virtual OS and Baremetal platforms mem_usage_help = "Memory usage per block" # Help text for Arguments only on Hypervisor and Baremetal platforms @@ -467,7 +469,9 @@ class AMDSMIParser(argparse.ArgumentParser): # Help text for Arguments only on Hypervisors schedule_help = "All scheduling information" guard_help = "All guard information" - guest_help = "All guest data information" + guest_data_help = "All guest data information" + fb_usage_help = "Displays total and used Frame Buffer usage information" + xgmi_help = "Table of current XGMI metrics information" # Create metric subparser metric_parser = subparsers.add_parser('metric', help=metric_help, description=metric_subcommand_help) @@ -482,8 +486,8 @@ class AMDSMIParser(argparse.ArgumentParser): # Add Watch args self._add_watch_arguments(metric_parser) - # Optional Args for Virtual OS and Baremetal systems - if self.helpers.is_virtual_os() or self.helpers.is_baremetal(): + # Optional Args for Linux Virtual OS and Baremetal systems + if not self.helpers.is_hypervisor() and not self.helpers.is_windows(): metric_parser.add_argument('-m', '--mem-usage', action='store_true', required=False, help=mem_usage_help) # Optional Args for Hypervisors and Baremetal systems @@ -493,11 +497,11 @@ class AMDSMIParser(argparse.ArgumentParser): metric_parser.add_argument('-c', '--clock', action='store_true', required=False, help=clock_help) metric_parser.add_argument('-t', '--temperature', action='store_true', required=False, help=temperature_help) metric_parser.add_argument('-e', '--ecc', action='store_true', required=False, help=ecc_help) - metric_parser.add_argument('-k', '--ecc-block', action='store_true', required=False, help=ecc_block_help) metric_parser.add_argument('-P', '--pcie', action='store_true', required=False, help=pcie_help) # Optional Args for Linux Baremetal Systems if self.helpers.is_baremetal() and self.helpers.is_linux(): + metric_parser.add_argument('-k', '--ecc-block', action='store_true', required=False, help=ecc_block_help) metric_parser.add_argument('-f', '--fan', action='store_true', required=False, help=fan_help) metric_parser.add_argument('-C', '--voltage-curve', action='store_true', required=False, help=vc_help) metric_parser.add_argument('-o', '--overdrive', action='store_true', required=False, help=overdrive_help) @@ -509,7 +513,9 @@ class AMDSMIParser(argparse.ArgumentParser): if self.helpers.is_hypervisor(): metric_parser.add_argument('-s', '--schedule', action='store_true', required=False, help=schedule_help) metric_parser.add_argument('-G', '--guard', action='store_true', required=False, help=guard_help) - metric_parser.add_argument('-u', '--guest', action='store_true', required=False, help=guest_help) + metric_parser.add_argument('-u', '--guest-data', action='store_true', required=False, help=guest_data_help) + metric_parser.add_argument('-f', '--fb_usage', action='store_true', required=False, help=fb_usage_help) + metric_parser.add_argument('-m', '--xgmi', action='store_true', required=False, help=xgmi_help) def _add_process_parser(self, subparsers, func): @@ -574,10 +580,6 @@ class AMDSMIParser(argparse.ArgumentParser): def _add_event_parser(self, subparsers, func): - if self.helpers.is_virtual_os(): - # This subparser doesn't only apply to guest systems - return - # Subparser help text event_help = "Displays event information for the given GPU" event_subcommand_help = "If no GPU is specified, returns event information for all GPUs on the system." From 21fa9c09503ba1f25df03df87baa5990d94e6d3e Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Fri, 27 Oct 2023 03:12:46 -0500 Subject: [PATCH 13/33] SWDEV-424983 - Fix supported metrics api checks Change-Id: I5c95bb3057dd7546036cbd87bbf7025469d2b3d5 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 88d5e011e69ed9230a39faf2027b63bdbd446400] --- projects/amdsmi/src/amd_smi/amd_smi.cc | 57 ++++++++++--------- .../amd_smi_test/functional/err_cnt_read.cc | 4 +- .../tests/amd_smi_test/functional/fan_read.cc | 3 + .../functional/frequencies_read.cc | 2 +- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 66088cd7e2..ca5b1aa47a 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -446,7 +446,7 @@ amdsmi_status_t amdsmi_get_gpu_board_info(amdsmi_processor_handle processor_hand AMDSMI_CHECK_INIT(); - if (board_info == NULL) { + if (board_info == nullptr) { return AMDSMI_STATUS_INVAL; } @@ -532,7 +532,7 @@ amdsmi_status_t amdsmi_get_gpu_vram_usage(amdsmi_processor_handle processor_hand AMDSMI_CHECK_INIT(); - if (vram_info == NULL) { + if (vram_info == nullptr) { return AMDSMI_STATUS_INVAL; } @@ -1086,9 +1086,8 @@ amdsmi_get_gpu_compute_process_gpus(uint32_t pid, uint32_t *dv_indices, amdsmi_status_t amdsmi_get_gpu_ecc_count(amdsmi_processor_handle processor_handle, amdsmi_gpu_block_t block, amdsmi_error_count_t *ec) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (ec == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_ecc_count_get, processor_handle, static_cast(block), reinterpret_cast(ec)); @@ -1096,9 +1095,8 @@ amdsmi_status_t amdsmi_get_gpu_ecc_count(amdsmi_processor_handle processor_hand amdsmi_status_t amdsmi_get_gpu_ecc_enabled(amdsmi_processor_handle processor_handle, uint64_t *enabled_blocks) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (enabled_blocks == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_ecc_enabled_get, processor_handle, enabled_blocks); } @@ -1106,9 +1104,8 @@ amdsmi_status_t amdsmi_get_gpu_ecc_status(amdsmi_processor_handle processor_han amdsmi_gpu_block_t block, amdsmi_ras_err_state_t *state) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (state == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_ecc_status_get, processor_handle, static_cast(block), reinterpret_cast(state)); @@ -1118,9 +1115,8 @@ amdsmi_status_t amdsmi_get_gpu_metrics_info( amdsmi_processor_handle processor_handle, amdsmi_gpu_metrics_t *pgpu_metrics) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (pgpu_metrics == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_gpu_metrics_info_get, processor_handle, reinterpret_cast(pgpu_metrics)); } @@ -1207,9 +1203,8 @@ amdsmi_status_t uint32_t sensor_ind, amdsmi_power_profile_status_t *status) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (status == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_power_profile_presets_get, processor_handle, sensor_ind, reinterpret_cast(status)); @@ -1228,15 +1223,16 @@ amdsmi_status_t reserved, static_cast(profile)); } + amdsmi_status_t amdsmi_get_gpu_perf_level(amdsmi_processor_handle processor_handle, amdsmi_dev_perf_level_t *perf) { AMDSMI_CHECK_INIT(); + // nullptr api supported - if (perf == nullptr) - return AMDSMI_STATUS_INVAL; return rsmi_wrapper(rsmi_dev_perf_level_get, processor_handle, reinterpret_cast(perf)); } + amdsmi_status_t amdsmi_set_gpu_perf_level(amdsmi_processor_handle processor_handle, amdsmi_dev_perf_level_t perf_lvl) { @@ -1260,37 +1256,44 @@ amdsmi_status_t amdsmi_get_gpu_pci_bandwidth(amdsmi_processor_handle processor_h amdsmi_status_t amdsmi_get_clk_freq(amdsmi_processor_handle processor_handle, amdsmi_clk_type_t clk_type, amdsmi_frequencies_t *f) { AMDSMI_CHECK_INIT(); - - if (f == nullptr) - return AMDSMI_STATUS_INVAL; + // nullptr api supported // Get from gpu_metrics if (clk_type == CLK_TYPE_VCLK0 || clk_type == CLK_TYPE_VCLK1 || clk_type == CLK_TYPE_DCLK0 || clk_type == CLK_TYPE_DCLK1 ) { + + // when f == nullptr -> check if metrics are supported amdsmi_gpu_metrics_t metric_info; + amdsmi_gpu_metrics_t * metric_info_p = nullptr; + + if (f != nullptr) { + metric_info_p = &metric_info; + } + + // when metric_info_p == nullptr - this will not return AMDSMI_STATUS_SUCCESS auto r_status = amdsmi_get_gpu_metrics_info( - processor_handle, &metric_info); + processor_handle, metric_info_p); if (r_status != AMDSMI_STATUS_SUCCESS) return r_status; f->num_supported = 1; if (clk_type == CLK_TYPE_VCLK0) { - f->current = metric_info.current_vclk0; - f->frequency[0] = metric_info.average_vclk0_frequency; + f->current = metric_info_p->current_vclk0; + f->frequency[0] = metric_info_p->average_vclk0_frequency; } if (clk_type == CLK_TYPE_VCLK1) { - f->current = metric_info.current_vclk1; - f->frequency[0] = metric_info.average_vclk1_frequency; + f->current = metric_info_p->current_vclk1; + f->frequency[0] = metric_info_p->average_vclk1_frequency; } if (clk_type == CLK_TYPE_DCLK0) { - f->current = metric_info.current_dclk0; - f->frequency[0] = metric_info.average_dclk0_frequency; + f->current = metric_info_p->current_dclk0; + f->frequency[0] = metric_info_p->average_dclk0_frequency; } if (clk_type == CLK_TYPE_DCLK1) { - f->current = metric_info.current_dclk1; - f->frequency[0] = metric_info.average_dclk1_frequency; + f->current = metric_info_p->current_dclk1; + f->frequency[0] = metric_info_p->average_dclk1_frequency; } return r_status; @@ -1305,7 +1308,7 @@ amdsmi_status_t amdsmi_set_clk_freq(amdsmi_processor_handle processor_handle, amdsmi_clk_type_t clk_type, uint64_t freq_bitmask) { AMDSMI_CHECK_INIT(); - // Not support the clock type read from gpu_metrics + // Not support the clock type write into gpu_metrics if (clk_type == CLK_TYPE_VCLK0 || clk_type == CLK_TYPE_VCLK1 || clk_type == CLK_TYPE_DCLK0 || diff --git a/projects/amdsmi/tests/amd_smi_test/functional/err_cnt_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/err_cnt_read.cc index c63d561fa1..ab341b21a0 100755 --- a/projects/amdsmi/tests/amd_smi_test/functional/err_cnt_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/err_cnt_read.cc @@ -109,7 +109,7 @@ void TestErrCntRead::Run(void) { } // Verify api support checking functionality is working err = amdsmi_get_gpu_ecc_enabled(processor_handles_[i], nullptr); - ASSERT_EQ(err, AMDSMI_STATUS_INVAL); + ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED); continue; } else { @@ -150,7 +150,7 @@ void TestErrCntRead::Run(void) { // Verify api support checking functionality is working err = amdsmi_get_gpu_ecc_count(processor_handles_[i], static_cast(b), nullptr); - ASSERT_EQ(err, AMDSMI_STATUS_INVAL); + ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED); } else { CHK_ERR_ASRT(err) diff --git a/projects/amdsmi/tests/amd_smi_test/functional/fan_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/fan_read.cc index 5829567ec7..78e257e895 100755 --- a/projects/amdsmi/tests/amd_smi_test/functional/fan_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/fan_read.cc @@ -107,6 +107,9 @@ void TestFanRead::Run(void) { std::cout << "\t**" << ": " << "Not supported on this machine" << std::endl; } + // Verify api support checking functionality is working + err = amdsmi_get_gpu_fan_speed(processor_handles_[i], 0, nullptr); + ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED); return; } else { CHK_ERR_ASRT(err) diff --git a/projects/amdsmi/tests/amd_smi_test/functional/frequencies_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/frequencies_read.cc index 33d678e7da..98e310d64b 100755 --- a/projects/amdsmi/tests/amd_smi_test/functional/frequencies_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/frequencies_read.cc @@ -128,7 +128,7 @@ void TestFrequenciesRead::Run(void) { ": Not supported on this machine" << std::endl; // Verify api support checking functionality is working err = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr); - ASSERT_EQ(err, AMDSMI_STATUS_INVAL); + ASSERT_EQ(err, AMDSMI_STATUS_NOT_SUPPORTED); return; } From a09863f5502160a3959f28ff078d9dcf8d3988f9 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 30 Oct 2023 05:53:49 -0400 Subject: [PATCH 14/33] Esmi Auxillary API wrappers removed from amdsmi library that are called during amdsmi inititalization amdsmi_get_cpu_family, amdsmi_get_cpu_model, amdsmi_get_cpu_threads_per_core, amdsmi_get_number_of_cpu_cores, amdsmi_get_number_of_cpu_sockets Added amdsmi_get_cpucore_info to amdsmi library Change-Id: Ib88d580e1d85afdf578963247e585cfae05c58ad [ROCm/amdsmi commit: 28f6383639b11faf819e639ac0d552ccee0dd375] --- projects/amdsmi/include/amd_smi/amdsmi.h | 59 ++++------------- .../include/amd_smi/impl/amd_smi_cpu_core.h | 3 +- projects/amdsmi/src/amd_smi/amd_smi.cc | 64 ++++++------------- 3 files changed, 34 insertions(+), 92 deletions(-) diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 716d307682..6ea775be3a 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -1469,6 +1469,20 @@ amdsmi_status_t amdsmi_get_socket_info( * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail */ amdsmi_status_t amdsmi_get_cpusocket_info(amdsmi_cpusocket_handle socket_handle, uint32_t sockid); + +/** + * @brief Get information about the given cpu core + * + * @details This function retrieves cpu core information. The @p core_handle must + * be provided to retrieve the core ID. + * + * @param[in] core_handle a processor handle + * + * @param[out] coreid The id of the core. + * + * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail + */ +amdsmi_status_t amdsmi_get_cpucore_info(amdsmi_processor_handle core_handle, uint32_t coreid); #endif /** @@ -4588,51 +4602,6 @@ amdsmi_status_t amdsmi_get_metrics_table(amdsmi_cpusocket_handle socket_handle, /*---------------------------------------------------------------------------*/ /** @{ */ -/** - * @brief Get cpu family. - * - * @param[in,out] family - Input buffer to fill family - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_get_cpu_family(uint32_t family); - -/** - * @brief Get cpu model. - * - * @param[in,out] family - Input buffer to fill family - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_get_cpu_model(uint32_t model); - -/** - * @brief Get threads per core. - * - * @param[in,out] threads - Input buffer to fill threads count. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_get_cpu_threads_per_core(uint32_t threads); - -/** - * @brief Get number of cpus. - * - * @param[in,out] cpus - Input buffer to fill number of cpus. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_get_number_of_cpu_cores(uint32_t cpus); - -/** - * @brief Get number of sockets - * - * @param[in,out] sockets - Input buffer to fill number of sockets. - * - * @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail - */ -amdsmi_status_t amdsmi_get_number_of_cpu_sockets(uint32_t sockets); - /** * @brief Get first online core on socket. * diff --git a/projects/amdsmi/include/amd_smi/impl/amd_smi_cpu_core.h b/projects/amdsmi/include/amd_smi/impl/amd_smi_cpu_core.h index ffcca3a6c9..c721cd671c 100644 --- a/projects/amdsmi/include/amd_smi/impl/amd_smi_cpu_core.h +++ b/projects/amdsmi/include/amd_smi/impl/amd_smi_cpu_core.h @@ -60,14 +60,13 @@ public: virtual ~AMDSmiCpuCore() {} + const uint32_t& get_core_id() const { return core_idx_; } void add_processor(AMDSmiProcessor* processor) { processors_.push_back(processor); } std::vector& get_processors() { return processors_;} amdsmi_status_t get_processor_count(uint32_t* processor_count) const; private: uint32_t core_idx_; - //uint64_t input; - //uint32_t idx; std::vector processors_; }; diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index ca5b1aa47a..02ca597ddf 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -330,6 +330,25 @@ amdsmi_status_t amdsmi_get_cpusocket_info( return AMDSMI_STATUS_SUCCESS; } + +amdsmi_status_t amdsmi_get_cpucore_info( + amdsmi_processor_handle core_handle, + uint32_t core_id) { + AMDSMI_CHECK_INIT(); + + if (core_handle == nullptr) { + return AMDSMI_STATUS_INVAL; + } + + amd::smi::AMDSmiProcessor* core = nullptr; + amdsmi_status_t r = amd::smi::AMDSmiSystem::getInstance() + .handle_to_processor(core_handle, &core); + if (r != AMDSMI_STATUS_SUCCESS) return r; + + core_id = static_cast(core)->get_core_id(); + + return AMDSMI_STATUS_SUCCESS; +} #endif amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle, @@ -2948,51 +2967,6 @@ amdsmi_status_t amdsmi_get_metrics_table(amdsmi_cpusocket_handle socket_handle, return AMDSMI_STATUS_SUCCESS; } -amdsmi_status_t amdsmi_get_number_of_cpu_sockets(uint32_t sockets) -{ - amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_cpu_sockets(sockets); - if (status != AMDSMI_STATUS_SUCCESS) - return status; - - return AMDSMI_STATUS_SUCCESS; -} - -amdsmi_status_t amdsmi_get_number_of_cpu_cores(uint32_t cpus) -{ - amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_cpu_cores(cpus); - if (status != AMDSMI_STATUS_SUCCESS) - return status; - - return AMDSMI_STATUS_SUCCESS; -} - -amdsmi_status_t amdsmi_get_cpu_threads_per_core(uint32_t threads) -{ - amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_threads_per_core(threads); - if (status != AMDSMI_STATUS_SUCCESS) - return status; - - return AMDSMI_STATUS_SUCCESS; -} - -amdsmi_status_t amdsmi_get_cpu_family(uint32_t family) -{ - amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_cpu_family(family); - if (status != AMDSMI_STATUS_SUCCESS) - return status; - - return AMDSMI_STATUS_SUCCESS; -} - -amdsmi_status_t amdsmi_get_cpu_model(uint32_t model) -{ - amdsmi_status_t status = amd::smi::AMDSmiSystem::getInstance().get_cpu_model(model); - if (status != AMDSMI_STATUS_SUCCESS) - return status; - - return AMDSMI_STATUS_SUCCESS; -} - amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_cpusocket_handle socket_handle, uint32_t sock_ind, uint32_t *pcore_ind) { From 37f1dc34414556e296655623faabf1629f230d46 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Mon, 30 Oct 2023 06:30:11 -0400 Subject: [PATCH 15/33] Updated README for esmi python wrappers Change-Id: I95d345c12040a2163131bd48c5a687ccf734edd0 [ROCm/amdsmi commit: 78b2db036b134d4e9d7e5dd8f7200b9e3678ee01] --- projects/amdsmi/py-interface/README.md | 311 +++++++++++++++++++++++++ 1 file changed, 311 insertions(+) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 70c4419924..636aa02e0f 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -3499,3 +3499,314 @@ try: except AmdSmiException as e: print(e) ``` + +### amdsmi_get_cpusocket_handles + +**Note: CURRENTLY HARDCODED TO RETURN DUMMY DATA** +Description: Returns list of cpusocket handle objects on current machine + +Input parameters: `None` + +Output: List of cpusocket handle objects + +Exceptions that can be thrown by `amdsmi_get_cpusocket_handles` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + sockets = amdsmi_get_cpusocket_handles() + print('Socket numbers: {}'.format(len(sockets))) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpusocket_info + +**Note: CURRENTLY HARDCODED TO RETURN EMPTY VALUES** +Description: Return cpu socket index + +Input parameters: +`socket_handle` cpu socket handle + +Output: Socket index + +Exceptions that can be thrown by `amdsmi_get_cpusocket_info` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + print(amdsmi_get_cpusocket_info(socket)) +except AmdSmiException as e: + print(e) +``` + + +### amdsmi_get_cpucore_handles + +Description: Returns list of CPU core handle objects on current machine + +Input parameters: `None` + +Output: List of CPU core handle objects + +Exceptions that can be thrown by `amdsmi_get_cpucore_handles` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + core_handles = amdsmi_get_cpucore_handles() + if len(core_handles) == 0: + print("No CPU cores on machine") + else: + for core in core_handles: + print(amdsmi_get_cpucore_info(core)) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_hsmp_proto_ver + +Description: Get the hsmp protocol version. + +Output: amdsmi hsmp protocol version + +Exceptions that can be thrown by `amdsmi_get_cpu_hsmp_proto_ver` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + version = amdsmi_get_cpu_hsmp_proto_ver(socket) + print(version) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_smu_fw_version + +Description: Get the SMU Firmware version. + +Output: amdsmi SMU Firmware version + +Exceptions that can be thrown by `amdsmi_get_cpu_smu_fw_version` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + version = amdsmi_get_cpu_smu_fw_version(socket) + print(version['debug']) + print(version['minor']) + print(version['major']) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_prochot_status + +Description: Get the CPU's prochot status. + +Output: amdsmi cpu prochot status + +Exceptions that can be thrown by `amdsmi_get_cpu_prochot_status` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + prochot = amdsmi_get_cpu_prochot_status(socket) + print(prochot) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_fclk_mclk + +Description: Get the Data fabric clock and Memory clock in MHz. + +Output: amdsmi data fabric clock and memory clock + +Exceptions that can be thrown by `amdsmi_get_cpu_fclk_mclk` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + clk = amdsmi_get_cpu_fclk_mclk(socket) + for fclk, mclk in clk.items(): + print(fclk) + print(mclk) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_cclk_limit + +Description: Get the core clock in MHz. + +Output: amdsmi core clock + +Exceptions that can be thrown by `amdsmi_get_cpu_cclk_limit` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + cclk_limit = amdsmi_get_cpu_cclk_limit(socket) + print(cclk_limit) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_socket_current_active_freq_limit + +Description: Get current active frequency limit of the socket. + +Output: amdsmi frequency value in MHz and frequency source name + +Exceptions that can be thrown by `amdsmi_get_cpu_socket_current_active_freq_limit` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + freq_limit = amdsmi_get_cpu_socket_current_active_freq_limit(socket) + for freq, src in freq_limit.items(): + print(freq) + print(src) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_socket_freq_range + +Description: Get socket frequency range + +Output: amdsmi maximum frequency and minimum frequency + +Exceptions that can be thrown by `amdsmi_get_cpu_socket_freq_range` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + freq_range = amdsmi_get_cpu_socket_freq_range(socket) + for fmax, fmin in freq_range.items(): + print(fmax) + print(fmin) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_core_current_freq_limit + +Description: Get socket frequency limit of the core + +Output: amdsmi frequency + +Exceptions that can be thrown by `amdsmi_get_cpu_core_current_freq_limit` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + core_handles = amdsmi_get_cpucore_handles() + if len(core_handles) == 0: + print("No CPU cores on machine") + else: + for core in core_handles: + freq_limit = amdsmi_get_cpu_core_current_freq_limit(core) + print(freq_limit) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_socket_power + +Description: Get the socket power. + +Output: amdsmi socket power + +Exceptions that can be thrown by `amdsmi_get_cpu_socket_power` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + sock_power = amdsmi_get_cpu_socket_power(socket) + print(sock_power) +except AmdSmiException as e: + print(e) +``` From 5e18c29b3b5cc46f3f4e29b0b534fb5cd55e02f7 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Mon, 30 Oct 2023 20:10:32 -0500 Subject: [PATCH 16/33] Update python wrapper with esmi updates Change-Id: I0274821f6525e60f76ec9ba9e4b2a50b19231031 Signed-off-by: Maisam Arif [ROCm/amdsmi commit: 4dd7e8a41f524fa176d35401aa107bd27259c88b] --- .../amdsmi/py-interface/amdsmi_wrapper.py.in | 62 +++++++------------ 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in index 18576d77fc..c6caa37c28 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in @@ -892,16 +892,6 @@ amdsmi_process_handle_t = ctypes.c_uint32 class struct_amdsmi_proc_info_t(Structure): pass -class struct_engine_usage_(Structure): - pass - -struct_engine_usage_._pack_ = 1 # source:False -struct_engine_usage_._fields_ = [ - ('gfx', ctypes.c_uint64), - ('enc', ctypes.c_uint64), - ('reserved', ctypes.c_uint32 * 12), -] - class struct_memory_usage_(Structure): pass @@ -913,6 +903,16 @@ struct_memory_usage_._fields_ = [ ('reserved', ctypes.c_uint32 * 10), ] +class struct_engine_usage_(Structure): + pass + +struct_engine_usage_._pack_ = 1 # source:False +struct_engine_usage_._fields_ = [ + ('gfx', ctypes.c_uint64), + ('enc', ctypes.c_uint64), + ('reserved', ctypes.c_uint32 * 12), +] + struct_amdsmi_proc_info_t._pack_ = 1 # source:False struct_amdsmi_proc_info_t._fields_ = [ ('name', ctypes.c_char * 32), @@ -1656,6 +1656,9 @@ uint32_t = ctypes.c_uint32 amdsmi_get_cpusocket_info = _libraries['libamd_smi.so'].amdsmi_get_cpusocket_info amdsmi_get_cpusocket_info.restype = amdsmi_status_t amdsmi_get_cpusocket_info.argtypes = [amdsmi_cpusocket_handle, uint32_t] +amdsmi_get_cpucore_info = _libraries['libamd_smi.so'].amdsmi_get_cpucore_info +amdsmi_get_cpucore_info.restype = amdsmi_status_t +amdsmi_get_cpucore_info.argtypes = [amdsmi_processor_handle, uint32_t] amdsmi_get_processor_handles = _libraries['libamd_smi.so'].amdsmi_get_processor_handles amdsmi_get_processor_handles.restype = amdsmi_status_t amdsmi_get_processor_handles.argtypes = [amdsmi_socket_handle, ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.POINTER(None))] @@ -2071,21 +2074,6 @@ class struct_hsmp_metric_table(Structure): amdsmi_get_metrics_table = _libraries['libamd_smi.so'].amdsmi_get_metrics_table amdsmi_get_metrics_table.restype = amdsmi_status_t amdsmi_get_metrics_table.argtypes = [amdsmi_cpusocket_handle, uint8_t, ctypes.POINTER(struct_hsmp_metric_table)] -amdsmi_get_cpu_family = _libraries['libamd_smi.so'].amdsmi_get_cpu_family -amdsmi_get_cpu_family.restype = amdsmi_status_t -amdsmi_get_cpu_family.argtypes = [uint32_t] -amdsmi_get_cpu_model = _libraries['libamd_smi.so'].amdsmi_get_cpu_model -amdsmi_get_cpu_model.restype = amdsmi_status_t -amdsmi_get_cpu_model.argtypes = [uint32_t] -amdsmi_get_cpu_threads_per_core = _libraries['libamd_smi.so'].amdsmi_get_cpu_threads_per_core -amdsmi_get_cpu_threads_per_core.restype = amdsmi_status_t -amdsmi_get_cpu_threads_per_core.argtypes = [uint32_t] -amdsmi_get_number_of_cpu_cores = _libraries['libamd_smi.so'].amdsmi_get_number_of_cpu_cores -amdsmi_get_number_of_cpu_cores.restype = amdsmi_status_t -amdsmi_get_number_of_cpu_cores.argtypes = [uint32_t] -amdsmi_get_number_of_cpu_sockets = _libraries['libamd_smi.so'].amdsmi_get_number_of_cpu_sockets -amdsmi_get_number_of_cpu_sockets.restype = amdsmi_status_t -amdsmi_get_number_of_cpu_sockets.argtypes = [uint32_t] amdsmi_first_online_core_on_cpu_socket = _libraries['libamd_smi.so'].amdsmi_first_online_core_on_cpu_socket amdsmi_first_online_core_on_cpu_socket.restype = amdsmi_status_t amdsmi_first_online_core_on_cpu_socket.argtypes = [amdsmi_cpusocket_handle, uint32_t, ctypes.POINTER(ctypes.c_uint32)] @@ -2283,9 +2271,8 @@ __all__ = \ 'amdsmi_get_cpu_current_xgmi_bw', 'amdsmi_get_cpu_ddr_bw', 'amdsmi_get_cpu_dimm_power_consumption', 'amdsmi_get_cpu_dimm_temp_range_and_refresh_rate', - 'amdsmi_get_cpu_dimm_thermal_sensor', 'amdsmi_get_cpu_family', - 'amdsmi_get_cpu_fclk_mclk', 'amdsmi_get_cpu_hsmp_proto_ver', - 'amdsmi_get_cpu_model', 'amdsmi_get_cpu_prochot_status', + 'amdsmi_get_cpu_dimm_thermal_sensor', 'amdsmi_get_cpu_fclk_mclk', + 'amdsmi_get_cpu_hsmp_proto_ver', 'amdsmi_get_cpu_prochot_status', 'amdsmi_get_cpu_pwr_svi_telemetry_all_rails', 'amdsmi_get_cpu_smu_fw_version', 'amdsmi_get_cpu_socket_c0_residency', @@ -2295,12 +2282,12 @@ __all__ = \ 'amdsmi_get_cpu_socket_lclk_dpm_level', 'amdsmi_get_cpu_socket_power', 'amdsmi_get_cpu_socket_power_cap', 'amdsmi_get_cpu_socket_power_cap_max', - 'amdsmi_get_cpu_socket_temperature', - 'amdsmi_get_cpu_threads_per_core', 'amdsmi_get_cpucore_handles', - 'amdsmi_get_cpusocket_handles', 'amdsmi_get_cpusocket_info', - 'amdsmi_get_energy_count', 'amdsmi_get_esmi_err_msg', - 'amdsmi_get_fw_info', 'amdsmi_get_gpu_activity', - 'amdsmi_get_gpu_asic_info', 'amdsmi_get_gpu_available_counters', + 'amdsmi_get_cpu_socket_temperature', 'amdsmi_get_cpucore_handles', + 'amdsmi_get_cpucore_info', 'amdsmi_get_cpusocket_handles', + 'amdsmi_get_cpusocket_info', 'amdsmi_get_energy_count', + 'amdsmi_get_esmi_err_msg', 'amdsmi_get_fw_info', + 'amdsmi_get_gpu_activity', 'amdsmi_get_gpu_asic_info', + 'amdsmi_get_gpu_available_counters', 'amdsmi_get_gpu_bad_page_info', 'amdsmi_get_gpu_bdf_id', 'amdsmi_get_gpu_board_info', 'amdsmi_get_gpu_cache_info', 'amdsmi_get_gpu_compute_process_gpus', @@ -2331,10 +2318,9 @@ __all__ = \ 'amdsmi_get_gpu_vram_vendor', 'amdsmi_get_lib_version', 'amdsmi_get_metrics_table', 'amdsmi_get_metrics_table_version', 'amdsmi_get_minmax_bandwidth_between_processors', - 'amdsmi_get_number_of_cpu_cores', - 'amdsmi_get_number_of_cpu_sockets', 'amdsmi_get_pcie_link_caps', - 'amdsmi_get_pcie_link_status', 'amdsmi_get_power_cap_info', - 'amdsmi_get_power_info', 'amdsmi_get_processor_handle_from_bdf', + 'amdsmi_get_pcie_link_caps', 'amdsmi_get_pcie_link_status', + 'amdsmi_get_power_cap_info', 'amdsmi_get_power_info', + 'amdsmi_get_processor_handle_from_bdf', 'amdsmi_get_processor_handles', 'amdsmi_get_processor_type', 'amdsmi_get_socket_handles', 'amdsmi_get_socket_info', 'amdsmi_get_temp_metric', 'amdsmi_get_utilization_count', From 91ef279bc4e4bc05c4c1d08e6411a0b3734f29ea Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Mon, 30 Oct 2023 22:28:23 -0500 Subject: [PATCH 17/33] Fix python setup.cfg on rhel8 Change-Id: If06fd0e6f3a5574a9f318de23b9eaa712e1c03bb Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 6d7376a7931865542d0a4923660342961451257f] --- projects/amdsmi/py-interface/pyproject.toml.in | 4 ++-- projects/amdsmi/py-interface/setup.cfg.in | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/py-interface/pyproject.toml.in b/projects/amdsmi/py-interface/pyproject.toml.in index f659dc4202..34368333c8 100644 --- a/projects/amdsmi/py-interface/pyproject.toml.in +++ b/projects/amdsmi/py-interface/pyproject.toml.in @@ -2,7 +2,7 @@ # https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html [build-system] -requires = ["setuptools>=61.0"] +requires = ["setuptools>=59.0"] build-backend = "setuptools.build_meta" [project] @@ -14,7 +14,7 @@ version = "@amd_smi_libraries_VERSION_STRING@" license = {file = "amdsmi/LICENSE"} readme = {file = "amdsmi/README.md", content-type = "text/markdown"} description = "AMDSMI Python LIB - AMD GPU Monitoring Library" -requires-python = ">=3.7" +requires-python = ">=3.6" dependencies = [ "PyYAML >= 5.0", "clang >= 14.0" diff --git a/projects/amdsmi/py-interface/setup.cfg.in b/projects/amdsmi/py-interface/setup.cfg.in index c073f89a12..d266f8c231 100644 --- a/projects/amdsmi/py-interface/setup.cfg.in +++ b/projects/amdsmi/py-interface/setup.cfg.in @@ -2,5 +2,5 @@ # mostly a rhel8 limitation... [metadata] -name = "amdsmi" -version = "@amd_smi_libraries_VERSION_STRING@" +name = amdsmi +version = @amd_smi_libraries_VERSION_STRING@ From 4a67734b65de5b8c5ea111ff10a36d91e95ed648 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Wed, 25 Oct 2023 08:17:25 -0500 Subject: [PATCH 18/33] Query the CPU and GPU link type The rsmi_topo_get_link_type() is extended to support query the CPU and GPU link type by passing dv_ind_dst as 0xFFFFFFFF. Change-Id: I1f212a01e8120adb70a08ab772fa9faaaecefa29 [ROCm/amdsmi commit: de5bc164dec7e0939997df28021e7d0811aabe5b] --- projects/amdsmi/include/rocm_smi/rocm_smi.h | 14 +++++++++++- projects/amdsmi/src/rocm_smi.cc | 24 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/projects/amdsmi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/include/rocm_smi/rocm_smi.h index 9b169f9827..ea945c91a0 100755 --- a/projects/amdsmi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/include/rocm_smi/rocm_smi.h @@ -686,6 +686,10 @@ typedef enum _RSMI_IO_LINK_TYPE { RSMI_IOLINK_TYPE_SIZE = 0xFFFFFFFF //!< Max of IO Link types } RSMI_IO_LINK_TYPE; +//! The CPU node index which will be used in rsmi_topo_get_link_type +//! to query the link type between GPU and CPU +#define CPU_NODE_INDEX 0xFFFFFFFF + /** * @brief The utilization counter type */ @@ -3671,7 +3675,7 @@ rsmi_minmax_bandwidth_get(uint32_t dv_ind_src, uint32_t dv_ind_dst, uint64_t *min_bandwidth, uint64_t *max_bandwidth); /** - * @brief Retrieve the hops and the connection type between 2 GPUs + * @brief Retrieve the hops and the connection type between GPU to GPU/CPU * * @details Given a source device index @p dv_ind_src and * a destination device index @p dv_ind_dst, and a pointer to an @@ -3680,6 +3684,14 @@ rsmi_minmax_bandwidth_get(uint32_t dv_ind_src, uint32_t dv_ind_dst, * between the device @p dv_ind_src and @p dv_ind_dst to the memory * pointed to by @p hops and @p type. * + * To query the link type between GPU and CPU, given a source GPU index + * @p dev_ind_srcc and a destination device index @p dv_ind_dst + * CPU_NODE_INDEX(0xFFFFFFFF), a pointer to an + * uint64_t @p hops and a pointer to an RSMI_IO_LINK_TYPE @p type, + * this function will write the number of hops and the connection type + * between the device @p dv_ind_src and CPU to the memory + * pointed to by @p hops and @p type. + * * @param[in] dv_ind_src the source device index * * @param[in] dv_ind_dst the destination device index diff --git a/projects/amdsmi/src/rocm_smi.cc b/projects/amdsmi/src/rocm_smi.cc index 9a7bd5d3ac..8749b13213 100755 --- a/projects/amdsmi/src/rocm_smi.cc +++ b/projects/amdsmi/src/rocm_smi.cc @@ -4387,6 +4387,30 @@ rsmi_topo_get_link_type(uint32_t dv_ind_src, uint32_t dv_ind_dst, rsmi_status_t status; uint32_t node_ind_dst; + + // handle the link type for CPU + if (dv_ind_dst == CPU_NODE_INDEX) { + // No CPU connected + if (kfd_node->numa_node_weight() == 0) { + return RSMI_STATUS_NOT_SUPPORTED; + } + amd::smi::IO_LINK_TYPE io_link_type = + kfd_node->numa_node_type(); + switch (io_link_type) { + case amd::smi::IOLINK_TYPE_XGMI: + *type = RSMI_IOLINK_TYPE_XGMI; + *hops = 1; + return RSMI_STATUS_SUCCESS; + case amd::smi::IOLINK_TYPE_PCIEXPRESS: + *type = RSMI_IOLINK_TYPE_PCIEXPRESS; + // always be the same CPU node + *hops = 2; + return RSMI_STATUS_SUCCESS; + default: + return RSMI_STATUS_NOT_SUPPORTED; + } + } + int ret = smi.get_node_index(dv_ind_dst, &node_ind_dst); if (ret == 0) { From f13cbb8d10b2be1f736ae5357cd0abdd6bf6b553 Mon Sep 17 00:00:00 2001 From: "Oliveira, Daniel" Date: Mon, 30 Oct 2023 13:43:52 -0500 Subject: [PATCH 19/33] amd_smi_lib: Fix missing sym link causes segfault Changes AMDSmiDrm to use the versioned library for its dependency Code changes related to the following: * AMDSmiDrm::init() Build changes related to the following: None Change-Id: Ibd5b3dd88f679912acdfa292502003f58b28daf5 Signed-off-by: Oliveira, Daniel [ROCm/amdsmi commit: e20fd12934a6133e11a1272e18da5f73ae075b22] --- projects/amdsmi/src/amd_smi/amd_smi_drm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/src/amd_smi/amd_smi_drm.cc b/projects/amdsmi/src/amd_smi/amd_smi_drm.cc index f3c6d8e090..3d47e2d074 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi_drm.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi_drm.cc @@ -86,7 +86,7 @@ amdsmi_status_t AMDSmiDrm::init() { int fd = -1; - amdsmi_status_t status = lib_loader_.load("libdrm.so"); + amdsmi_status_t status = lib_loader_.load("libdrm.so.2"); if (status != AMDSMI_STATUS_SUCCESS) { return status; } From c4efbff219e5459f9b0579a0b0a6abad2b3e7851 Mon Sep 17 00:00:00 2001 From: Charis Poag Date: Tue, 31 Oct 2023 17:37:43 -0500 Subject: [PATCH 20/33] Fix GPU Metric content revision check Change-Id: I94ff4732be01214591b635357d9a62eb7d5192a0 Signed-off-by: Charis Poag [ROCm/amdsmi commit: b49e82a4f4f7f3760014ae7cd9b0a905815a3ddb] --- .../amdsmi/rocm_smi/example/rocm_smi_example.cc | 4 ++++ projects/amdsmi/src/rocm_smi_gpu_metrics.cc | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc b/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc index 0515d75d3c..cef1fd1263 100755 --- a/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc +++ b/projects/amdsmi/rocm_smi/example/rocm_smi_example.cc @@ -808,6 +808,10 @@ int main() { print_test_header("GPU METRICS", i); print_function_header_with_rsmi_ret(ret, "rsmi_dev_gpu_metrics_info_get(" + std::to_string(i) + ", &p)"); + std::cout << "\t**p.common_header.content_revision: " << std::dec + << p.common_header.content_revision << "\n"; + std::cout << "\t**p.common_header.format_revision: " << std::dec + << p.common_header.format_revision << "\n"; std::cout << "\t**p.average_gfxclk_frequency: " << std::dec << p.average_gfxclk_frequency << "\n"; std::cout << "\t**p.average_socclk_frequency: " << std::dec diff --git a/projects/amdsmi/src/rocm_smi_gpu_metrics.cc b/projects/amdsmi/src/rocm_smi_gpu_metrics.cc index b055876398..6833d35e91 100755 --- a/projects/amdsmi/src/rocm_smi_gpu_metrics.cc +++ b/projects/amdsmi/src/rocm_smi_gpu_metrics.cc @@ -496,10 +496,15 @@ rsmi_dev_gpu_metrics_info_get(uint32_t dv_ind, rsmi_gpu_metrics_t *smu) { // a specific version. *smu = {}; - uint8_t dev_content_revision = dev->gpu_metrics_ver().content_revision; - if (dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_1 || - dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_2 || - dev_content_revision != RSMI_GPU_METRICS_API_CONTENT_VER_3) { + bool isRevisionExpected = ((dev->gpu_metrics_ver().content_revision == 1) || + (dev->gpu_metrics_ver().content_revision == 2) || + (dev->gpu_metrics_ver().content_revision == 3)); + if (isRevisionExpected == false) { + ss << __PRETTY_FUNCTION__ << " | content revision was = " + << print_unsigned_hex_and_int(dev->gpu_metrics_ver().content_revision) + << ", expected version 1,2, or 3 | returning " + << getRSMIStatusString(RSMI_STATUS_NOT_SUPPORTED); + LOG_ERROR(ss); return RSMI_STATUS_NOT_SUPPORTED; } if (dev->gpu_metrics_ver().content_revision == From b2b284c4b04f653db3e784ff486848f02093a558 Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Thu, 2 Nov 2023 01:12:25 -0400 Subject: [PATCH 21/33] Updated README for esmi lib support for amdsmi Change-Id: Icff9120b4323cad4ab9f9578d509b0596f808fcf [ROCm/amdsmi commit: 3e3a233e4942b3ec1cf5a096869a7902d6895d5f] --- projects/amdsmi/README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index 61d36acdd0..0cfe1b1458 100755 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -6,13 +6,15 @@ For additional information refer to [ROCm Documentation](https://rocm.docs.amd.c Note: This project is a successor to [rocm_smi_lib](https://github.com/RadeonOpenCompute/rocm_smi_lib) +and [esmi_ib_library](https://github.com/amd/esmi_ib_library) + ## Supported platforms At initial release, the AMD SMI library will support Linux bare metal and Linux virtual machine guest for AMD GPUs. In the future release, the library will be extended to support AMD EPYCâ„¢ CPUs. AMD SMI library can run on AMD ROCm supported platforms, please refer to [List of Supported Operating Systems and GPUs](https://rocm.docs.amd.com/en/latest/release/gpu_os_support.html) -To run the AMD SMI library, the amdgpu driver needs to be installed. Optionally, the libdrm can be +To run the AMD SMI library, the amdgpu driver and the hsmp driver needs to be installed. Optionally, the libdrm can be installed to query firmware information and hardware IPs. ## Usage Basics @@ -25,6 +27,10 @@ GPU device and CPU device on the same socket. Moreover, for MI200, it may have m To discover the sockets in the system, `amdsmi_get_socket_handles()` is called to get list of sockets handles, which in turn can be used to query the devices in that socket using `amdsmi_get_processor_handles()`. The device handler is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different device handles after restart application, so a device handle should not be relied upon to be constant over process. +To discover the cpu sockets in the system, `amdsmi_get_cpusocket_handles()` is called to get list of cpu sockets +handles, which in turn can be used to query the cpu cores in that cpu socket using `amdsmi_get_cpucore_handles()`. The cpu core handler is used to distinguish the detected cpu cores from one another. + + ## Hello AMD SMI The only required AMD-SMI call for any program that wants to use AMD-SMI is the `amdsmi_init()` call. This call initializes some internal data structures that will be used by subsequent AMD-SMI calls. In the call, a flag can be passed if the application is only interested in a specific device type. @@ -132,7 +138,7 @@ For additional details, see the [ROCm Contributing Guide](https://rocm.docs.amd. ### Requirements * python 3.7+ 64-bit -* amdgpu driver must be loaded for amdsmi_init() to pass +* amdgpu driver and hsmp driver must be loaded for amdsmi_init() to pass ### Optional autocompletion From e05f594cba62f9de2d66aeaad9c8c6bc61f0dc63 Mon Sep 17 00:00:00 2001 From: "Bill(Shuzhou) Liu" Date: Wed, 1 Nov 2023 10:29:17 -0500 Subject: [PATCH 22/33] Support cache type in cache info Add the cache type to the cache info. Change-Id: Ic13ca9640b65d2b414eeebe7b884530f2036aac8 [ROCm/amdsmi commit: 56b246cc3c00e8a9e6fe9a87a784df83cd071459] --- projects/amdsmi/example/amd_smi_drm_example.cc | 5 +++-- projects/amdsmi/include/amd_smi/amdsmi.h | 12 ++++++++++++ .../amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h | 8 ++++++++ projects/amdsmi/rocm_smi/src/rocm_smi_kfd.cc | 9 ++++++++- projects/amdsmi/src/amd_smi/amd_smi.cc | 17 +++++++++++++++++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 9dd5f5562d..de0f794aed 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -312,9 +312,10 @@ int main() { CHK_AMDSMI_RET(ret) printf(" Output of amdsmi_get_gpu_cache_info:\n"); for (unsigned int i = 0 ; i < cache_info.num_cache_types; i++) { - printf("\tCache Level: %d, Cache Size: %d KB\n", + printf("\tCache Level: %d, Cache Size: %d KB, Cache type: 0x%x\n", cache_info.cache[i].cache_level, - cache_info.cache[i].cache_size_kb); + cache_info.cache[i].cache_size_kb, + cache_info.cache[i].flags); } // Get power measure diff --git a/projects/amdsmi/include/amd_smi/amdsmi.h b/projects/amdsmi/include/amd_smi/amdsmi.h index 6ea775be3a..72894c3422 100644 --- a/projects/amdsmi/include/amd_smi/amdsmi.h +++ b/projects/amdsmi/include/amd_smi/amdsmi.h @@ -455,11 +455,23 @@ typedef struct { uint32_t reserved[16]; } amdsmi_vbios_info_t; +/** + * @brief cache flags + */ +typedef enum { + CACHE_FLAGS_ENABLED = 0x00000001, + CACHE_FLAGS_DATA_CACHE = 0x00000002, + CACHE_FLAGS_INST_CACHE = 0x00000004, + CACHE_FLAGS_CPU_CACHE = 0x00000008, + CACHE_FLAGS_SIMD_CACHE = 0x00000010, +} amdsmi_cache_flags_type_t; + typedef struct { uint32_t num_cache_types; struct cache_ { uint32_t cache_size_kb; /* In KB */ uint32_t cache_level; + uint32_t flags; // amdsmi_cache_flags_type_t which is a bitmask uint32_t reserved[3]; } cache[AMDSMI_MAX_CACHE_TYPES]; uint32_t reserved[15]; diff --git a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h index fef797cc5f..807058e780 100755 --- a/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h +++ b/projects/amdsmi/rocm_smi/include/rocm_smi/rocm_smi.h @@ -864,6 +864,14 @@ typedef struct { struct { uint32_t cache_size_kb; /* In KB */ uint32_t cache_level; + /* + HSA_CACHE_TYPE_DATA 0x00000001 + HSA_CACHE_TYPE_INSTRUCTION 0x00000002 + HSA_CACHE_TYPE_CPU 0x00000004 + HSA_CACHE_TYPE_HSACU 0x00000008 + so HSA_CACHE_TYPE_DATA|HSA_CACHE_TYPE_HSACU == 9 + */ + uint32_t flags; } cache[RSMI_MAX_CACHE_TYPES]; } rsmi_gpu_cache_info_t; /// \cond Ignore in docs. diff --git a/projects/amdsmi/rocm_smi/src/rocm_smi_kfd.cc b/projects/amdsmi/rocm_smi/src/rocm_smi_kfd.cc index 68fccb9a49..57cc029bd7 100755 --- a/projects/amdsmi/rocm_smi/src/rocm_smi_kfd.cc +++ b/projects/amdsmi/rocm_smi/src/rocm_smi_kfd.cc @@ -926,10 +926,15 @@ int KFDNode::get_cache_info(rsmi_gpu_cache_info_t *info) { int cache_level = std::stoi(level); if (cache_level < 0 ) continue; + std::string type = get_properties_from_file(prop_file, "type "); + int cache_type = std::stoi(type); + if (cache_type <= 0) continue; + // only count once bool is_count_already = false; for (unsigned int i=0; i < info->num_cache_types; i++) { - if (info->cache->cache_level == static_cast(cache_level)) { + if (info->cache[i].cache_level == static_cast(cache_level) && + info->cache[i].flags == static_cast(cache_type)) { is_count_already = true; break; } @@ -940,8 +945,10 @@ int KFDNode::get_cache_info(rsmi_gpu_cache_info_t *info) { std::string size = get_properties_from_file(prop_file, "size "); int cache_size = std::stoi(size); if (cache_size <= 0) continue; + info->cache[info->num_cache_types].cache_level = cache_level; info->cache[info->num_cache_types].cache_size_kb = cache_size; + info->cache[info->num_cache_types].flags = cache_type; info->num_cache_types++; } catch (...) { continue; diff --git a/projects/amdsmi/src/amd_smi/amd_smi.cc b/projects/amdsmi/src/amd_smi/amd_smi.cc index 02ca597ddf..f25b3d6f92 100644 --- a/projects/amdsmi/src/amd_smi/amd_smi.cc +++ b/projects/amdsmi/src/amd_smi/amd_smi.cc @@ -510,12 +510,29 @@ amdsmi_status_t amdsmi_get_gpu_cache_info( processor_handle, &rsmi_info); if (status != AMDSMI_STATUS_SUCCESS) return status; + // Sysfs cache type + #define HSA_CACHE_TYPE_DATA 0x00000001 + #define HSA_CACHE_TYPE_INSTRUCTION 0x00000002 + #define HSA_CACHE_TYPE_CPU 0x00000004 + #define HSA_CACHE_TYPE_HSACU 0x00000008 info->num_cache_types = rsmi_info.num_cache_types; for (unsigned int i =0; i < rsmi_info.num_cache_types; i++) { info->cache[i].cache_size_kb = rsmi_info.cache[i].cache_size_kb; info->cache[i].cache_level = rsmi_info.cache[i].cache_level; + // convert from sysfs type to CRAT type(HSA Cache Affinity type) + info->cache[i].flags = 0; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_DATA) + info->cache[i].flags |= CACHE_FLAGS_DATA_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_INSTRUCTION) + info->cache[i].flags |= CACHE_FLAGS_INST_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_CPU) + info->cache[i].flags |= CACHE_FLAGS_CPU_CACHE; + if (rsmi_info.cache[i].flags & HSA_CACHE_TYPE_HSACU) + info->cache[i].flags |= CACHE_FLAGS_SIMD_CACHE; } + + return AMDSMI_STATUS_SUCCESS; } From cf0098c16f1ae5aa37b79cde392bbf13cfff27b2 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 2 Nov 2023 05:38:44 -0500 Subject: [PATCH 23/33] SWDEV-417117 - Added Cache Flags Signed-off-by: Maisam Arif Change-Id: I78836ba5f87c2859b82f17a7564df6f99ac77ad7 [ROCm/amdsmi commit: aeef4850346c5887e608a156f25db0a475836f0f] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 9 +++ projects/amdsmi/py-interface/README.md | 8 +++ .../amdsmi/py-interface/amdsmi_interface.py | 13 +++- .../amdsmi/py-interface/amdsmi_wrapper.py.in | 62 ++++++++++++------- 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index f8f049dd64..741f78b960 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -466,9 +466,18 @@ class AMDSMICommands(): if args.cache: try: cache_info = amdsmi_interface.amdsmi_get_gpu_cache_info(args.gpu) + for cache_key, cache_dict in cache_info.items(): + for key, value in cache_dict.items(): + if key == 'cache_size' or key == 'cache_level': + continue + if value: + cache_info[cache_key][key] = "ENABLED" + else: + cache_info[cache_key][key] = "DISABLED" if self.logger.is_human_readable_format(): for _ , cache_values in cache_info.items(): cache_values['cache_size'] = f"{cache_values['cache_size']} KB" + except amdsmi_exception.AmdSmiLibraryException as e: cache_info = "N/A" logging.debug("Failed to get cache info for gpu %s | %s", gpu_id, e.get_error_info()) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 636aa02e0f..c3033ef149 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -478,6 +478,10 @@ Field | Description `cache #` | upt 10 caches will be available `cache_size` | size of cache in KB `cache_level` | level of cache +`data_cache` | True if data cache is enabled, false otherwise +`instruction_cache` | True if instruction cache is enabled, false otherwise +`cpu_cache` | True if cpu cache is enabled, false otherwise +`simd_cache` | True if simd cache is enabled, false otherwise Exceptions that can be thrown by `amdsmi_get_gpu_cache_info` function: @@ -499,6 +503,10 @@ try: print(cache_index) print(cache_values['cache_size']) print(cache_values['cache_level']) + print(cache_values['data_cache']) + print(cache_values['instruction_cache']) + print(cache_values['cpu_cache']) + print(cache_values['simd_cache']) except AmdSmiException as e: print(e) ``` diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 97d4dbc269..1e37eb7adf 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -991,7 +991,7 @@ def amdsmi_get_gpu_vram_info( def amdsmi_get_gpu_cache_info( processor_handle: amdsmi_wrapper.amdsmi_processor_handle, -) -> Dict[str, Any]: +) -> Dict[str, Dict[str, Any]]: if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle): raise AmdSmiParameterException( processor_handle, amdsmi_wrapper.amdsmi_processor_handle @@ -1007,8 +1007,17 @@ def amdsmi_get_gpu_cache_info( for cache_index in range(cache_info.num_cache_types): cache_size = cache_info.cache[cache_index].cache_size_kb cache_level = cache_info.cache[cache_index].cache_level + cache_flags = cache_info.cache[cache_index].flags + data_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_DATA_CACHE) + inst_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_INST_CACHE) + cpu_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_CPU_CACHE) + simd_cache = bool(cache_flags & amdsmi_wrapper.CACHE_FLAGS_SIMD_CACHE) cache_info_dict[f"cache {cache_index}"] = {"cache_size": cache_size, - "cache_level": cache_level} + "cache_level": cache_level, + "data_cache": data_cache, + "instruction_cache": inst_cache, + "cpu_cache": cpu_cache, + "simd_cache": simd_cache} return cache_info_dict diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in index c6caa37c28..00ae691291 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in @@ -751,6 +751,21 @@ struct_amdsmi_vbios_info_t._fields_ = [ ] amdsmi_vbios_info_t = struct_amdsmi_vbios_info_t + +# values for enumeration 'amdsmi_cache_flags_type_t' +amdsmi_cache_flags_type_t__enumvalues = { + 1: 'CACHE_FLAGS_ENABLED', + 2: 'CACHE_FLAGS_DATA_CACHE', + 4: 'CACHE_FLAGS_INST_CACHE', + 8: 'CACHE_FLAGS_CPU_CACHE', + 16: 'CACHE_FLAGS_SIMD_CACHE', +} +CACHE_FLAGS_ENABLED = 1 +CACHE_FLAGS_DATA_CACHE = 2 +CACHE_FLAGS_INST_CACHE = 4 +CACHE_FLAGS_CPU_CACHE = 8 +CACHE_FLAGS_SIMD_CACHE = 16 +amdsmi_cache_flags_type_t = ctypes.c_uint32 # enum class struct_amdsmi_gpu_cache_info_t(Structure): pass @@ -761,6 +776,7 @@ struct_cache_._pack_ = 1 # source:False struct_cache_._fields_ = [ ('cache_size_kb', ctypes.c_uint32), ('cache_level', ctypes.c_uint32), + ('flags', ctypes.c_uint32), ('reserved', ctypes.c_uint32 * 3), ] @@ -2193,22 +2209,24 @@ __all__ = \ 'AMDSMI_VRAM_VENDOR__WINBOND', 'AMDSMI_XGMI_STATUS_ERROR', 'AMDSMI_XGMI_STATUS_MULTIPLE_ERRORS', 'AMDSMI_XGMI_STATUS_NO_ERRORS', 'AMD_APU', 'AMD_CPU', - 'AMD_CPU_CORE', 'AMD_GPU', 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', - 'CLK_TYPE_DCLK1', 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', - 'CLK_TYPE_MEM', 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', - 'CLK_TYPE_VCLK0', 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', - 'COMPUTE_PARTITION_CPX', 'COMPUTE_PARTITION_DPX', - 'COMPUTE_PARTITION_INVALID', 'COMPUTE_PARTITION_QPX', - 'COMPUTE_PARTITION_SPX', 'COMPUTE_PARTITION_TPX', - 'CONTAINER_DOCKER', 'CONTAINER_LXC', 'FW_ID_ASD', 'FW_ID_CP_CE', - 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', 'FW_ID_CP_MEC2', - 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', 'FW_ID_CP_MES', - 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', 'FW_ID_DMCU', - 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', 'FW_ID_DRV_CAP', - 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', 'FW_ID_IMU_IRAM', 'FW_ID_ISP', - 'FW_ID_MC', 'FW_ID_MES_KIQ', 'FW_ID_MES_STACK', - 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', 'FW_ID_MMSCH', - 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', + 'AMD_CPU_CORE', 'AMD_GPU', 'CACHE_FLAGS_CPU_CACHE', + 'CACHE_FLAGS_DATA_CACHE', 'CACHE_FLAGS_ENABLED', + 'CACHE_FLAGS_INST_CACHE', 'CACHE_FLAGS_SIMD_CACHE', + 'CLK_TYPE_DCEF', 'CLK_TYPE_DCLK0', 'CLK_TYPE_DCLK1', + 'CLK_TYPE_DF', 'CLK_TYPE_FIRST', 'CLK_TYPE_GFX', 'CLK_TYPE_MEM', + 'CLK_TYPE_PCIE', 'CLK_TYPE_SOC', 'CLK_TYPE_SYS', 'CLK_TYPE_VCLK0', + 'CLK_TYPE_VCLK1', 'CLK_TYPE__MAX', 'COMPUTE_PARTITION_CPX', + 'COMPUTE_PARTITION_DPX', 'COMPUTE_PARTITION_INVALID', + 'COMPUTE_PARTITION_QPX', 'COMPUTE_PARTITION_SPX', + 'COMPUTE_PARTITION_TPX', 'CONTAINER_DOCKER', 'CONTAINER_LXC', + 'FW_ID_ASD', 'FW_ID_CP_CE', 'FW_ID_CP_ME', 'FW_ID_CP_MEC1', + 'FW_ID_CP_MEC2', 'FW_ID_CP_MEC_JT1', 'FW_ID_CP_MEC_JT2', + 'FW_ID_CP_MES', 'FW_ID_CP_PFP', 'FW_ID_CP_PM4', 'FW_ID_DFC', + 'FW_ID_DMCU', 'FW_ID_DMCU_ERAM', 'FW_ID_DMCU_ISR', + 'FW_ID_DRV_CAP', 'FW_ID_FIRST', 'FW_ID_IMU_DRAM', + 'FW_ID_IMU_IRAM', 'FW_ID_ISP', 'FW_ID_MC', 'FW_ID_MES_KIQ', + 'FW_ID_MES_STACK', 'FW_ID_MES_THREAD1', 'FW_ID_MES_THREAD1_STACK', + 'FW_ID_MMSCH', 'FW_ID_PPTABLE', 'FW_ID_PSP_BL', 'FW_ID_PSP_DBG', 'FW_ID_PSP_INTF', 'FW_ID_PSP_KEYDB', 'FW_ID_PSP_SOC', 'FW_ID_PSP_SOSDRV', 'FW_ID_PSP_SPL', 'FW_ID_PSP_SYSDRV', 'FW_ID_PSP_TOC', 'FW_ID_REG_ACCESS_WHITELIST', 'FW_ID_RLC', @@ -2242,12 +2260,12 @@ __all__ = \ 'VRAM_TYPE_UNKNOWN', 'VRAM_TYPE__MAX', 'WR_BW0', 'amd_metrics_table_header_t', 'amdsmi_asic_info_t', 'amdsmi_bdf_t', 'amdsmi_bit_field_t', 'amdsmi_board_info_t', - 'amdsmi_clk_info_t', 'amdsmi_clk_type_t', - 'amdsmi_compute_partition_type_t', 'amdsmi_container_types_t', - 'amdsmi_counter_command_t', 'amdsmi_counter_value_t', - 'amdsmi_cpu_apb_disable', 'amdsmi_cpu_apb_enable', - 'amdsmi_cpusocket_handle', 'amdsmi_ddr_bw_metrics_t', - 'amdsmi_dev_compute_partition_get', + 'amdsmi_cache_flags_type_t', 'amdsmi_clk_info_t', + 'amdsmi_clk_type_t', 'amdsmi_compute_partition_type_t', + 'amdsmi_container_types_t', 'amdsmi_counter_command_t', + 'amdsmi_counter_value_t', 'amdsmi_cpu_apb_disable', + 'amdsmi_cpu_apb_enable', 'amdsmi_cpusocket_handle', + 'amdsmi_ddr_bw_metrics_t', 'amdsmi_dev_compute_partition_get', 'amdsmi_dev_compute_partition_reset', 'amdsmi_dev_compute_partition_set', 'amdsmi_dev_memory_partition_get', From 0a90c7cfc80e91f1f2b0e3891be66e12c6c6e4b7 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 25 Oct 2023 18:52:46 -0500 Subject: [PATCH 24/33] SWDEV-429037 - Automatically install amdsmi python lib with package Signed-off-by: Maisam Arif Change-Id: I9c8c1335982ebd61a29da6f66c635f0a97d95f6e [ROCm/amdsmi commit: c2e12feb6a0499c417633317be4a64c1d61a1c50] --- projects/amdsmi/CMakeLists.txt | 13 +- projects/amdsmi/DEBIAN/postinst.in | 30 ++++ projects/amdsmi/DEBIAN/prerm.in | 25 +++ projects/amdsmi/README.md | 157 ++++++++---------- projects/amdsmi/RPM/post.in | 30 ++++ projects/amdsmi/RPM/preun.in | 26 +++ projects/amdsmi/amdsmi_cli/README.md | 56 +++---- projects/amdsmi/amdsmi_cli/amdsmi_init.py | 2 +- projects/amdsmi/py-interface/CMakeLists.txt | 2 +- projects/amdsmi/py-interface/README.md | 2 +- .../amdsmi/py-interface/amdsmi_wrapper.py.in | 1 + projects/amdsmi/src/CMakeLists.txt | 2 +- 12 files changed, 213 insertions(+), 133 deletions(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index ab61539758..7d538d59fb 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -241,12 +241,12 @@ install( #Debian package specific variables set(CPACK_DEBIAN_PACKAGE_PROVIDES "amd-smi") -set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sudo, libdrm-dev, python3-yaml") +set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "sudo, libdrm-dev, python3-yaml, python3-argcomplete") set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS}) set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS}) set(CPACK_DEBIAN_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan") set(CPACK_DEBIAN_DEV_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3 (>= 3.7.9)") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "python3 (>= 3.6.8), python3-pip") set(CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) set(CPACK_DEBIAN_DEV_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS}) @@ -265,10 +265,13 @@ endif() set(CPACK_RPM_PACKAGE_PROVIDES "amd-smi") set(CPACK_RPM_DEV_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}") set(CPACK_RPM_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan") -# python version gated by rhel8 :( -set(CPACK_RPM_PACKAGE_SUGGESTS "python3 >= 3.6.8") +set(CPACK_RPM_PACKAGE_SUGGESTS "python3-argcomplete") set(CPACK_RPM_DEV_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS}) set(CPACK_RPM_ASAN_PACKAGE_SUGGESTS ${CPACK_RPM_PACKAGE_SUGGESTS}) +# python version gated by rhel8 :( +set(CPACK_RPM_PACKAGE_REQUIRES "python3 >= 3.6.8, python3-pip") +set(CPACK_RPM_DEV_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) +set(CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CPACK_RPM_PACKAGE_REQUIRES}) # don't terminate if bytecompile of python files fails set(CPACK_RPM_SPEC_MORE_DEFINE "%define _python_bytecompile_errors_terminate_build 0") @@ -306,7 +309,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/post.in" RPM/post @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/preun.in" RPM/preun @ONLY) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/RPM/postun.in" RPM/postun @ONLY) set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post") -set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/preun" ) +set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/preun") set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/postun") #Set the names now using CPACK utility diff --git a/projects/amdsmi/DEBIAN/postinst.in b/projects/amdsmi/DEBIAN/postinst.in index 097bb34bed..a4969efc46 100755 --- a/projects/amdsmi/DEBIAN/postinst.in +++ b/projects/amdsmi/DEBIAN/postinst.in @@ -104,8 +104,38 @@ do_ldconfig() { fi } +do_install_amdsmi_python_lib() { + # get python version + local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + if [ $? -ne 0 ]; then + echo "[WARNING] Could not determine python version. "\ + "AMD-SMI python library will not be installed." + return + fi + + # check if python version is supported + if [ "$python3_minor_version" -lt 6 ]; then + echo "[WARNING] AMD-SMI python library is not "\ + "supported on python version 3.$python3_minor_version. "\ + "AMD-SMI python library will not be installed." + return + fi + + # Remove old python library + python3 -m pip uninstall amdsmi --yes --quiet + + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi + local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ + python3 -m pip install "$python_lib_path" + python3 -m pip show argcomplete + if [ $? -ne 1 ]; then + activate-global-python-argcomplete + fi +} + case "$1" in ( configure ) + do_install_amdsmi_python_lib do_ldconfig do_configureLogrotate || return 0 ;; diff --git a/projects/amdsmi/DEBIAN/prerm.in b/projects/amdsmi/DEBIAN/prerm.in index 3a4ab7ff26..6ec49763f3 100755 --- a/projects/amdsmi/DEBIAN/prerm.in +++ b/projects/amdsmi/DEBIAN/prerm.in @@ -33,11 +33,36 @@ return_logrotateToOrigConfig() { fi } +rm_python_lib() { + # get python version + local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + if [ $? -ne 0 ]; then + echo "[WARNING] Could not determine python version. "\ + "AMD-SMI python library will not be uninstalled." + return + fi + + # check if python version is supported + if [ "$python3_minor_version" -lt 6 ]; then + echo "[INFO] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ + "AMD-SMI python library will not be uninstalled." + return + fi + + python3 -m pip uninstall amdsmi --yes + python3 -m pip show amdsmi + if [ $? -ne 1 ]; then + echo "[WARNING] AMD-SMI python library (amdsmi) is still installed. "\ + "Check post install to ensure version is correct" + return + fi +} case "$1" in ( remove | upgrade) # remove old gpuv-smi symlink rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null + rm_python_lib rm_ldconfig rm_pyc rm_logFolder diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index 0cfe1b1458..2b5f924e98 100755 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -17,7 +17,71 @@ AMD SMI library can run on AMD ROCm supported platforms, please refer to [List o To run the AMD SMI library, the amdgpu driver and the hsmp driver needs to be installed. Optionally, the libdrm can be installed to query firmware information and hardware IPs. -## Usage Basics +## Install CLI Tool and Libraries + +### Requirements + +* python 3.6.8+ 64-bit +* amdgpu driver must be loaded for amdsmi_init() to pass + +### Installation + +* Install amdgpu driver +* Install amd-smi-lib package through package manager +* amd-smi --help + +### Install Example for Ubuntu 22.04 + +``` bash +apt install amd-smi-lib +amd-smi --help +``` + +### Optional autocompletion + +`amd-smi` cli application supports autocompletion. The package should attempt to install it, if argcomplete is not installed you can enable it by using the following commands: + +```bash +python3 -m pip install argcomplete +activate-global-python-argcomplete +# restart shell to enable +``` + +### Manual/Multiple Rocm Instance Python Library Install + +In the event there are multiple rocm installations and pyenv is not being used, to use the correct amdsmi version you must uninstall previous versions of amd-smi and install the version you want directly from your rocm instance. + +#### Python Library Install Example for Ubuntu 22.04 + +Remove previous amdsmi installation: + +```bash +python3 -m pip list | grep amd +python3 -m pip uninstall amdsmi +``` + +Then install Python library from your target rocm instance: + +``` bash +apt install amd-smi-lib +amd-smi --help +cd /opt/rocm/share/amd_smi +python3 -m pip install --upgrade pip +python3 -m pip install --user . +``` + +Now you have the amdsmi python library in your python path: + +``` bash +~$ python3 +Python 3.8.10 (default, May 26 2023, 14:05:08) +[GCC 9.4.0] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> import amdsmi +>>> +``` + +## Usage Basics for the C Library ### Device/Socket handles @@ -133,92 +197,7 @@ The output will be in `docs/_build/html`. For additional details, see the [ROCm Contributing Guide](https://rocm.docs.amd.com/en/latest/contributing.html#building-documentation) -## Install CLI Tool and Python Library - -### Requirements - -* python 3.7+ 64-bit -* amdgpu driver and hsmp driver must be loaded for amdsmi_init() to pass - -### Optional autocompletion - -`amd-smi` cli application supports autocompletion. It is enabled by using the -following commands: - -```bash -python3 -m pip install argcomplete -activate-global-python-argcomplete -# restart shell to enable -``` - -### CLI Installation - -Before amd-smi install, ensure previous versions of amdsmi library are uninstalled using pip: - -```bash -python3 -m pip list | grep amd -python3 -m pip uninstall amdsmi -``` - -* Install amdgpu driver -* Install amd-smi-lib package through package manager -* amd-smi --help - -### Install Example for Ubuntu 22.04 - -``` bash -python3 -m pip list | grep amd -python3 -m pip uninstall amdsmi -apt install amd-smi-lib -amd-smi --help -``` - -### Python Development Library Installation - -This option is for users who want to develop their own scripts using amd-smi's python library - -Verify that your python version is 3.7+ to install the python library - -* Install amdgpu driver -* Install amd-smi-lib package through package manager -* cd /opt/rocm/share/amd_smi -* python3 -m pip install --upgrade pip -* python3 -m pip install --user . -* import amdsmi in python to start development - -Warning: this will take precedence over the cli tool's library install, to avoid issues run these steps after every amd-smi-lib update. - -#### Older RPM Packaged OS's - -The default python versions in older RPM based OS's are not gauranteed to have the minium version. - -For example RHEL 8 and SLES 15 are 3.6.8 and 3.6.15 . You will need to ensure the latest yaml package is installed ( pyyaml >= 5.1) pyyaml is installed to your pip instance: - -``` bash -python3 -m pip install pyyaml -amd-smi list -``` - -While the CLI will work with these older python versions, to install the python development library you need to upgrade to python 3.7+ - -#### Python Library Install Example for Ubuntu 22.04 - -``` bash -apt install amd-smi-lib -amd-smi --help -cd /opt/rocm/share/amd_smi -python3 -m pip install --upgrade pip -python3 -m pip install --user . -``` - -``` bash -python3 -Python 3.8.10 (default, May 26 2023, 14:05:08) -[GCC 9.4.0] on linux -Type "help", "copyright", "credits" or "license" for more information. ->>> import amdsmi ->>> -``` +## Building AMD SMI ### Rebuilding Python wrapper @@ -236,8 +215,6 @@ Note: To be able to re-generate python wrapper you need **docker** installed. Note: python_wrapper is NOT automatically re-generated. You must run `./update_wrapper.sh`. -## Building AMD SMI - ### Additional Required software for building In order to build the AMD SMI library, the following components are required. Note that the software versions listed are what was used in development. Earlier versions are not guaranteed to work: @@ -248,7 +225,7 @@ In order to build the AMD SMI library, the following components are required. No In order to build the AMD SMI python package, the following components are required: * clang (14.0 or above) -* python (3.7 or above) +* python (3.6.8 or above) * virtualenv - `python3 -m pip install virtualenv` In order to build the latest documentation, the following are required: diff --git a/projects/amdsmi/RPM/post.in b/projects/amdsmi/RPM/post.in index 454ad2909f..47dedb1baf 100755 --- a/projects/amdsmi/RPM/post.in +++ b/projects/amdsmi/RPM/post.in @@ -104,8 +104,38 @@ do_ldconfig() { fi } +do_install_amdsmi_python_lib() { + # get python version + local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + if [ $? -ne 0 ]; then + echo "[WARNING] Could not determine python version. "\ + "AMD-SMI python library will not be installed." + return + fi + + # check if python version is supported + if [ "$python3_minor_version" -lt 6 ]; then + echo "[WARNING] AMD-SMI python library is not "\ + "supported on python version 3.$python3_minor_version. "\ + "AMD-SMI python library will not be installed." + return + fi + + # Remove old python library + python3 -m pip uninstall amdsmi --yes --quiet + + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi + local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ + python3 -m pip install "$python_lib_path" + python3 -m pip show argcomplete + if [ $? -ne 1 ]; then + activate-global-python-argcomplete + fi +} + # post install or upgrade, $i is 1 or 2 -> do these actions if [ "$1" -ge 1 ]; then + do_install_amdsmi_python_lib do_ldconfig do_configureLogrotate || return 0 fi diff --git a/projects/amdsmi/RPM/preun.in b/projects/amdsmi/RPM/preun.in index f607a4ac7c..85333f7984 100755 --- a/projects/amdsmi/RPM/preun.in +++ b/projects/amdsmi/RPM/preun.in @@ -25,10 +25,36 @@ return_logrotateToOrigConfig() { fi } +rm_python_lib() { + # get python version + local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + if [ $? -ne 0 ]; then + echo "[WARNING] Could not determine python version. "\ + "AMD-SMI python library will not be uninstalled." + return + fi + + # check if python version is supported + if [ "$python3_minor_version" -lt 6 ]; then + echo "[INFO] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ + "AMD-SMI python library will not be uninstalled." + return + fi + + python3 -m pip uninstall amdsmi --yes + python3 -m pip show amdsmi + if [ $? -ne 1 ]; then + echo "[WARNING] AMD-SMI python library (amdsmi) is still installed. "\ + "Check post install to ensure version is correct" + return + fi +} + if [ "$1" -le 1 ]; then # perform the below actions for rpm remove($1=0) or upgrade($1=1) operations # remove old gpuv-smi symlink rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null + rm_python_lib rm_pyc rm_logFolder return_logrotateToOrigConfig diff --git a/projects/amdsmi/amdsmi_cli/README.md b/projects/amdsmi/amdsmi_cli/README.md index 2d48154e50..aae5e23f26 100644 --- a/projects/amdsmi/amdsmi_cli/README.md +++ b/projects/amdsmi/amdsmi_cli/README.md @@ -10,17 +10,10 @@ Recommended: At least one AMD GPU with AMD driver installed ### Requirements -* python 3.7+ 64-bit +* python 3.6.8+ 64-bit * amdgpu driver must be loaded for amdsmi_init() to pass -### CLI Installation - -Before amd-smi install, ensure previous versions of amdsmi library are uninstalled using pip: - -```bash -python3 -m pip list | grep amd -python3 -m pip uninstall amdsmi -``` +### Installation * Install amdgpu driver * Install amd-smi-lib package through package manager @@ -29,42 +22,35 @@ python3 -m pip uninstall amdsmi ### Install Example for Ubuntu 22.04 ``` bash -python3 -m pip list | grep amd -python3 -m pip uninstall amdsmi apt install amd-smi-lib amd-smi --help ``` -### Python Development Library Installation +### Optional autocompletion -This option is for users who want to develop their own scripts using amd-smi's python library +`amd-smi` cli application supports autocompletion. The package should attempt to install it, if argcomplete is not installed you can enable it by using the following commands: -Verify that your python version is 3.7+ to install the python library - -* Install amdgpu driver -* Install amd-smi-lib package through package manager -* cd /opt/rocm/share/amd_smi -* python3 -m pip install --upgrade pip -* python3 -m pip install --user . -* import amdsmi in python to start development - -Warning: this will take precedence over the cli tool's library install, to avoid issues run these steps after every amd-smi-lib update. - -#### Older RPM Packaged OS's - -The default python versions in older RPM based OS's are not gauranteed to have the minium version. - -For example RHEL 8 and SLES 15 are 3.6.8 and 3.6.15 . You will need to ensure the latest yaml package is installed ( pyyaml >= 5.1) pyyaml is installed to your pip instance: - -``` bash -python3 -m pip install pyyaml -amd-smi list +```bash +python3 -m pip install argcomplete +activate-global-python-argcomplete +# restart shell to enable ``` -While the CLI will work with these older python versions, to install the python development library you need to upgrade to python 3.7+ +### Manual/Multiple Rocm Instance Python Library Install + +In the event there are multiple rocm installations and pyenv is not being used, to use the correct amdsmi version you must uninstall previous versions of amd-smi and install the version you want directly from your rocm instance. #### Python Library Install Example for Ubuntu 22.04 +Remove previous amdsmi installation: + +```bash +python3 -m pip list | grep amd +python3 -m pip uninstall amdsmi +``` + +Then install Python library from your target rocm instance: + ``` bash apt install amd-smi-lib amd-smi --help @@ -73,6 +59,8 @@ python3 -m pip install --upgrade pip python3 -m pip install --user . ``` +Now you have the amdsmi python library in your python path: + ``` bash ~$ python3 Python 3.8.10 (default, May 26 2023, 14:05:08) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_init.py b/projects/amdsmi/amdsmi_cli/amdsmi_init.py index a1cb955d02..8e56cbbd3a 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_init.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_init.py @@ -30,8 +30,8 @@ import sys from pathlib import Path sys.path.append(f"{Path(__file__).resolve().parent}/../../share/amd_smi") -sys.path.append("/opt/rocm/share/amd_smi") +# If the python library is installed, it will overwrite the path above from amdsmi import amdsmi_interface from amdsmi import amdsmi_exception diff --git a/projects/amdsmi/py-interface/CMakeLists.txt b/projects/amdsmi/py-interface/CMakeLists.txt index 048b456a62..0d2160d1b1 100644 --- a/projects/amdsmi/py-interface/CMakeLists.txt +++ b/projects/amdsmi/py-interface/CMakeLists.txt @@ -46,7 +46,7 @@ if(NOT GOOD_CLANG_FOUND) COMMAND mkdir -p ${PY_PACKAGE_DIR} COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) else() - find_package(Python3 3.7 COMPONENTS Interpreter Development REQUIRED) + find_package(Python3 3.6 COMPONENTS Interpreter Development REQUIRED) # --break-system-packages is needed for python 3.11 # see: https://peps.python.org/pep-0668/ if (NOT Python3_VERSION VERSION_LESS "3.11") diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index c3033ef149..7b254b0f86 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -2,7 +2,7 @@ ## Requirements -* python 3.7+ 64-bit +* python 3.6+ 64-bit * driver must be loaded for amdsmi_init() to pass ## Overview diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in index 00ae691291..27b62a7235 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py.in @@ -168,6 +168,7 @@ def char_pointer_cast(string, encoding='utf-8'): _libraries = {} from pathlib import Path +### TODO: Add lib build folder cmake variable or dynamic libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so") libamd_smi_optrocm = Path("/opt/rocm/lib/libamd_smi.so") libamd_smi_parent_dir = Path(__file__).resolve().parent / "libamd_smi.so" diff --git a/projects/amdsmi/src/CMakeLists.txt b/projects/amdsmi/src/CMakeLists.txt index 7e5d043e75..15e3a1977b 100644 --- a/projects/amdsmi/src/CMakeLists.txt +++ b/projects/amdsmi/src/CMakeLists.txt @@ -3,7 +3,7 @@ # message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") -message(" CMake AMD SMI (Library) ") +message(" CMake AMD SMI C/C++ Library ") message("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&") message("") From 8535f6993d12376ea17c369470ae17ad28835f15 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Tue, 31 Oct 2023 01:45:38 -0500 Subject: [PATCH 25/33] Don't crash [un]install scripts on python failure Change-Id: Icfbcc647bda94dd2ff2f65016de5c80af5d1ec79 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 08268ba1c16bdcc350ea641372937089fcfd10f4] --- projects/amdsmi/DEBIAN/postinst.in | 5 +++-- projects/amdsmi/DEBIAN/prerm.in | 7 ++++--- projects/amdsmi/RPM/post.in | 5 +++-- projects/amdsmi/RPM/preun.in | 7 ++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/projects/amdsmi/DEBIAN/postinst.in b/projects/amdsmi/DEBIAN/postinst.in index a4969efc46..c168fa4d75 100755 --- a/projects/amdsmi/DEBIAN/postinst.in +++ b/projects/amdsmi/DEBIAN/postinst.in @@ -106,7 +106,8 @@ do_ldconfig() { do_install_amdsmi_python_lib() { # get python version - local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + local python3_minor_version + python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') if [ $? -ne 0 ]; then echo "[WARNING] Could not determine python version. "\ "AMD-SMI python library will not be installed." @@ -135,7 +136,7 @@ do_install_amdsmi_python_lib() { case "$1" in ( configure ) - do_install_amdsmi_python_lib + do_install_amdsmi_python_lib || return 0 do_ldconfig do_configureLogrotate || return 0 ;; diff --git a/projects/amdsmi/DEBIAN/prerm.in b/projects/amdsmi/DEBIAN/prerm.in index 6ec49763f3..186593ce2e 100755 --- a/projects/amdsmi/DEBIAN/prerm.in +++ b/projects/amdsmi/DEBIAN/prerm.in @@ -35,7 +35,8 @@ return_logrotateToOrigConfig() { rm_python_lib() { # get python version - local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + local python3_minor_version + python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') if [ $? -ne 0 ]; then echo "[WARNING] Could not determine python version. "\ "AMD-SMI python library will not be uninstalled." @@ -44,7 +45,7 @@ rm_python_lib() { # check if python version is supported if [ "$python3_minor_version" -lt 6 ]; then - echo "[INFO] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ + echo "[WARNING] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ "AMD-SMI python library will not be uninstalled." return fi @@ -62,7 +63,7 @@ case "$1" in ( remove | upgrade) # remove old gpuv-smi symlink rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null - rm_python_lib + rm_python_lib || return 0 rm_ldconfig rm_pyc rm_logFolder diff --git a/projects/amdsmi/RPM/post.in b/projects/amdsmi/RPM/post.in index 47dedb1baf..cf760e9d07 100755 --- a/projects/amdsmi/RPM/post.in +++ b/projects/amdsmi/RPM/post.in @@ -106,7 +106,8 @@ do_ldconfig() { do_install_amdsmi_python_lib() { # get python version - local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + local python3_minor_version + python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') if [ $? -ne 0 ]; then echo "[WARNING] Could not determine python version. "\ "AMD-SMI python library will not be installed." @@ -135,7 +136,7 @@ do_install_amdsmi_python_lib() { # post install or upgrade, $i is 1 or 2 -> do these actions if [ "$1" -ge 1 ]; then - do_install_amdsmi_python_lib + do_install_amdsmi_python_lib || return 0 do_ldconfig do_configureLogrotate || return 0 fi diff --git a/projects/amdsmi/RPM/preun.in b/projects/amdsmi/RPM/preun.in index 85333f7984..00bd4d374c 100755 --- a/projects/amdsmi/RPM/preun.in +++ b/projects/amdsmi/RPM/preun.in @@ -27,7 +27,8 @@ return_logrotateToOrigConfig() { rm_python_lib() { # get python version - local python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') + local python3_minor_version + python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)') if [ $? -ne 0 ]; then echo "[WARNING] Could not determine python version. "\ "AMD-SMI python library will not be uninstalled." @@ -36,7 +37,7 @@ rm_python_lib() { # check if python version is supported if [ "$python3_minor_version" -lt 6 ]; then - echo "[INFO] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ + echo "[WARNING] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\ "AMD-SMI python library will not be uninstalled." return fi @@ -54,7 +55,7 @@ if [ "$1" -le 1 ]; then # perform the below actions for rpm remove($1=0) or upgrade($1=1) operations # remove old gpuv-smi symlink rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null - rm_python_lib + rm_python_lib || return 0 rm_pyc rm_logFolder return_logrotateToOrigConfig From 009da920b770d43243ada512924f89d1ff95ac64 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Wed, 1 Nov 2023 18:36:43 -0500 Subject: [PATCH 26/33] Remove absolute link to libamd_smi.so Also modify README to include: export PATH="$PATH:/opt/rocm/bin" Change-Id: Ib4513d61fd3e6b23cc789491c11d83e6a6de947a Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 874d8edb3dcfbe935325cab0a7f4b343d4eae236] --- projects/amdsmi/README.md | 3 +- projects/amdsmi/py-interface/CMakeLists.txt | 38 +++++++++---------- ...amdsmi_wrapper.py.in => amdsmi_wrapper.py} | 11 +----- .../amdsmi/py-interface/pyproject.toml.in | 4 ++ projects/amdsmi/py-interface/setup.cfg.in | 3 ++ projects/amdsmi/tools/generator.py | 10 +---- projects/amdsmi/update_wrapper.sh | 7 ++-- 7 files changed, 34 insertions(+), 42 deletions(-) rename projects/amdsmi/py-interface/{amdsmi_wrapper.py.in => amdsmi_wrapper.py} (99%) diff --git a/projects/amdsmi/README.md b/projects/amdsmi/README.md index 2b5f924e98..c4568921b9 100755 --- a/projects/amdsmi/README.md +++ b/projects/amdsmi/README.md @@ -34,6 +34,8 @@ installed to query firmware information and hardware IPs. ``` bash apt install amd-smi-lib +# if installed with rocm ignore the export +export PATH="$PATH:/opt/rocm/bin" amd-smi --help ``` @@ -64,7 +66,6 @@ Then install Python library from your target rocm instance: ``` bash apt install amd-smi-lib -amd-smi --help cd /opt/rocm/share/amd_smi python3 -m pip install --upgrade pip python3 -m pip install --user . diff --git a/projects/amdsmi/py-interface/CMakeLists.txt b/projects/amdsmi/py-interface/CMakeLists.txt index 0d2160d1b1..d55e9b6fca 100644 --- a/projects/amdsmi/py-interface/CMakeLists.txt +++ b/projects/amdsmi/py-interface/CMakeLists.txt @@ -36,15 +36,9 @@ if(NOT GOOD_CLANG_FOUND) OUTPUT amdsmi_wrapper.py ${PY_PACKAGE_DIR}/amdsmi_wrapper.py DEPENDS ${AMD_SMI} - ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in - # remove .in suffix when copying - COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py - # hacky alternative to configure_file that will run at MAKE compile instead of CMake configure - COMMAND sed -i - s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g - ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py + ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py COMMAND mkdir -p ${PY_PACKAGE_DIR} - COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) + COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) else() find_package(Python3 3.6 COMPONENTS Interpreter Development REQUIRED) # --break-system-packages is needed for python 3.11 @@ -59,7 +53,7 @@ else() configure_file(${PROJECT_SOURCE_DIR}/tools/generator.py generator.py @ONLY COPYONLY) add_custom_command( OUTPUT amdsmi.h - ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in + ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py amdsmi_wrapper.py ${PY_PACKAGE_DIR}/amdsmi_wrapper.py DEPENDS ${AMD_SMI} @@ -67,15 +61,9 @@ else() generator.py ${PROJECT_SOURCE_DIR}/include/amd_smi/amdsmi.h COMMAND cp ${PROJECT_SOURCE_DIR}/include/amd_smi/amdsmi.h ./ - COMMAND ${Python3_EXECUTABLE} generator.py "$<$:-e -DENABLE_ESMI_LIB>" -i amdsmi.h -l ${PROJECT_BINARY_DIR}/src/libamd_smi.so -o ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in - # remove .in suffix when copying - COMMAND cp -f ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py.in ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py - # hacky alternative to configure_file that will run at MAKE compile instead of CMake configure - COMMAND sed -i - s:"@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@":"${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}":g - ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py + COMMAND ${Python3_EXECUTABLE} generator.py "$<$:-e -DENABLE_ESMI_LIB>" -i amdsmi.h -l ${PROJECT_BINARY_DIR}/src/libamd_smi.so -o ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py COMMAND mkdir -p ${PY_PACKAGE_DIR} - COMMAND ln -Pf ${CMAKE_CURRENT_BINARY_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) + COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_wrapper.py ${PY_PACKAGE_DIR}/) endif() # populate version string @@ -98,7 +86,17 @@ add_custom_command( COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/ COMMAND ln -Pf ${CMAKE_CURRENT_SOURCE_DIR}/README.md ${PY_PACKAGE_DIR}/ - COMMAND ln -Pf ${PROJECT_SOURCE_DIR}/LICENSE ${PY_PACKAGE_DIR}/) + COMMAND ln -Pf ${PROJECT_SOURCE_DIR}/LICENSE ${PY_PACKAGE_DIR}/ + ) + +# copy libamd_smi.so to allow for a self-contained python package +add_custom_command( + OUTPUT ${PY_PACKAGE_DIR}/libamd_smi.so + DEPENDS ${PROJECT_BINARY_DIR}/src/libamd_smi.so + COMMAND cp + "${PROJECT_BINARY_DIR}/src/libamd_smi.so" + ${PY_PACKAGE_DIR}/ + ) add_custom_target( python_package ALL @@ -108,7 +106,9 @@ add_custom_target( ${PY_PACKAGE_DIR}/amdsmi_exception.py ${PY_PACKAGE_DIR}/amdsmi_interface.py ${PY_PACKAGE_DIR}/README.md - ${PY_PACKAGE_DIR}/LICENSE) + ${PY_PACKAGE_DIR}/LICENSE + ${PY_PACKAGE_DIR}/libamd_smi.so + ) install( FILES diff --git a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in b/projects/amdsmi/py-interface/amdsmi_wrapper.py similarity index 99% rename from projects/amdsmi/py-interface/amdsmi_wrapper.py.in rename to projects/amdsmi/py-interface/amdsmi_wrapper.py index 27b62a7235..fafa936ecf 100644 --- a/projects/amdsmi/py-interface/amdsmi_wrapper.py.in +++ b/projects/amdsmi/py-interface/amdsmi_wrapper.py @@ -168,20 +168,11 @@ def char_pointer_cast(string, encoding='utf-8'): _libraries = {} from pathlib import Path -### TODO: Add lib build folder cmake variable or dynamic -libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so") -libamd_smi_optrocm = Path("/opt/rocm/lib/libamd_smi.so") libamd_smi_parent_dir = Path(__file__).resolve().parent / "libamd_smi.so" libamd_smi_cwd = Path.cwd() / "libamd_smi.so" try: - if libamd_smi_cpack.is_file(): - # try to find library in install directory provided by CMake - _libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_cpack) - elif libamd_smi_optrocm.is_file(): - # try /opt/rocm/lib as a fallback - _libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_optrocm) - elif libamd_smi_parent_dir.is_file(): + if libamd_smi_parent_dir.is_file(): # try to fall back to parent directory _libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_parent_dir) else: diff --git a/projects/amdsmi/py-interface/pyproject.toml.in b/projects/amdsmi/py-interface/pyproject.toml.in index 34368333c8..45b18e4d11 100644 --- a/projects/amdsmi/py-interface/pyproject.toml.in +++ b/projects/amdsmi/py-interface/pyproject.toml.in @@ -25,3 +25,7 @@ dependencies = [ [tool.setuptools] packages = ["amdsmi"] + +# install libamd_smi.so +[tool.setuptools.package-data] +amdsmi = ["*.so"] diff --git a/projects/amdsmi/py-interface/setup.cfg.in b/projects/amdsmi/py-interface/setup.cfg.in index d266f8c231..3647feae6b 100644 --- a/projects/amdsmi/py-interface/setup.cfg.in +++ b/projects/amdsmi/py-interface/setup.cfg.in @@ -4,3 +4,6 @@ [metadata] name = amdsmi version = @amd_smi_libraries_VERSION_STRING@ + +[options.package_data] +amdsmi = *.so diff --git a/projects/amdsmi/tools/generator.py b/projects/amdsmi/tools/generator.py index 18383ee118..cc3db2f92b 100644 --- a/projects/amdsmi/tools/generator.py +++ b/projects/amdsmi/tools/generator.py @@ -114,19 +114,11 @@ def main(): library_path = os.path.join(os.path.dirname(__file__), library) line_to_replace = "_libraries['{}'] = ctypes.CDLL('{}')".format(library_name, library_path) new_line = f"""from pathlib import Path -libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/{library_name}") -libamd_smi_optrocm = Path("/opt/rocm/lib/{library_name}") libamd_smi_parent_dir = Path(__file__).resolve().parent / "{library_name}" libamd_smi_cwd = Path.cwd() / "{library_name}" try: - if libamd_smi_cpack.is_file(): - # try to find library in install directory provided by CMake - _libraries['{library_name}'] = ctypes.CDLL(libamd_smi_cpack) - elif libamd_smi_optrocm.is_file(): - # try /opt/rocm/lib as a fallback - _libraries['{library_name}'] = ctypes.CDLL(libamd_smi_optrocm) - elif libamd_smi_parent_dir.is_file(): + if libamd_smi_parent_dir.is_file(): # try to fall back to parent directory _libraries['{library_name}'] = ctypes.CDLL(libamd_smi_parent_dir) else: diff --git a/projects/amdsmi/update_wrapper.sh b/projects/amdsmi/update_wrapper.sh index fdbb2985c9..d6557d92c0 100755 --- a/projects/amdsmi/update_wrapper.sh +++ b/projects/amdsmi/update_wrapper.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# this program generates py-interface/amdsmi_wrapper.py.in +# this program generates py-interface/amdsmi_wrapper.py set -eu @@ -44,7 +44,8 @@ cp -r /src /tmp/src \ && rm -rf build .cache \ && cmake -B build -DBUILD_WRAPPER=ON $ENABLE_ESMI_LIB \ && make -C build -j $(nproc) \ - && cp /tmp/src/py-interface/amdsmi_wrapper.py.in /src/py-interface/amdsmi_wrapper.py.in" + && cp /tmp/src/py-interface/amdsmi_wrapper.py /src/py-interface/amdsmi_wrapper.py \ + && chown --reference /src/py-interface/CMakeLists.txt /src/py-interface/amdsmi_wrapper.py" echo -e "Generated new wrapper! -[$DIR/py-interface/amdsmi_wrapper.py.in]" +[$DIR/py-interface/amdsmi_wrapper.py]" From 517ea90c12fecf9d5e680427d6226f958f54da4d Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 2 Nov 2023 02:18:40 -0500 Subject: [PATCH 27/33] SWDEV-426130 - Fixed Decimal Firmwares & Readme Signed-off-by: Maisam Arif Change-Id: I850105561be91a2c2581106371af9fab1fd8fa98 [ROCm/amdsmi commit: 312732aa8a01a2e71f8ff759f6009b6c81c14b88] --- projects/amdsmi/amdsmi_cli/README.md | 40 +++++++++---------- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 8 ++-- projects/amdsmi/amdsmi_cli/amdsmi_helpers.py | 4 +- projects/amdsmi/py-interface/README.md | 3 +- .../amdsmi/py-interface/amdsmi_interface.py | 20 ++++++++-- 5 files changed, 45 insertions(+), 30 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/README.md b/projects/amdsmi/amdsmi_cli/README.md index aae5e23f26..0be74e1c29 100644 --- a/projects/amdsmi/amdsmi_cli/README.md +++ b/projects/amdsmi/amdsmi_cli/README.md @@ -120,8 +120,8 @@ GPU with some basic information for each VF. optional arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices Command Modifiers: --json Displays output in JSON format (human readable by default). @@ -143,8 +143,8 @@ If no static argument is provided, all static information will be displayed. Static Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -a, --asic All asic information -b, --bus All bus information -V, --vbios All video bios information (if available) @@ -175,8 +175,8 @@ If no GPU is specified, return firmware information for all GPUs on the system. Firmware Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -f, --ucode-list, --fw-list All FW list information Command Modifiers: @@ -197,8 +197,8 @@ If no GPU is specified, return bad page information for all GPUs on the system. Bad Pages Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -p, --pending Displays all pending retired pages -r, --retired Displays retired pages -u, --un-res Displays unreservable pages @@ -223,8 +223,8 @@ If no metric argument is provided all metric information will be displayed. Metric arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -w, --watch INTERVAL Reprint the command in a loop of INTERVAL seconds -W, --watch_time TIME The total TIME to watch the given command -i, --iterations ITERATIONS Total number of ITERATIONS to loop on the given command @@ -263,8 +263,8 @@ If no process argument is provided all process information will be displayed. Process arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF: 0000:23:00.0 | UUID: c4ff73bf-0000-1000-802e-0812b504ed69 - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -w, --watch INTERVAL Reprint the command in a loop of INTERVAL seconds -W, --watch_time TIME The total TIME to watch the given command -i, --iterations ITERATIONS Total number of ITERATIONS to loop on the given command @@ -292,8 +292,8 @@ If no GPU is specified, returns event information for all GPUs on the system. Event Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices Command Modifiers: --json Displays output in JSON format (human readable by default). @@ -314,8 +314,8 @@ If no topology argument is provided all topology information will be displayed. Topology arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID:0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -a, --access Displays link accessibility between GPUs -w, --weight Displays relative weight between GPUs -o, --hops Displays the number of hops between GPUs @@ -343,8 +343,8 @@ A set argument must be provided; Multiple set arguments are accepted Set Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF: 0000:23:00.0 | UUID: c4ff73bf-0000-1000-802e-0812b504ed69 - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -f, --fan % Set GPU fan speed (0-255 or 0-100%) -l, --perf-level LEVEL Set performance level -P, --profile SETPROFILE Set power profile level (#) or a quoted string of custom profile attributes @@ -374,8 +374,8 @@ A reset argument must be provided; Multiple reset arguments are accepted Reset Arguments: -h, --help show this help message and exit -g, --gpu GPU [GPU ...] Select a GPU ID, BDF, or UUID from the possible choices: - ID: 0 | BDF: 0000:23:00.0 | UUID: c4ff73bf-0000-1000-802e-0812b504ed69 - all | Selects all devices + ID: 0 | BDF:0000:23:00.0 | UUID:ffff73bf-0000-1000-80ff-ffffffffffff + all | Selects all devices -G, --gpureset Reset the specified GPU -c, --clocks Reset clocks and overdrive to default -f, --fans Reset fans to automatic (driver) control diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 741f78b960..3a8432e2cd 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -1131,8 +1131,8 @@ class AMDSMICommands(): "replay_roll_over_count" : "N/A", "nak_sent_count" : "N/A", "nak_received_count" : "N/A", - "current_bandwith_sent": "N/A", - "current_bandwith_received": "N/A", + "current_bandwidth_sent": "N/A", + "current_bandwidth_received": "N/A", "max_packet_size": "N/A"} try: @@ -1200,8 +1200,8 @@ class AMDSMICommands(): received = f"{received} MB/s" pcie_bw['max_pkt_sz'] = f"{pcie_bw['max_pkt_sz']} B" - pcie_dict['current_bandwith_sent'] = sent - pcie_dict['current_bandwith_received'] = received + pcie_dict['current_bandwidth_sent'] = sent + pcie_dict['current_bandwidth_received'] = received pcie_dict['max_packet_size'] = pcie_bw['max_pkt_sz'] except amdsmi_exception.AmdSmiLibraryException as e: logging.debug("Failed to get pcie bandwidth for gpu %s | %s", gpu_id, e.get_error_info()) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py index 2efb9a573b..cb5f7cf1bb 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py @@ -170,11 +170,11 @@ class AMDSMIHelpers(): id_padding = max_padding else: id_padding = max_padding - int(math.log10(gpu_id)) - gpu_choices_str += f"\tID: {gpu_id}{' ' * id_padding}| BDF: {bdf} | UUID: {uuid}\n" + gpu_choices_str += f"ID: {gpu_id}{' ' * id_padding}| BDF: {bdf} | UUID: {uuid}\n" # Add the all option to the gpu_choices gpu_choices["all"] = "all" - gpu_choices_str += f"\t all{' ' * max_padding}| Selects all devices\n" + gpu_choices_str += f" all{' ' * max_padding}| Selects all devices\n" return (gpu_choices, gpu_choices_str) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 7b254b0f86..8ef3ff222d 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -584,7 +584,8 @@ try: firmware_list = amdsmi_get_fw_info(device)['fw_list'] for firmware_block in firmware_list: print(firmware_block['fw_name']) - print(firmware_block['fw_version']) # String formated hex version ie: 21.00.00.AC + # String formated hex or decimal value ie: 21.00.00.AC or 130 + print(firmware_block['fw_version']) except AmdSmiException as e: print(e) ``` diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index 1e37eb7adf..e7adccfb29 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1375,12 +1375,26 @@ def amdsmi_get_fw_info( _check_res(amdsmi_wrapper.amdsmi_get_fw_info( processor_handle, ctypes.byref(fw_info))) + hex_format_fw = [AmdSmiFwBlock.FW_ID_SMC, + AmdSmiFwBlock.FW_ID_PSP_SOSDRV, + AmdSmiFwBlock.FW_ID_TA_RAS, + AmdSmiFwBlock.FW_ID_XGMI, + AmdSmiFwBlock.FW_ID_UVD, + AmdSmiFwBlock.FW_ID_VCE, + AmdSmiFwBlock.FW_ID_VCN] + firmwares = [] for i in range(0, fw_info.num_fw_info): - fw_version = hex(fw_info.fw_info_list[i].fw_version) - fw_version_string = ".".join(re.findall('..?', fw_version[2:])) + fw_name = AmdSmiFwBlock(fw_info.fw_info_list[i].fw_id) + fw_version = fw_info.fw_info_list[i].fw_version + + if fw_name in hex_format_fw: + fw_version_string = ".".join(re.findall('..?', hex(fw_version)[2:])) + else: + fw_version_string = str(fw_version) + firmwares.append({ - 'fw_name': AmdSmiFwBlock(fw_info.fw_info_list[i].fw_id), + 'fw_name': fw_name, 'fw_version': fw_version_string.upper(), }) return { From 7dc9618e77ea69ab4f28658d97b7c07f6adac7fe Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 2 Nov 2023 04:30:01 -0500 Subject: [PATCH 28/33] SWDEV-403153 - Fixed eeprom hex casting Signed-off-by: Maisam Arif Change-Id: I46531bd9ae60947539d4b95e5b21c7008ec0b3ea [ROCm/amdsmi commit: 8b0b0490d1823ed52a35ba19b334c96555830e96] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 4 ++-- projects/amdsmi/py-interface/amdsmi_interface.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index 3a8432e2cd..cd88dfbd28 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -496,7 +496,7 @@ class AMDSMICommands(): ras_info = amdsmi_interface.amdsmi_get_gpu_ras_feature_info(args.gpu) for key, value in ras_info.items(): if isinstance(value, int): - if value >= 65535: + if value == 65535 or value == 0: logging.debug(f"Failed to get ras {key} for gpu {gpu_id}") ras_info[key] = "N/A" continue @@ -953,7 +953,7 @@ class AMDSMICommands(): engine_usage['mm_ip_usage'] = engine_usage.pop('mm_activity') for key, value in engine_usage.items(): - if value >= 65535: + if value == 65535: engine_usage[key] = "N/A" if self.logger.is_human_readable_format(): diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index e7adccfb29..ea1bf675a5 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -1180,7 +1180,7 @@ def amdsmi_get_gpu_ras_feature_info( ) return { - "eeprom_version": ras_feature.ras_eeprom_version, + "eeprom_version": hex(ras_feature.ras_eeprom_version), "parity_schema" : bool(ras_feature.ecc_correction_schema_flag & 1), "single_bit_schema" : bool(ras_feature.ecc_correction_schema_flag & 2), "double_bit_schema" : bool(ras_feature.ecc_correction_schema_flag & 4), From 5b6d22b24eadf41106707f84def5f7720f37ce21 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Wed, 25 Oct 2023 17:03:47 -0500 Subject: [PATCH 29/33] SWDEV-425457 - Updated Sphinx docs to include ESMI Signed-off-by: Maisam Arif Change-Id: Ie7669c9f94703e5c5cdc65314cbf30e8b587d0f1 [ROCm/amdsmi commit: f061aa4be5774b65dde3d00ff9498a27e3463ab1] --- projects/amdsmi/docs/.gitignore | 3 +++ projects/amdsmi/docs/conf.py | 12 ++++++++++++ projects/amdsmi/docs/esmi_lib_readme_link.md | 3 +++ projects/amdsmi/docs/sphinx/_toc.yml.in | 4 ++++ projects/amdsmi/docs/sphinx/requirements.txt | 4 ++-- 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 projects/amdsmi/docs/esmi_lib_readme_link.md diff --git a/projects/amdsmi/docs/.gitignore b/projects/amdsmi/docs/.gitignore index b84233aed8..9095d45c48 100644 --- a/projects/amdsmi/docs/.gitignore +++ b/projects/amdsmi/docs/.gitignore @@ -9,3 +9,6 @@ /latex/ 404.md data/AMD-404.png + +# file below is overwritten by sphinx script! +./esmi_lib_readme_link.md diff --git a/projects/amdsmi/docs/conf.py b/projects/amdsmi/docs/conf.py index bdfc6e486f..6bc3e3f5b6 100644 --- a/projects/amdsmi/docs/conf.py +++ b/projects/amdsmi/docs/conf.py @@ -6,8 +6,20 @@ import subprocess +import urllib from rocm_docs import ROCmDocs +esmi_readme_link = "https://raw.githubusercontent.com/amd/esmi_ib_library/master/docs/README.md" +try: + # Try to override esmi_lib_readme_link.md with the github esmi readme contents + with urllib.request.urlopen(esmi_readme_link) as f: + esmi_readme = f.read().decode('utf-8') + + with open("./esmi_lib_readme_link.md", "w", encoding='utf-8') as f: + f.write(esmi_readme) +except urllib.error.URLError: + # don't care about the error because there is backup link in the file already + pass get_version_year = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_YEAR\ //p" ../include/amd_smi/amdsmi.h' get_version_major = r'sed -n -e "s/^#define\ AMDSMI_LIB_VERSION_MAJOR\ //p" ../include/amd_smi/amdsmi.h' diff --git a/projects/amdsmi/docs/esmi_lib_readme_link.md b/projects/amdsmi/docs/esmi_lib_readme_link.md new file mode 100644 index 0000000000..f52aec131a --- /dev/null +++ b/projects/amdsmi/docs/esmi_lib_readme_link.md @@ -0,0 +1,3 @@ +# ESMI Library README + +For more information, see the [ESMI Library README](https://raw.githubusercontent.com/am/esmi_ib_library/master/docs/README.md) \ No newline at end of file diff --git a/projects/amdsmi/docs/sphinx/_toc.yml.in b/projects/amdsmi/docs/sphinx/_toc.yml.in index 3a4de74232..c05c3bfbf0 100644 --- a/projects/amdsmi/docs/sphinx/_toc.yml.in +++ b/projects/amdsmi/docs/sphinx/_toc.yml.in @@ -17,6 +17,10 @@ subtrees: title: Python CLI Tool - file: amdsmi_release_notes_link title: Python CLI Release Notes + - caption: Libraries + entries: + - file: esmi_lib_readme_link + title: ESMI Library - caption: About entries: - file: license diff --git a/projects/amdsmi/docs/sphinx/requirements.txt b/projects/amdsmi/docs/sphinx/requirements.txt index ca744335cb..53bd7f615d 100644 --- a/projects/amdsmi/docs/sphinx/requirements.txt +++ b/projects/amdsmi/docs/sphinx/requirements.txt @@ -47,7 +47,7 @@ fastjsonschema==2.17.1 # via rocm-docs-core gitdb==4.0.10 # via gitpython -gitpython==3.1.31 +gitpython==3.1.37 # via rocm-docs-core idna==3.4 # via requests @@ -110,7 +110,7 @@ requests==2.30.0 # via # pygithub # sphinx -rocm-docs-core[api_reference]>=0.20.0 +rocm-docs-core[api_reference]>=0.26.0 # via -r requirements.in smmap==5.0.0 # via gitdb From 9b3d9f61b3d3fe99d105b87960b398e90ade7ad7 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 2 Nov 2023 18:17:42 -0500 Subject: [PATCH 30/33] CMake - Bump version Change-Id: Idc3c07b5f37309d03b46df7a6400793bc8953f61 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: 1010787865a6d3c92519ea2d0e23c483904b4ffc] --- projects/amdsmi/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index 3c837763bf..47c67e1b45 100755 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -28,7 +28,7 @@ find_program(GIT NAMES git) ## Setup the package version based on git tags. set(PKG_VERSION_GIT_TAG_PREFIX "amdsmi_pkg_ver") -get_package_version_number("23.4.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) +get_package_version_number("23.4.2" ${PKG_VERSION_GIT_TAG_PREFIX} GIT) message("Package version: ${PKG_VERSION_STR}") set(${AMD_SMI_LIBS_TARGET}_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}") set(${AMD_SMI_LIBS_TARGET}_VERSION_MINOR "${CPACK_PACKAGE_VERSION_MINOR}") From 1128c1f24646f5bf01f838293d80a54891cee23f Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 2 Nov 2023 17:56:10 -0500 Subject: [PATCH 31/33] DOCS - Fix 'failed to reach any of the inventories' Change-Id: I7edd1fad17bd0f3e0946a6712410cf6549afc729 Signed-off-by: Galantsev, Dmitrii [ROCm/amdsmi commit: fc02ebc5f2dcdec1383d1e6efd92a70bf6deb734] --- projects/amdsmi/docs/conf.py | 3 +++ projects/amdsmi/py-interface/README.md | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/projects/amdsmi/docs/conf.py b/projects/amdsmi/docs/conf.py index 6bc3e3f5b6..4e4806d16c 100644 --- a/projects/amdsmi/docs/conf.py +++ b/projects/amdsmi/docs/conf.py @@ -37,6 +37,9 @@ 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() +docs_core.html_theme_options = { + "repository_url": "https://github.com/RadeonOpenCompute/amdsmi" +} for sphinx_var in ROCmDocs.SPHINX_VARS: globals()[sphinx_var] = getattr(docs_core, sphinx_var) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index 8ef3ff222d..fee3a48770 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -1784,19 +1784,23 @@ except AmdSmiException as e: ``` ## amdsmi_is_gpu_power_management_enabled + Description: Returns is power management enabled Input parameters: + * `processor_handle` GPU device which to query Output: Bool true if power management enabled else false Exceptions that can be thrown by `amdsmi_is_gpu_power_management_enabled` function: + * `AmdSmiLibraryException` * `AmdSmiRetryException` * `AmdSmiParameterException` Example: + ```python try: devices = amdsmi_get_processor_handles() @@ -3281,7 +3285,6 @@ except AmdSmiException as e: print(e) ``` - ### amdsmi_dev_compute_partition_get Description: Get the compute partition from the given GPU @@ -3560,7 +3563,6 @@ except AmdSmiException as e: print(e) ``` - ### amdsmi_get_cpucore_handles Description: Returns list of CPU core handle objects on current machine From 11b1e5fb42cebb244f82259e547dafcce1283b29 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Thu, 2 Nov 2023 20:54:03 -0500 Subject: [PATCH 32/33] Handle GPU Not detected Signed-off-by: Maisam Arif Change-Id: I988b0dddde23b83c1a8e402233b6aa08ce55d0c7 [ROCm/amdsmi commit: 9bfebc6f1cf3cc0faecbbd769330e3655076b46e] --- projects/amdsmi/amdsmi_cli/amdsmi_commands.py | 5 +++++ projects/amdsmi/amdsmi_cli/amdsmi_helpers.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index cd88dfbd28..6c8e95398e 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -50,6 +50,11 @@ class AMDSMICommands(): sys.exit(-1) else: raise e + + if len(self.device_handles) == 0: + logging.error('Unable to detect any devices, check if driver is initialized (amdgpu not found in modules)') + sys.exit(-1) + self.stop = '' diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py index cb5f7cf1bb..9e08bfbc70 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_helpers.py @@ -154,6 +154,10 @@ class AMDSMIHelpers(): else: raise e + if len(device_handles) == 0: + logging.error('Unable to find any devices, check if driver is initialized (amdgpu not found in modules)') + sys.exit(-1) + # Handle spacing for the gpu_choices_str max_padding = int(math.log10(len(device_handles))) + 1 From 5845c75e513431ca4f6322e2626b2ad888b0615e Mon Sep 17 00:00:00 2001 From: Deepak Mewar Date: Thu, 2 Nov 2023 07:23:31 -0400 Subject: [PATCH 33/33] Updated esmi python wrappers to amdsmi python library Change-Id: Icf2576926d3649929d2aa580b476a013204daf95 [ROCm/amdsmi commit: 6d46e2059856b742d2cdf897454e65ba4ab0fa21] --- projects/amdsmi/py-interface/README.md | 123 ++++++++++++++++++ .../amdsmi/py-interface/amdsmi_interface.py | 95 ++++++++++++++ 2 files changed, 218 insertions(+) diff --git a/projects/amdsmi/py-interface/README.md b/projects/amdsmi/py-interface/README.md index fee3a48770..6343bb1775 100644 --- a/projects/amdsmi/py-interface/README.md +++ b/projects/amdsmi/py-interface/README.md @@ -3821,3 +3821,126 @@ try: except AmdSmiException as e: print(e) ``` + +### amdsmi_get_cpu_socket_power_cap + +Description: Get the socket power cap. + +Output: amdsmi socket power cap + +Exceptions that can be thrown by `amdsmi_get_cpu_socket_power_cap` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + sock_power = amdsmi_get_cpu_socket_power_cap(socket) + print(sock_power) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_socket_power_cap_max + +Description: Get the socket power cap max. + +Output: amdsmi socket power cap max + +Exceptions that can be thrown by `amdsmi_get_cpu_socket_power_cap_max` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + sock_power = amdsmi_get_cpu_socket_power_cap_max(socket) + print(sock_power) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_get_cpu_pwr_svi_telemetry_all_rails + +Description: Get the SVI based power telemetry for all rails. + +Output: amdsmi svi based power value + +Exceptions that can be thrown by `amdsmi_get_cpu_pwr_svi_telemetry_all_rails` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + power = amdsmi_get_cpu_pwr_svi_telemetry_all_rails(socket) + print(power) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_set_cpu_socket_power_cap + +Description: Set the power cap value for a given socket. + +Input: socket index, amdsmi socket power cap value + +Exceptions that can be thrown by `amdsmi_set_cpu_socket_power_cap` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + power = amdsmi_set_cpu_socket_power_cap(socket, 0, 1000) +except AmdSmiException as e: + print(e) +``` + +### amdsmi_set_cpu_pwr_efficiency_mode + +Description: Set the power efficiency profile policy. + +Input: socket index, mode(0, 1, or 2) + +Exceptions that can be thrown by `amdsmi_set_cpu_pwr_efficiency_mode` function: + +* `AmdSmiLibraryException` + +Example: + +```python +try: + socket_handles = amdsmi_get_cpusocket_handles() + if len(socket_handles) == 0: + print("No CPU sockets on machine") + else: + for socket in socket_handles: + policy = amdsmi_set_cpu_pwr_efficiency_mode(socket, 0, 0) +except AmdSmiException as e: + print(e) +``` diff --git a/projects/amdsmi/py-interface/amdsmi_interface.py b/projects/amdsmi/py-interface/amdsmi_interface.py index ea1bf675a5..d1069be1ab 100644 --- a/projects/amdsmi/py-interface/amdsmi_interface.py +++ b/projects/amdsmi/py-interface/amdsmi_interface.py @@ -876,6 +876,101 @@ def amdsmi_get_cpu_socket_power( return ppower.value +def amdsmi_get_cpu_socket_power_cap( + socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int +) -> int: + if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle): + raise AmdSmiParameterException( + socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle + ) + if not isinstance(sock_idx, int): + raise AmdSmiParameterException(sock_idx, int) + + pcap = ctypes.c_uint32() + _check_res( + amdsmi_wrapper.amdsmi_get_cpu_socket_power_cap( + socket_handle, sock_idx, ctypes.byref(pcap) + ) + ) + + return pcap.value + +def amdsmi_get_cpu_socket_power_cap_max( + socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int +) -> int: + if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle): + raise AmdSmiParameterException( + socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle + ) + if not isinstance(sock_idx, int): + raise AmdSmiParameterException(sock_idx, int) + + pmax = ctypes.c_uint32() + _check_res( + amdsmi_wrapper.amdsmi_get_cpu_socket_power_cap_max( + socket_handle, sock_idx, ctypes.byref(pmax) + ) + ) + + return pmax.value + +def amdsmi_get_cpu_pwr_svi_telemetry_all_rails( + socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int +) -> int: + if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle): + raise AmdSmiParameterException( + socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle + ) + if not isinstance(sock_idx, int): + raise AmdSmiParameterException(sock_idx, int) + + power = ctypes.c_uint32() + _check_res( + amdsmi_wrapper.amdsmi_get_cpu_pwr_svi_telemetry_all_rails( + socket_handle, sock_idx, ctypes.byref(power) + ) + ) + + return power.value + +def amdsmi_set_cpu_socket_power_cap( + socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int, power_cap: int +): + if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle): + raise AmdSmiParameterException( + socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle + ) + if not isinstance(sock_idx, int): + raise AmdSmiParameterException(sock_idx, int) + if not isinstance(power_cap, int): + raise AmdSmiParameterException(power_cap, int) + sock_idx = ctypes.c_uint32(sock_idx) + power_cap = ctypes.c_uint32(power_cap) + + _check_res( + amdsmi_wrapper.amdsmi_set_cpu_socket_power_cap( + processor_handle, sock_idx, power_cap) + ) + +def amdsmi_set_cpu_pwr_efficiency_mode( + socket_handle: amdsmi_wrapper.amdsmi_cpusocket_handle, sock_idx: int, mode: int +): + if not isinstance(socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle): + raise AmdSmiParameterException( + socket_handle, amdsmi_wrapper.amdsmi_cpusocket_handle + ) + if not isinstance(sock_idx, int): + raise AmdSmiParameterException(sock_idx, int) + if not isinstance(mode, int): + raise AmdSmiParameterException(mode, int) + sock_idx = ctypes.c_uint8(sock_idx) + mode = ctypes.c_uint8(mode) + + _check_res( + amdsmi_wrapper.amdsmi_set_cpu_pwr_efficiency_mode( + socket_handle, sock_idx, mode) + ) + def amdsmi_init(flag=AmdSmiInitFlags.INIT_AMD_GPUS): if not isinstance(flag, AmdSmiInitFlags): raise AmdSmiParameterException(flag, AmdSmiInitFlags)