Merge amd-staging into amd-master 20230921
Signed-off-by: Hao Zhou <Hao.Zhou@amd.com> Change-Id: I08c5ae1cca4b03dbb3cfcbcbf61d4b1b633908c1
This commit is contained in:
+4
-1
@@ -17,4 +17,7 @@ build/
|
||||
.cache/
|
||||
|
||||
# Simulated SYSFS - for early development or debug
|
||||
device/
|
||||
device/
|
||||
|
||||
# Misc
|
||||
__pycache__
|
||||
|
||||
+35
-46
@@ -1,21 +1,18 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
do_addLogFolder() {
|
||||
sudo mkdir -p "${logPath}"
|
||||
sudo touch "${logFile}"
|
||||
sudo chmod -R a+rw "${logPath}"
|
||||
sudo chmod a+rw "${logFile}"
|
||||
}
|
||||
|
||||
do_configureLogrotate() {
|
||||
logrotate --version &>/dev/null
|
||||
local IS_SYSTEMD=0
|
||||
local packageName="rocm-smi-lib"
|
||||
local logPath=/var/log/rocm_smi_lib
|
||||
local logFile="${logPath}/ROCm-SMI-lib.log"
|
||||
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
mkdir -p "${logPath}"
|
||||
touch "${logFile}"
|
||||
chmod -R a+rw "${logPath}"
|
||||
chmod a+rw "${logFile}"
|
||||
|
||||
command -v logrotate &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Detected logrotate is not installed."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
@@ -23,14 +20,14 @@ do_configureLogrotate() {
|
||||
fi
|
||||
|
||||
if [ ! -f $logrotateConfFile ]; then
|
||||
sudo touch "${logrotateConfFile}"
|
||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
touch "${logrotateConfFile}"
|
||||
chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
# ROCm SMI logging rotation, rotates files using root user/group
|
||||
# Hourly logrotation check
|
||||
# Only rotates if size grew larger than 1MB
|
||||
# Max of 4 rotation files, oldest will be removed
|
||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
||||
cat << EOF > "${logrotateConfFile}"
|
||||
${logFile} {
|
||||
su root root
|
||||
hourly
|
||||
@@ -47,43 +44,29 @@ EOF
|
||||
# issue was RPM build thought we were using macros
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
# workaround: remove extra 'OURCE' text
|
||||
# from rocm_smi.conf. Unsure if CMAKE,
|
||||
# bash, or here document
|
||||
# issue (only seen on RHEL 8.7)
|
||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
fi
|
||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
||||
sudo systemctl list-timers|grep -iq logrotate
|
||||
if [ $? -ne 0 ]; then
|
||||
# confirm logrotate file exists in daily
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
# move logrotate daily to hourly
|
||||
if [ -d /etc/cron.hourly ]; then
|
||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
else
|
||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
else
|
||||
# confirm that it's already been moved to hourly
|
||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) may not rotate properly."
|
||||
fi
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl list-timers | grep -iq logrotate
|
||||
if [ $? -eq 0 ]; then
|
||||
IS_SYSTEMD=1
|
||||
fi
|
||||
return #done configuring for non-systemd timers
|
||||
else
|
||||
fi
|
||||
if [ "$IS_SYSTEMD" -eq 1 ]; then
|
||||
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
||||
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
||||
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||
sudo cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||
cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||
fi
|
||||
cat <<'EOF' | sudo tee /lib/systemd/system/logrotate.timer >/dev/null
|
||||
cat << EOF > /lib/systemd/system/logrotate.timer
|
||||
[Unit]
|
||||
Description=Hourly rotation of log files
|
||||
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
||||
@@ -97,12 +80,19 @@ Persistent=true
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOF
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
systemctl reenable --now logrotate.timer
|
||||
else
|
||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
return #done configuring for systemd timers
|
||||
else
|
||||
# $IS_SYSTEMD -eq 0
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
# move logrotate daily to hourly
|
||||
if [ -d /etc/cron.hourly ]; then
|
||||
mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -117,8 +107,7 @@ do_ldconfig() {
|
||||
case "$1" in
|
||||
( configure )
|
||||
do_ldconfig
|
||||
do_addLogFolder
|
||||
do_configureLogrotate
|
||||
do_configureLogrotate || return 0
|
||||
;;
|
||||
( abort-upgrade | abort-remove | abort-deconfigure )
|
||||
echo "$1"
|
||||
|
||||
+21
-27
@@ -1,29 +1,4 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
rm_logFolder() {
|
||||
sudo rm -rf "$logPath"
|
||||
}
|
||||
|
||||
return_logrotateToOrigConfig() {
|
||||
if [ -f $logrotateConfFile ]; then
|
||||
sudo rm -rf "${logrotateConfFile}"
|
||||
fi
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
fi
|
||||
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||
sudo cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||
sudo rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
fi
|
||||
}
|
||||
|
||||
rm_ldconfig() {
|
||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||
@@ -34,8 +9,27 @@ rm_ldconfig() {
|
||||
}
|
||||
|
||||
rm_pyc() {
|
||||
# remove pyc file generated by python
|
||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||
# remove pyc file generated by python
|
||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||
}
|
||||
|
||||
rm_logFolder() {
|
||||
rm -rf /var/log/rocm_smi_lib
|
||||
}
|
||||
|
||||
return_logrotateToOrigConfig() {
|
||||
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
if [ -f $logrotateConfFile ]; then
|
||||
rm -rf "$logrotateConfFile"
|
||||
fi
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
fi
|
||||
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||
cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||
rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||
systemctl reenable --now logrotate.timer
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +1,65 @@
|
||||
|
||||
|
||||
# ROCm System Management Interface (ROCm SMI) Library
|
||||
|
||||
The ROCm System Management Interface Library, or ROCm SMI library, is part of the Radeon Open Compute [ROCm](https://github.com/RadeonOpenCompute) software stack . It is a C library for Linux that provides a user space interface for applications to monitor and control GPU applications.
|
||||
|
||||
For additional information refer to [ROCm Documentation](https://rocm.docs.amd.com/projects/rocm_smi_lib/en/latest/)
|
||||
|
||||
## DISCLAIMER
|
||||
|
||||
The information contained herein is for informational purposes only, and is subject to change without notice. In addition, any stated support is planned and is also subject to change. 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.
|
||||
|
||||
© 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.
|
||||
|
||||
## Building ROCm SMI
|
||||
|
||||
# Building ROCm SMI
|
||||
### Additional Required software for building
|
||||
|
||||
#### Additional Required software for building
|
||||
In order to build the ROCm 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:
|
||||
|
||||
* CMake (v3.5.0)
|
||||
* g++ (5.4.0)
|
||||
|
||||
In order to build the latest documentation, the following are required:
|
||||
|
||||
* Python 3.8+
|
||||
* NPM (sass)
|
||||
|
||||
The source code for ROCm SMI is available on [Github](https://github.com/RadeonOpenCompute/rocm_smi_lib).
|
||||
|
||||
After the ROCm SMI library git repository has been cloned to a local Linux machine, building the library is achieved by following the typical CMake build sequence. Specifically,
|
||||
|
||||
```shell
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j $(nproc)
|
||||
# Install library file and header; default location is /opt/rocm
|
||||
$ make install
|
||||
make install
|
||||
```
|
||||
|
||||
The built library will appear in the `build` folder.
|
||||
|
||||
To build the rpm and deb packages follow the above steps with:
|
||||
|
||||
```shell
|
||||
make package
|
||||
```
|
||||
|
||||
#### Documentation
|
||||
|
||||
The following is an example of how to build the docs:
|
||||
|
||||
```shell
|
||||
sudo apt install -y npm
|
||||
sudo npm install -g sass
|
||||
|
||||
python3 -m venv .venv
|
||||
|
||||
.venv/bin/python3 -m pip install -r docs/.sphinx/requirements.txt
|
||||
.venv/bin/python3 -m sphinx -T -E -b html -d docs/_build/doctrees -D language=en docs docs/_build/html
|
||||
```
|
||||
|
||||
#### Building the Tests
|
||||
|
||||
In order to verify the build and capability of ROCm SMI on your system and to see an example of how ROCm SMI can be used, you may build and run the tests that are available in the repo. To build the tests, follow these steps:
|
||||
|
||||
```shell
|
||||
# Set environment variables used in CMakeLists.txt file
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_TESTS=ON ..
|
||||
@@ -65,11 +68,14 @@ make -j $(nproc)
|
||||
|
||||
To run the test, execute the program `rsmitst` that is built from the steps above.
|
||||
|
||||
# Usage Basics
|
||||
## Device Indices
|
||||
## Usage Basics
|
||||
|
||||
### Device Indices
|
||||
|
||||
Many of the functions in the library take a "device index". The device index is a number greater than or equal to 0, and less than the number of devices detected, as determined by `rsmi_num_monitor_devices()`. The index is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different index after a reboot, so an index should not be relied upon to be constant over reboots.
|
||||
|
||||
# Hello ROCm SMI
|
||||
## Hello ROCm SMI
|
||||
|
||||
The only required ROCm-SMI call for any program that wants to use ROCm-SMI is the `rsmi_init()` call. This call initializes some internal data structures that will be used by subsequent ROCm-SMI calls.
|
||||
|
||||
When ROCm-SMI is no longer being used, `rsmi_shut_down()` should be called. This provides a way to do any releasing of resources that ROCm-SMI may have held. In many cases, this may have no effect, but may be necessary in future versions of the library.
|
||||
|
||||
+38
-54
@@ -1,21 +1,18 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
do_addLogFolder() {
|
||||
sudo mkdir -p "${logPath}"
|
||||
sudo touch "${logFile}"
|
||||
sudo chmod -R a+rw "${logPath}"
|
||||
sudo chmod a+rw "${logFile}"
|
||||
}
|
||||
|
||||
do_configureLogrotate() {
|
||||
logrotate --version &>/dev/null
|
||||
local IS_SYSTEMD=0
|
||||
local packageName="rocm-smi-lib"
|
||||
local logPath=/var/log/rocm_smi_lib
|
||||
local logFile="${logPath}/ROCm-SMI-lib.log"
|
||||
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
|
||||
mkdir -p "${logPath}"
|
||||
touch "${logFile}"
|
||||
chmod -R a+rw "${logPath}"
|
||||
chmod a+rw "${logFile}"
|
||||
|
||||
command -v logrotate &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Detected logrotate is not installed."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
@@ -23,14 +20,14 @@ do_configureLogrotate() {
|
||||
fi
|
||||
|
||||
if [ ! -f $logrotateConfFile ]; then
|
||||
sudo touch "${logrotateConfFile}"
|
||||
sudo chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
touch "${logrotateConfFile}"
|
||||
chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
||||
# ROCm SMI logging rotation, rotates files using root user/group
|
||||
# Hourly logrotation check
|
||||
# Only rotates if size grew larger than 1MB
|
||||
# Max of 4 rotation files, oldest will be removed
|
||||
# Rotated files use date extention of ex. ROCm-SMI-lib.log.2023-05-09_16:51:42
|
||||
cat << EOF | sudo tee "${logrotateConfFile}" >/dev/null
|
||||
cat << EOF > "${logrotateConfFile}"
|
||||
${logFile} {
|
||||
su root root
|
||||
hourly
|
||||
@@ -47,43 +44,29 @@ EOF
|
||||
# issue was RPM build thought we were using macros
|
||||
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
||||
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
||||
sudo sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
sed -i s/%%/%/g "${logrotateConfFile}"
|
||||
# workaround: remove extra 'OURCE' text
|
||||
# from rocm_smi.conf. Unsure if CMAKE,
|
||||
# bash, or here document
|
||||
# issue (only seen on RHEL 8.7)
|
||||
sudo sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
sed -i s/OURCE//g "${logrotateConfFile}"
|
||||
fi
|
||||
# check if logrotate uses system timers, Ubuntu/modern OS's do
|
||||
# Several older OS's like RHEL 8.7, do not. Instead defaults
|
||||
# to use daily cron jobs - see https://stackoverflow.com/a/69465677
|
||||
sudo systemctl list-timers|grep -iq logrotate
|
||||
if [ $? -ne 0 ]; then
|
||||
# confirm logrotate file exists in daily
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
# move logrotate daily to hourly
|
||||
if [ -d /etc/cron.hourly ]; then
|
||||
sudo mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
else
|
||||
echo "[WARNING] Could find and configure hourly cron for $packageName's"\
|
||||
" logrotate. $packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
else
|
||||
# confirm that it's already been moved to hourly
|
||||
sudo find /etc/cron.* -iname logrotate -print -quit |grep -iq hourly
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "[WARNING] Could not configure an hourly cron for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) may not rotate properly."
|
||||
fi
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl list-timers | grep -iq logrotate
|
||||
if [ $? -eq 0 ]; then
|
||||
IS_SYSTEMD=1
|
||||
fi
|
||||
return #done configuring for non-systemd timers
|
||||
else
|
||||
fi
|
||||
if [ "$IS_SYSTEMD" -eq 1 ]; then
|
||||
# Configure systemd timers - the typical setup for modern Linux logrotation setups
|
||||
if [ -f /lib/systemd/system/logrotate.timer ]; then
|
||||
if [ ! -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||
sudo cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||
cp /lib/systemd/system/logrotate.timer /lib/systemd/system/logrotate.timer.backup
|
||||
fi
|
||||
cat <<'EOF' | sudo tee /lib/systemd/system/logrotate.timer >/dev/null
|
||||
cat << EOF > /lib/systemd/system/logrotate.timer
|
||||
[Unit]
|
||||
Description=Hourly rotation of log files
|
||||
Documentation=man:logrotate(8) man:logrotate.conf(5)
|
||||
@@ -97,12 +80,19 @@ Persistent=true
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
EOF
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
systemctl reenable --now logrotate.timer
|
||||
else
|
||||
echo "[WARNING] Could not configure systemd timer for $packageName's logrotate."\
|
||||
"$packageName logs (when turned on) will not rotate properly."
|
||||
fi
|
||||
return #done configuring for systemd timers
|
||||
else
|
||||
# $IS_SYSTEMD -eq 0
|
||||
if [ -f /etc/cron.daily/logrotate ]; then
|
||||
# move logrotate daily to hourly
|
||||
if [ -d /etc/cron.hourly ]; then
|
||||
mv /etc/cron.daily/logrotate /etc/cron.hourly/logrotate
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -114,14 +104,8 @@ do_ldconfig() {
|
||||
fi
|
||||
}
|
||||
|
||||
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||
echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
||||
ldconfig
|
||||
fi
|
||||
|
||||
# post install or upgrade, $i is 1 or 2 -> do these actions
|
||||
if [ $1 -ge 1 ]; then
|
||||
do_addLogFolder
|
||||
do_configureLogrotate
|
||||
fi
|
||||
if [ "$1" -ge 1 ]; then
|
||||
do_ldconfig
|
||||
do_configureLogrotate || return 0
|
||||
fi
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# second term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
||||
if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||
if [ "$1" -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
||||
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
||||
rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf
|
||||
ldconfig
|
||||
|
||||
+13
-15
@@ -1,34 +1,32 @@
|
||||
#!/bin/bash
|
||||
#set -x
|
||||
|
||||
packageName="rocm-smi-lib"
|
||||
logPath=/var/log/rocm_smi_lib
|
||||
logName=ROCm-SMI-lib.log
|
||||
logFile="${logPath}/${logName}"
|
||||
logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
rm_pyc() {
|
||||
# remove pyc file generated by python
|
||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||
}
|
||||
|
||||
rm_logFolder() {
|
||||
sudo rm -rf "$logPath"
|
||||
rm -rf /var/log/rocm_smi_lib
|
||||
}
|
||||
|
||||
return_logrotateToOrigConfig() {
|
||||
local logrotateConfFile=/etc/logrotate.d/rocm_smi.conf
|
||||
if [ -f $logrotateConfFile ]; then
|
||||
sudo rm -rf "${logrotateConfFile}"
|
||||
rm -rf "$logrotateConfFile"
|
||||
fi
|
||||
if [ -f /etc/cron.hourly/logrotate ]; then
|
||||
sudo mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
||||
fi
|
||||
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
||||
sudo cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||
sudo rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||
sudo systemctl reenable --now logrotate.timer
|
||||
cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
||||
rm -rf /lib/systemd/system/logrotate.timer.backup
|
||||
systemctl reenable --now logrotate.timer
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $1 -le 1 ]; then
|
||||
if [ "$1" -le 1 ]; then
|
||||
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
||||
# remove pyc file generated by python
|
||||
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__
|
||||
rm_pyc
|
||||
rm_logFolder
|
||||
return_logrotateToOrigConfig
|
||||
fi
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
docBin/
|
||||
@@ -7,3 +7,5 @@
|
||||
/_templates/
|
||||
/html/
|
||||
/latex/
|
||||
404.md
|
||||
data/AMD-404.png
|
||||
|
||||
@@ -2,5 +2,6 @@ defaults:
|
||||
numbered: False
|
||||
maxdepth: 6
|
||||
root: index
|
||||
entries:
|
||||
- file: html/index
|
||||
subtrees:
|
||||
- entries:
|
||||
- file: .doxygen/docBin/html/index
|
||||
|
||||
@@ -4,5 +4,6 @@ defaults:
|
||||
numbered: False
|
||||
maxdepth: 6
|
||||
root: index
|
||||
entries:
|
||||
- file: html/index
|
||||
subtrees:
|
||||
- entries:
|
||||
- file: .doxygen/docBin/html/index
|
||||
|
||||
@@ -1 +1 @@
|
||||
rocm-docs-core[api_reference]==0.9.0
|
||||
rocm-docs-core[api_reference]==0.24.1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# This file is autogenerated by pip-compile with Python 3.8
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile .sphinx/requirements.in
|
||||
# pip-compile requirements.in
|
||||
#
|
||||
accessible-pygments==0.0.4
|
||||
# via pydata-sphinx-theme
|
||||
@@ -41,7 +41,9 @@ docutils==0.16
|
||||
# myst-parser
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
doxysphinx==3.2.3
|
||||
doxysphinx==3.3.4
|
||||
# via rocm-docs-core
|
||||
fastjsonschema==2.18.0
|
||||
# via rocm-docs-core
|
||||
gitdb==4.0.10
|
||||
# via gitpython
|
||||
@@ -59,10 +61,8 @@ jinja2==3.1.2
|
||||
# via
|
||||
# myst-parser
|
||||
# sphinx
|
||||
json5==0.9.11
|
||||
libsass==0.22.0
|
||||
# via doxysphinx
|
||||
linkify-it-py==1.0.3
|
||||
# via myst-parser
|
||||
lxml==4.9.2
|
||||
# via doxysphinx
|
||||
markdown-it-py==2.2.0
|
||||
@@ -75,7 +75,9 @@ mdit-py-plugins==0.3.5
|
||||
# via myst-parser
|
||||
mdurl==0.1.2
|
||||
# via markdown-it-py
|
||||
myst-parser[linkify]==1.0.0
|
||||
mpire==2.8.0
|
||||
# via doxysphinx
|
||||
myst-parser==1.0.0
|
||||
# via rocm-docs-core
|
||||
packaging==23.1
|
||||
# via
|
||||
@@ -92,8 +94,11 @@ pygithub==1.58.1
|
||||
pygments==2.15.0
|
||||
# via
|
||||
# accessible-pygments
|
||||
# mpire
|
||||
# pydata-sphinx-theme
|
||||
# sphinx
|
||||
pyjson5==1.6.4
|
||||
# via doxysphinx
|
||||
pyjwt[crypto]==2.6.0
|
||||
# via pygithub
|
||||
pynacl==1.5.0
|
||||
@@ -105,13 +110,14 @@ pytz==2023.3
|
||||
pyyaml==6.0
|
||||
# via
|
||||
# myst-parser
|
||||
# rocm-docs-core
|
||||
# sphinx-external-toc
|
||||
requests==2.28.2
|
||||
# via
|
||||
# pygithub
|
||||
# sphinx
|
||||
rocm-docs-core[api_reference]==0.9.0
|
||||
# via -r .sphinx/requirements.in
|
||||
rocm-docs-core[api_reference]==0.24.1
|
||||
# via -r requirements.in
|
||||
smmap==5.0.0
|
||||
# via gitdb
|
||||
snowballstemmer==2.2.0
|
||||
@@ -151,10 +157,10 @@ sphinxcontrib-qthelp==1.0.3
|
||||
# via sphinx
|
||||
sphinxcontrib-serializinghtml==1.1.5
|
||||
# via sphinx
|
||||
tqdm==4.66.1
|
||||
# via mpire
|
||||
typing-extensions==4.5.0
|
||||
# via pydata-sphinx-theme
|
||||
uc-micro-py==1.0.1
|
||||
# via linkify-it-py
|
||||
urllib3==1.26.15
|
||||
# via requests
|
||||
wrapt==1.15.0
|
||||
|
||||
@@ -13,5 +13,3 @@ docs_core.setup()
|
||||
|
||||
for sphinx_var in ROCmDocs.SPHINX_VARS:
|
||||
globals()[sphinx_var] = getattr(docs_core, sphinx_var)
|
||||
|
||||
html_theme_options["show_navbar_depth"] = 2
|
||||
|
||||
@@ -638,10 +638,21 @@ def printLog(device, metricName, value=None, extraSpace=False, useItalics=False)
|
||||
lock.acquire()
|
||||
if useItalics:
|
||||
logstr = italics + logstr + end
|
||||
if extraSpace:
|
||||
print('\n' + logstr + '\n', end='', flush=True)
|
||||
else:
|
||||
print(logstr + '\n', end='', flush=True)
|
||||
try:
|
||||
if extraSpace:
|
||||
print('\n', end='')
|
||||
print(logstr + '\n', end='')
|
||||
sys.stdout.flush()
|
||||
# when piped into programs like 'head' - print throws an error.
|
||||
# silently ignore instead
|
||||
except(BrokenPipeError, IOError):
|
||||
# https://docs.python.org/3/library/signal.html#note-on-sigpipe
|
||||
# Python flushes standard streams on exit; redirect remaining output
|
||||
# to devnull to avoid another BrokenPipeError at shutdown
|
||||
devnull = os.open(os.devnull, os.O_WRONLY)
|
||||
os.dup2(devnull, sys.stdout.fileno())
|
||||
sys.exit(1) # Python exits with error code 1 on EPIPE
|
||||
|
||||
lock.release()
|
||||
|
||||
|
||||
@@ -832,8 +843,10 @@ def resetFans(deviceList):
|
||||
for device in deviceList:
|
||||
sensor_ind = c_uint32(0)
|
||||
ret = rocmsmi.rsmi_dev_fan_reset(device, sensor_ind)
|
||||
if rsmi_ret_ok(ret, device, 'reset_fan'):
|
||||
if rsmi_ret_ok(ret, device, silent=True):
|
||||
printLog(device, 'Successfully reset fan speed to driver control', None)
|
||||
else:
|
||||
printLog(device, 'Not supported on the given system', None)
|
||||
printLogSpacer()
|
||||
|
||||
|
||||
@@ -1354,8 +1367,10 @@ def setFanSpeed(deviceList, fan):
|
||||
else:
|
||||
fanLevel = int(str(fan))
|
||||
ret = rocmsmi.rsmi_dev_fan_speed_set(device, 0, int(fanLevel))
|
||||
if rsmi_ret_ok(ret, device, 'set_fan_speed'):
|
||||
if rsmi_ret_ok(ret, device, silent=True):
|
||||
printLog(device, 'Successfully set fan speed to level %s' % (str(int(fanLevel))), None)
|
||||
else:
|
||||
printLog(device, 'Not supported on the given system', None)
|
||||
printLogSpacer()
|
||||
|
||||
|
||||
@@ -1806,15 +1821,19 @@ def showClocks(deviceList):
|
||||
for clk_type in sorted(rsmi_clk_names_dict):
|
||||
if rocmsmi.rsmi_dev_gpu_clk_freq_get(device, rsmi_clk_names_dict[clk_type], None) == 1:
|
||||
ret = rocmsmi.rsmi_dev_gpu_clk_freq_get(device, rsmi_clk_names_dict[clk_type], byref(freq))
|
||||
if rsmi_ret_ok(ret, device, 'get_clk_freq_' + clk_type, True):
|
||||
printLog(device, 'Supported %s frequencies on GPU%s' % (clk_type, str(device)), None)
|
||||
for x in range(freq.num_supported):
|
||||
fr = '{:>.0f}Mhz'.format(freq.frequency[x] / 1000000)
|
||||
if x == freq.current:
|
||||
printLog(device, str(x), str(fr) + ' *')
|
||||
else:
|
||||
printLog(device, str(x), str(fr))
|
||||
printLog(device, '', None)
|
||||
if ret == rsmi_status_t.RSMI_STATUS_UNEXPECTED_DATA:
|
||||
printLog(device, 'Clock [%s] on device [%s] exists but EMPTY! Likely driver error!' % (clk_type, str(device)))
|
||||
continue
|
||||
if not rsmi_ret_ok(ret, device, 'get_clk_freq_' + clk_type, True):
|
||||
continue
|
||||
printLog(device, 'Supported %s frequencies on GPU%s' % (clk_type, str(device)), None)
|
||||
for x in range(freq.num_supported):
|
||||
fr = '{:>.0f}Mhz'.format(freq.frequency[x] / 1000000)
|
||||
if x == freq.current:
|
||||
printLog(device, str(x), str(fr) + ' *')
|
||||
else:
|
||||
printLog(device, str(x), str(fr))
|
||||
printLog(device, '', None)
|
||||
else:
|
||||
logging.debug('{} frequency is unsupported on device[{}]'.format(clk_type, device))
|
||||
printLog(device, '', None)
|
||||
@@ -3518,8 +3537,7 @@ def save(deviceList, savefilepath):
|
||||
# The code below is for when this script is run as an executable instead of when imported as a module
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(
|
||||
description='AMD ROCm System Management Interface | ROCM-SMI version: %s | Kernel version: %s' % (
|
||||
__version__, getVersion(None, rsmi_sw_component_t.RSMI_SW_COMP_DRIVER)),
|
||||
description=f'AMD ROCm System Management Interface | ROCM-SMI version: {__version__}',
|
||||
formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=90, width=120))
|
||||
groupDev = parser.add_argument_group()
|
||||
groupDisplayOpt = parser.add_argument_group('Display Options')
|
||||
@@ -3679,6 +3697,11 @@ if __name__ == '__main__':
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Must set PRINT_JSON early so the prints can be silenced
|
||||
if args.json or args.csv:
|
||||
PRINT_JSON = True
|
||||
# Initialize rsmiBindings
|
||||
rocmsmi = initRsmiBindings(silent=PRINT_JSON)
|
||||
# Initialize the rocm SMI library
|
||||
initializeRsmi()
|
||||
|
||||
@@ -3714,8 +3737,7 @@ if __name__ == '__main__':
|
||||
sys.exit(1)
|
||||
|
||||
# If we want JSON/CSV output, initialize the keys (devices)
|
||||
if args.json or args.csv:
|
||||
PRINT_JSON = True
|
||||
if PRINT_JSON:
|
||||
for device in deviceList:
|
||||
JSON_DATA['card' + str(device)] = {}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""ROCm_SMI_LIB CLI Tool Python Bindings"""
|
||||
# NOTE: You MUST call rsmiBindings.initRsmiBindings() when using this library!
|
||||
# TODO: Get most (or all) of these from rocm_smi.h to avoid mismatches and redundancy
|
||||
|
||||
from __future__ import print_function
|
||||
@@ -14,36 +15,42 @@ import os
|
||||
# relative path changed accordingly.
|
||||
# if ROCM_SMI_LIB_PATH is set, we can load 'librocm_smi64.so' from that location
|
||||
#
|
||||
# Library load is wrapped in a function so prints can be hidden for PRINT_JSON mode.
|
||||
path_librocm = str()
|
||||
rocm_smi_lib_path = os.getenv('ROCM_SMI_LIB_PATH')
|
||||
if (rocm_smi_lib_path != None):
|
||||
path_librocm = rocm_smi_lib_path
|
||||
else:
|
||||
path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../@CMAKE_INSTALL_LIBDIR@/librocm_smi64.so.@VERSION_MAJOR@'
|
||||
def initRsmiBindings(silent=False):
|
||||
def print_silent(*args):
|
||||
if not silent:
|
||||
print(args)
|
||||
|
||||
if not os.path.isfile(path_librocm):
|
||||
print('Unable to find %s . Trying /opt/rocm*' % path_librocm)
|
||||
for root, dirs, files in os.walk('/opt', followlinks=True):
|
||||
if 'librocm_smi64.so.@VERSION_MAJOR@' in files:
|
||||
path_librocm = os.path.join(os.path.realpath(root), 'librocm_smi64.so.@VERSION_MAJOR@')
|
||||
if os.path.isfile(path_librocm):
|
||||
print('Using lib from %s' % path_librocm)
|
||||
rocm_smi_lib_path = os.getenv('ROCM_SMI_LIB_PATH')
|
||||
if (rocm_smi_lib_path != None):
|
||||
path_librocm = rocm_smi_lib_path
|
||||
else:
|
||||
print('Unable to find librocm_smi64.so.@VERSION_MAJOR@')
|
||||
else:
|
||||
print('Library loaded from: %s ' % path_librocm)
|
||||
path_librocm = os.path.dirname(os.path.realpath(__file__)) + '/../../@CMAKE_INSTALL_LIBDIR@/librocm_smi64.so.@VERSION_MAJOR@'
|
||||
|
||||
# ----------> TODO: Support static libs as well as SO
|
||||
try:
|
||||
cdll.LoadLibrary(path_librocm)
|
||||
rocmsmi = CDLL(path_librocm)
|
||||
except OSError:
|
||||
print('Unable to load the rocm_smi library.\n'\
|
||||
'Set LD_LIBRARY_PATH to the folder containing librocm_smi64.so.@VERSION_MAJOR@\n'\
|
||||
'{0}Please refer to https://github.com/'\
|
||||
'RadeonOpenCompute/rocm_smi_lib for the installation guide.{1}'\
|
||||
.format('\33[33m', '\033[0m'))
|
||||
exit()
|
||||
if not os.path.isfile(path_librocm):
|
||||
print_silent('Unable to find %s . Trying /opt/rocm*' % path_librocm)
|
||||
for root, dirs, files in os.walk('/opt', followlinks=True):
|
||||
if 'librocm_smi64.so.@VERSION_MAJOR@' in files:
|
||||
path_librocm = os.path.join(os.path.realpath(root), 'librocm_smi64.so.@VERSION_MAJOR@')
|
||||
if os.path.isfile(path_librocm):
|
||||
print_silent('Using lib from %s' % path_librocm)
|
||||
else:
|
||||
print('Unable to find librocm_smi64.so.@VERSION_MAJOR@')
|
||||
else:
|
||||
print_silent('Library loaded from: %s ' % path_librocm)
|
||||
|
||||
# ----------> TODO: Support static libs as well as SO
|
||||
try:
|
||||
cdll.LoadLibrary(path_librocm)
|
||||
return CDLL(path_librocm)
|
||||
except OSError:
|
||||
print('Unable to load the rocm_smi library.\n'\
|
||||
'Set LD_LIBRARY_PATH to the folder containing librocm_smi64.so.@VERSION_MAJOR@\n'\
|
||||
'{0}Please refer to https://github.com/'\
|
||||
'RadeonOpenCompute/rocm_smi_lib for the installation guide.{1}'\
|
||||
.format('\33[33m', '\033[0m'))
|
||||
exit()
|
||||
|
||||
# Device ID
|
||||
dv_id = c_uint64()
|
||||
|
||||
@@ -839,7 +839,7 @@ int main() {
|
||||
}
|
||||
CHK_RSMI_NOT_SUPPORTED_RET(ret)
|
||||
|
||||
std::cout << "\t**Averge Power Usage: ";
|
||||
std::cout << "\t**Average Power Usage: ";
|
||||
ret = rsmi_dev_power_ave_get(i, 0, &val_ui64);
|
||||
if (ret == RSMI_STATUS_SUCCESS) {
|
||||
std::cout << static_cast<float>(val_ui64)/1000 << " W" << std::endl;
|
||||
|
||||
+9
-4
@@ -407,6 +407,10 @@ static rsmi_status_t set_dev_mon_value(amd::smi::MonitorTypes type,
|
||||
}
|
||||
int ret = dev->monitor()->writeMonitor(type, sensor_ind,
|
||||
std::to_string(val));
|
||||
/// If the sysfs file doesn't exist, it is not supported.
|
||||
if (ret == ENOENT) {
|
||||
return rsmi_status_t::RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
return amd::smi::ErrnoToRsmiStatus(ret);
|
||||
}
|
||||
@@ -2631,9 +2635,8 @@ rsmi_dev_fan_reset(uint32_t dv_ind, uint32_t sensor_ind) {
|
||||
LOG_TRACE(ss);
|
||||
|
||||
++sensor_ind; // fan sysfs files have 1-based indices
|
||||
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
|
||||
ret = set_dev_mon_value<uint64_t>(amd::smi::kMonFanCntrlEnable,
|
||||
dv_ind, sensor_ind, 2);
|
||||
return ret;
|
||||
@@ -2669,14 +2672,12 @@ rsmi_dev_fan_speed_set(uint32_t dv_ind, uint32_t sensor_ind, uint64_t speed) {
|
||||
// First need to set fan mode (pwm1_enable) to 1 (aka, "manual")
|
||||
ret = set_dev_mon_value<uint64_t>(amd::smi::kMonFanCntrlEnable, dv_ind,
|
||||
sensor_ind, 1);
|
||||
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = set_dev_mon_value<uint64_t>(amd::smi::kMonFanSpeed, dv_ind,
|
||||
sensor_ind, speed);
|
||||
|
||||
return ret;
|
||||
|
||||
CATCH
|
||||
@@ -3739,6 +3740,10 @@ rsmi_dev_memory_reserved_pages_get(uint32_t dv_ind, uint32_t *num_pages,
|
||||
|
||||
ret = GetDevValueVec(amd::smi::kDevMemPageBad, dv_ind, &val_vec);
|
||||
|
||||
// file is empty, which is valid for no errors
|
||||
if (ret == RSMI_STATUS_UNEXPECTED_DATA) {
|
||||
ret = RSMI_STATUS_SUCCESS;
|
||||
}
|
||||
if (ret == RSMI_STATUS_FILE_ERROR) {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
@@ -858,8 +858,8 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
|
||||
ss << "Read devInfoMultiLineStr for DevInfoType ("
|
||||
<< RocmSMI::devInfoTypesStrings.at(type) << ")"
|
||||
<< ", but contained no string lines";
|
||||
LOG_INFO(ss);
|
||||
return 0;
|
||||
LOG_ERROR(ss);
|
||||
return ENXIO;
|
||||
}
|
||||
// Remove any *trailing* empty (whitespace) lines
|
||||
while (!retVec->empty() &&
|
||||
@@ -882,6 +882,7 @@ int Device::readDevInfoMultiLineStr(DevInfoTypes type,
|
||||
<< RocmSMI::devInfoTypesStrings.at(type) << ")"
|
||||
<< ", but lines were empty";
|
||||
LOG_INFO(ss);
|
||||
return ENXIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+25
-10
@@ -166,6 +166,7 @@ const AMDGpuVerbList_t amdgpu_verb_check_list {
|
||||
{ AMDGpuVerbTypes_t::kGetGpuOdVoltCurveRegions, "amdsmi_get_gpu_od_volt_curve_regions" }
|
||||
};
|
||||
|
||||
const uint16_t kDevIDAll(0xFFFF);
|
||||
const uint16_t kDevRevIDAll(0xFFFF);
|
||||
const AMDGpuPropertyList_t amdgpu_property_reinforcement_list {
|
||||
//
|
||||
@@ -176,6 +177,14 @@ const AMDGpuPropertyList_t amdgpu_property_reinforcement_list {
|
||||
// rsmi_dev_perf_level::RSMI_DEV_PERF_LEVEL_MANUAL = rsmi_dev_clk_range_set;
|
||||
//
|
||||
|
||||
// AMD All Families
|
||||
{kDevIDAll, {kDevRevIDAll,
|
||||
make_unique_property_id(AMDGpuPropertyTypesOffset_t::kMonitorTypes,
|
||||
MonitorTypes::kMonFanCntrlEnable),
|
||||
AMDGpuVerbTypes_t::kResetGpuFan,
|
||||
AMDGpuPropertyOpModeTypes_t::kBoth, false }
|
||||
},
|
||||
|
||||
// AMD Instinct MI210
|
||||
{0x740F, {0x02,
|
||||
make_unique_property_id(AMDGpuPropertyTypesOffset_t::kDevInfoTypes,
|
||||
@@ -239,12 +248,6 @@ const AMDGpuPropertyList_t amdgpu_property_reinforcement_list {
|
||||
AMDGpuVerbTypes_t::kGetGpuPowerProfilePresets,
|
||||
AMDGpuPropertyOpModeTypes_t::kBoth, false }
|
||||
},
|
||||
{0x74A1, {kDevRevIDAll,
|
||||
make_unique_property_id(AMDGpuPropertyTypesOffset_t::kDevInfoTypes,
|
||||
DevInfoTypes::kDevGpuReset),
|
||||
AMDGpuVerbTypes_t::kResetGpu,
|
||||
AMDGpuPropertyOpModeTypes_t::kSrIov, false }
|
||||
},
|
||||
{0x74A1, {kDevRevIDAll,
|
||||
make_unique_property_id(AMDGpuPropertyTypesOffset_t::kPerfTypes,
|
||||
rsmi_dev_perf_level::RSMI_DEV_PERF_LEVEL_DETERMINISM),
|
||||
@@ -350,7 +353,7 @@ rsmi_status_t validate_property_reinforcement_query(uint32_t dv_ind, AMDGpuVerbT
|
||||
// likely the reinforcement table does not contain any entries/rules for the
|
||||
// dev_id in question.
|
||||
//
|
||||
auto amdgpu_property_query_result_hdlr = [](rsmi_status_t query_result) {
|
||||
auto amdgpu_property_query_result_hdlr = [&](const rsmi_status_t query_result) {
|
||||
switch (query_result) {
|
||||
case (rsmi_status_t::RSMI_STATUS_UNKNOWN_ERROR):
|
||||
case (rsmi_status_t::RSMI_STATUS_NO_DATA):
|
||||
@@ -363,7 +366,7 @@ rsmi_status_t validate_property_reinforcement_query(uint32_t dv_ind, AMDGpuVerbT
|
||||
break;
|
||||
|
||||
default:
|
||||
return rsmi_status_t::RSMI_STATUS_NOT_FOUND;
|
||||
return actual_error_code;
|
||||
break;
|
||||
}
|
||||
};
|
||||
@@ -415,7 +418,7 @@ rsmi_status_t Device::check_amdgpu_property_reinforcement_query(uint32_t dev_idx
|
||||
std::ostringstream osstream;
|
||||
auto rsmi_status(rsmi_status_t::RSMI_STATUS_UNKNOWN_ERROR);
|
||||
|
||||
AMDGpuPropertyQuery_t amdgpu_property_query = [&]() {
|
||||
auto amdgpu_property_query = [&]() {
|
||||
AMDGpuPropertyQuery_t amdgpu_property_query_init{};
|
||||
amdgpu_property_query_init.m_asic_id = 0;
|
||||
amdgpu_property_query_init.m_pci_rev_id = 0;
|
||||
@@ -445,6 +448,18 @@ rsmi_status_t Device::check_amdgpu_property_reinforcement_query(uint32_t dev_idx
|
||||
LOG_TRACE(osstream);
|
||||
|
||||
bool is_proper_query(false);
|
||||
|
||||
// Generic filter for checking properties for all asics and revisions.
|
||||
auto amdgpu_property_query_all_asics = amdgpu_property_query;
|
||||
amdgpu_property_query_all_asics.m_asic_id = kDevIDAll;
|
||||
amdgpu_property_query_all_asics.m_pci_rev_id = kDevRevIDAll;
|
||||
auto amdgpu_property_query_result = run_amdgpu_property_reinforcement_query(amdgpu_property_query_all_asics);
|
||||
// We found a generic entry for all asics and revisions
|
||||
if (amdgpu_property_query_result != rsmi_status_t::RSMI_STATUS_UNKNOWN_ERROR) {
|
||||
return amdgpu_property_query_result;
|
||||
}
|
||||
|
||||
// If no generic entry, then we query for specific asic and revision ids.
|
||||
amdgpu_property_query = build_asic_id_filters(amdgpu_property_query, is_proper_query);
|
||||
if (!is_proper_query) {
|
||||
rsmi_status = rsmi_status_t::RSMI_STATUS_NO_DATA;
|
||||
@@ -487,7 +502,7 @@ rsmi_status_t Device::run_amdgpu_property_reinforcement_query(const AMDGpuProper
|
||||
osstream << __PRETTY_FUNCTION__ << " asic id found: " << itr_begin->first << "\n";
|
||||
// Pci_rev_id matches the filter or ALL Revisions
|
||||
if ((itr_begin->second.m_pci_rev_id == amdgpu_property_query.m_pci_rev_id) ||
|
||||
(itr_begin->second.m_pci_rev_id == kDevRevIDAll)) {
|
||||
(itr_begin->second.m_pci_rev_id == kDevRevIDAll)) {
|
||||
osstream << __PRETTY_FUNCTION__ << " asic rev.id found: " << itr_begin->second.m_pci_rev_id << "\n";
|
||||
// Do we have the property we are looking for?
|
||||
if (((amdgpu_property_query.m_property != 0) &&
|
||||
|
||||
@@ -176,6 +176,13 @@ int isRegularFile(std::string fname, bool *is_reg) {
|
||||
}
|
||||
|
||||
int WriteSysfsStr(std::string path, std::string val) {
|
||||
// On success, zero is returned. On error, -1 is returned, and
|
||||
// errno is set to indicate the error.
|
||||
auto is_regular_file_result = isRegularFile(path, nullptr);
|
||||
if (is_regular_file_result != 0) {
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
std::ofstream fs;
|
||||
int ret = 0;
|
||||
std::ostringstream ss;
|
||||
|
||||
@@ -123,16 +123,22 @@ void TestFrequenciesRead::Run(void) {
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED);
|
||||
} else {
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Supported " << name << " clock frequencies: ";
|
||||
std::cout << f.num_supported << std::endl;
|
||||
print_frequencies(&f);
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
|
||||
}
|
||||
}
|
||||
|
||||
// special driver issue, shouldn't normally occur
|
||||
if (err == RSMI_STATUS_UNEXPECTED_DATA) {
|
||||
std::cerr << "WARN: Clock file [" << FreqEnumToStr(t) << "] exists on device [" << i << "] but empty!" << std::endl;
|
||||
std::cerr << " Likely a driver issue!" << std::endl;
|
||||
}
|
||||
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Supported " << name << " clock frequencies: ";
|
||||
std::cout << f.num_supported << std::endl;
|
||||
print_frequencies(&f);
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_gpu_clk_freq_get(i, t, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_INVALID_ARGS);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -104,8 +104,7 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
for (uint32_t dv_ind = 0; dv_ind < num_monitor_devs(); ++dv_ind) {
|
||||
PrintDeviceHeader(dv_ind);
|
||||
|
||||
for (uint32_t clk = (uint32_t)RSMI_CLK_TYPE_FIRST;
|
||||
clk <= RSMI_CLK_TYPE_LAST; ++clk) {
|
||||
for (uint32_t clk = RSMI_CLK_TYPE_FIRST; clk <= RSMI_CLK_TYPE_LAST; ++clk) {
|
||||
rsmi_clk = (rsmi_clk_type)clk;
|
||||
|
||||
auto freq_read = [&]() -> bool {
|
||||
@@ -114,14 +113,20 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(rsmi_clk) <<
|
||||
": Not supported on this machine" << std::endl;
|
||||
return false;
|
||||
} else {
|
||||
// CHK_ERR_ASRT(ret)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " <<
|
||||
FreqEnumToStr(rsmi_clk) << " is " << f.current << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// special driver issue, shouldn't normally occur
|
||||
if (ret == RSMI_STATUS_UNEXPECTED_DATA) {
|
||||
std::cerr << "WARN: Clock file [" << FreqEnumToStr(rsmi_clk) << "] exists on device [" << dv_ind << "] but empty!" << std::endl;
|
||||
std::cerr << " Likely a driver issue!" << std::endl;
|
||||
}
|
||||
|
||||
// CHK_ERR_ASRT(ret)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " <<
|
||||
FreqEnumToStr(rsmi_clk) << " is " << f.current << std::endl;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
auto freq_write = [&]() {
|
||||
@@ -141,14 +146,18 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
std::endl;
|
||||
}
|
||||
ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, freq_bitmask);
|
||||
//Certain ASICs does not allow to set particular clocks. If set function for a clock returns
|
||||
//permission error despite root access, manually set ret value to success and return
|
||||
if (ret == RSMI_STATUS_PERMISSION && geteuid() == 0) {
|
||||
// Certain ASICs does not allow to set particular clocks. If set function for a clock returns
|
||||
// permission error despite root access, manually set ret value to success and return
|
||||
//
|
||||
// Sometimes setting clock frequencies is completely not supported
|
||||
if ((ret == RSMI_STATUS_PERMISSION && geteuid() == 0) ||
|
||||
(ret == RSMI_STATUS_NOT_SUPPORTED)) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(rsmi_clk) <<
|
||||
": Not supported on this machine. Skipping..." << std::endl;
|
||||
ret = RSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
}
|
||||
|
||||
CHK_ERR_ASRT(ret)
|
||||
ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
@@ -160,12 +169,20 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
std::cout << "Resetting mask to all frequencies." << std::endl;
|
||||
}
|
||||
ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, 0xFFFFFFFF);
|
||||
if (ret == RSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout << "\t**Set " << FreqEnumToStr(rsmi_clk)
|
||||
<< ": Not supported on this machine. Skipping..." << std::endl;
|
||||
ret = RSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
}
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO);
|
||||
if (ret != RSMI_STATUS_SUCCESS) {
|
||||
if (ret == RSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout << "\t**Setting performance level is not supported on this machine. Skipping..." << std::endl;
|
||||
ret = RSMI_STATUS_SUCCESS;
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -177,44 +194,6 @@ void TestFrequenciesReadWrite::Run(void) {
|
||||
}
|
||||
freq_write();
|
||||
CHK_ERR_ASRT(ret)
|
||||
#if 0
|
||||
ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Initial frequency for clock " << rsmi_clk << " is " <<
|
||||
f.current << std::endl;
|
||||
}
|
||||
// Set clocks to something other than the usual default of the lowest
|
||||
// frequency.
|
||||
freq_bitmask = 0b01100; // Try the 3rd and 4th clocks
|
||||
|
||||
std::string freq_bm_str =
|
||||
std::bitset<RSMI_MAX_NUM_FREQUENCIES>(freq_bitmask).to_string();
|
||||
|
||||
freq_bm_str.erase(0, std::min(freq_bm_str.find_first_not_of('0'),
|
||||
freq_bm_str.size()-1));
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Setting frequency mask for clock " << rsmi_clk <<
|
||||
" to 0b" << freq_bm_str << " ..." << std::endl;
|
||||
}
|
||||
ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, freq_bitmask);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
ret = rsmi_dev_gpu_clk_freq_get(dv_ind, rsmi_clk, &f);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "Frequency is now index " << f.current << std::endl;
|
||||
std::cout << "Resetting mask to all frequencies." << std::endl;
|
||||
}
|
||||
ret = rsmi_dev_gpu_clk_freq_set(dv_ind, rsmi_clk, 0xFFFFFFFF);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
ret = rsmi_dev_perf_level_set(dv_ind, RSMI_DEV_PERF_LEVEL_AUTO);
|
||||
CHK_ERR_ASRT(ret)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,6 +114,13 @@ void TestPowerCapReadWrite::Run(void) {
|
||||
ret = rsmi_dev_power_cap_get(dv_ind, 0, nullptr);
|
||||
ASSERT_EQ(ret, RSMI_STATUS_INVALID_ARGS);
|
||||
|
||||
// Check if power cap is within the range
|
||||
// skip the test otherwise
|
||||
if (orig < min || orig > max) {
|
||||
std::cout << "Power cap is not within the range. Skipping test for " << dv_ind << std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
new_cap = (max + min)/2;
|
||||
|
||||
IF_VERB(STANDARD) {
|
||||
|
||||
@@ -117,8 +117,18 @@ void TestPowerRead::Run(void) {
|
||||
}
|
||||
|
||||
err = rsmi_dev_power_ave_get(i, 0, &val_ui64);
|
||||
if (err == RSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout <<
|
||||
"\t**Power average information is not supported for this device"
|
||||
<< std::endl;
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
err = rsmi_dev_power_ave_get(i, 0, nullptr);
|
||||
ASSERT_EQ(err, RSMI_STATUS_NOT_SUPPORTED);
|
||||
continue;
|
||||
}
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << "\t**Averge Power Usage: ";
|
||||
std::cout << "\t**Average Power Usage: ";
|
||||
CHK_RSMI_PERM_ERR(err)
|
||||
if (err == RSMI_STATUS_SUCCESS) {
|
||||
std::cout << static_cast<float>(val_ui64)/1000 << " mW" << std::endl;
|
||||
|
||||
@@ -123,6 +123,15 @@ void TestPowerReadWrite::Run(void) {
|
||||
PrintDeviceHeader(dv_ind);
|
||||
|
||||
ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, &status);
|
||||
if (ret == RSMI_STATUS_NOT_SUPPORTED) {
|
||||
std::cout <<
|
||||
"\t**Power profile presets are not supported for this device"
|
||||
<< std::endl;
|
||||
// Verify api support checking functionality is working
|
||||
ret = rsmi_dev_power_profile_presets_get(dv_ind, 0, nullptr);
|
||||
ASSERT_EQ(ret, RSMI_STATUS_NOT_SUPPORTED);
|
||||
continue;
|
||||
}
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
// Verify api support checking functionality is working
|
||||
|
||||
@@ -64,8 +64,7 @@ $BLACKLIST_ALL_ASICS\
|
||||
# /sys/class/kfd/kfd/topology/nodes/*/properties
|
||||
FILTER[90400]=\
|
||||
$BLACKLIST_ALL_ASICS\
|
||||
"rsmitstReadOnly.TestVoltCurvRead:"\
|
||||
"rsmitstReadWrite.TestPowerReadWrite"
|
||||
"rsmitstReadOnly.TestVoltCurvRead"
|
||||
FILTER[90401]=${FILTER[90400]}
|
||||
FILTER[90402]=${FILTER[90400]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user