Merge remote-tracking branch 'rocmsmi/amd-staging' into amd-dev

Change-Id: I6037383a3efa777cc281a992fd9aa11d8e9ced28


[ROCm/amdsmi commit: 3d3759061a]
This commit is contained in:
Galantsev, Dmitrii
2023-10-04 18:42:56 -05:00
commit 1b4acb28f8
4 muutettua tiedostoa jossa 98 lisäystä ja 52 poistoa
@@ -52,7 +52,7 @@ function( parse_version VERSION_STRING )
string ( SUBSTRING ${VERSION_STRING} ${STRING_INDEX} -1 VERSION_BUILD )
endif ()
string ( REGEX MATCHALL "[0123456789]+" VERSIONS ${VERSION_STRING} )
string ( REGEX MATCHALL "[0-9]+" VERSIONS ${VERSION_STRING} )
list ( LENGTH VERSIONS VERSION_COUNT )
if ( ${VERSION_COUNT} GREATER 0)
@@ -30,8 +30,8 @@ from rsmiBindings import *
# Minor version - Increment when adding a new feature, set to 0 when major is incremented
# Patch version - Increment when adding a fix, set to 0 when minor is incremented
SMI_MAJ = 1
SMI_MIN = 4
SMI_PAT = 1
SMI_MIN = 5
SMI_PAT = 0
__version__ = '%s.%s.%s' % (SMI_MAJ, SMI_MIN, SMI_PAT)
# Set to 1 if an error occurs
@@ -1675,6 +1675,32 @@ def setNPSMode(deviceList, npsMode):
printErrLog(device, 'Failed to retrieve NPS mode, even though device supports it.')
printLogSpacer()
def showVersion(isCSV=False):
values = { 'ROCM-SMI version': __version__ }
version = rsmi_version_t()
status = rocmsmi.rsmi_version_get(byref(version))
if status == 0:
version_string = "%u.%u.%u" % (version.major, version.minor, version.patch)
values['ROCM-SMI-LIB version'] = version_string
if isCSV:
print('name, value')
for k in values.keys():
print('%s, %s' % (k, values[k]))
return
if PRINT_JSON:
temp_str = '{\n'
for k in values.keys():
temp_str += ' "%s": "%s",\n' % (k, values[k])
if len(values.keys()) > 1:
# replace ',\n' with '\n}'
temp_str = temp_str[:-2]
temp_str += '\n}'
print(temp_str)
return
for k in values.keys():
print('%s: %s' % (k, values[k]))
def showAllConcise(deviceList):
""" Display critical info for all devices in a concise format
@@ -2052,7 +2078,7 @@ def showFwInfo(deviceList, fwType):
ret = rocmsmi.rsmi_dev_firmware_version_get(device, fw_block_names_l.index(fw_name), byref(fw_ver))
if rsmi_ret_ok(ret, device, 'get_firmware_version_' + str(fw_name)):
# The VCN, VCE, UVD, SOS and ASD firmware's value needs to be in hexadecimal
if fw_name in ['VCN', 'VCE', 'UVD', 'SOS', 'ASD']:
if fw_name in ['VCN', 'VCE', 'UVD', 'SOS', 'ASD', 'MES', 'MES KIQ']:
printLog(device, '%s firmware version' % (fw_name),
'\t0x%s' % (str(hex(fw_ver.value))[2:].zfill(8)))
# The TA XGMI, TA RAS, and SMC firmware's hex value looks like 0x12345678
@@ -2955,7 +2981,7 @@ def showTempGraph(deviceList):
printLogSpacer()
def showVersion(deviceList, component):
def showDriverVersion(deviceList, component):
""" Display the software version for the specified component
@param deviceList: List of DRM devices (can be a single-item list)
@@ -3614,6 +3640,7 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='AMD ROCm System Management Interface | ROCM-SMI version: %s' % __version__,
formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=90, width=120))
groupVersion = parser.add_argument_group()
groupDev = parser.add_argument_group()
groupDisplayOpt = parser.add_argument_group('Display Options')
groupDisplayTop = parser.add_argument_group('Topology')
@@ -3627,6 +3654,7 @@ if __name__ == '__main__':
groupResponse = parser.add_argument_group('Auto-response options')
groupActionOutput = parser.add_argument_group('Output options')
groupVersion.add_argument('-V', '--version', help='Show version information', action='store_true')
groupDev.add_argument('-d', '--device', help='Execute command on specified device', type=int, nargs='+')
groupDisplayOpt.add_argument('--alldevices', action='store_true') # ------------- function deprecated, no help menu
groupDisplayOpt.add_argument('--showhw', help='Show Hardware details', action='store_true')
@@ -3775,11 +3803,16 @@ if __name__ == '__main__':
# 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()
if args.version:
showVersion(isCSV=args.csv)
sys.exit()
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARNING)
if args.loglevel is not None:
numericLogLevel = getattr(logging, args.loglevel.upper(), logging.WARNING)
@@ -3878,7 +3911,7 @@ if __name__ == '__main__':
if args.showhw:
showAllConciseHw(deviceList)
if args.showdriverversion:
showVersion(deviceList, rsmi_sw_component_t.RSMI_SW_COMP_DRIVER)
showDriverVersion(deviceList, rsmi_sw_component_t.RSMI_SW_COMP_DRIVER)
if args.showtempgraph:
showTempGraph(deviceList)
if args.showid:
@@ -37,8 +37,6 @@ def initRsmiBindings(silent=False):
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:
@@ -419,25 +417,27 @@ class rsmi_fw_block_t(c_int):
RSMI_FW_BLOCK_ME = 4
RSMI_FW_BLOCK_MEC = 5
RSMI_FW_BLOCK_MEC2 = 6
RSMI_FW_BLOCK_PFP = 7
RSMI_FW_BLOCK_RLC = 8
RSMI_FW_BLOCK_RLC_SRLC = 9
RSMI_FW_BLOCK_RLC_SRLG = 10
RSMI_FW_BLOCK_RLC_SRLS = 11
RSMI_FW_BLOCK_SDMA = 12
RSMI_FW_BLOCK_SDMA2 = 13
RSMI_FW_BLOCK_SMC = 14
RSMI_FW_BLOCK_SOS = 15
RSMI_FW_BLOCK_TA_RAS = 16
RSMI_FW_BLOCK_TA_XGMI = 17
RSMI_FW_BLOCK_UVD = 18
RSMI_FW_BLOCK_VCE = 19
RSMI_FW_BLOCK_VCN = 20
RSMI_FW_BLOCK_MES = 7
RSMI_FW_BLOCK_MES_KIQ = 8
RSMI_FW_BLOCK_PFP = 9
RSMI_FW_BLOCK_RLC = 10
RSMI_FW_BLOCK_RLC_SRLC = 11
RSMI_FW_BLOCK_RLC_SRLG = 12
RSMI_FW_BLOCK_RLC_SRLS = 13
RSMI_FW_BLOCK_SDMA = 14
RSMI_FW_BLOCK_SDMA2 = 15
RSMI_FW_BLOCK_SMC = 16
RSMI_FW_BLOCK_SOS = 17
RSMI_FW_BLOCK_TA_RAS = 18
RSMI_FW_BLOCK_TA_XGMI = 19
RSMI_FW_BLOCK_UVD = 20
RSMI_FW_BLOCK_VCE = 21
RSMI_FW_BLOCK_VCN = 22
RSMI_FW_BLOCK_LAST = RSMI_FW_BLOCK_VCN
# The following list correlated to the rsmi_fw_block_t
fw_block_names_l = ['ASD', 'CE', 'DMCU', 'MC', 'ME', 'MEC', 'MEC2', 'PFP',\
fw_block_names_l = ['ASD', 'CE', 'DMCU', 'MC', 'ME', 'MEC', 'MEC2', 'MES', 'MES KIQ', 'PFP',\
'RLC', 'RLC SRLC', 'RLC SRLG', 'RLC SRLS', 'SDMA', 'SDMA2',\
'SMC', 'SOS', 'TA RAS', 'TA XGMI', 'UVD', 'VCE', 'VCN']
@@ -43,9 +43,7 @@
*
*/
#include <stdint.h>
#include <stddef.h>
#include <cstdint>
#include <iostream>
#include <string>
@@ -87,15 +85,23 @@ void TestFrequenciesRead::Close() {
static void print_frequencies(amdsmi_frequencies_t *f, uint32_t *l = nullptr) {
assert(f != nullptr);
for (uint32_t j = 0; j < f->num_supported; ++j) {
std::cout << "\t** " << j << ": " << f->frequency[j];
for (uint32_t clk_i = 0; clk_i < f->num_supported; ++clk_i) {
std::string clk_i_str;
if (f->has_deep_sleep) {
clk_i_str = (clk_i == 0) ? "S" : std::to_string(clk_i-1);
} else {
clk_i_str = std::to_string(clk_i);
}
std::cout << "\t** " <<
std::setw(2) << std::right << clk_i_str << ": " <<
std::setw(11) << std::right << f->frequency[clk_i];
if (l != nullptr) {
std::cout << "T/s; x" << l[j];
std::cout << "T/s; x" << l[clk_i];
} else {
std::cout << "Hz";
}
if (j == f->current) {
if (clk_i == f->current) {
std::cout << " *";
}
std::cout << std::endl;
@@ -123,23 +129,30 @@ void TestFrequenciesRead::Run(void) {
// Verify api support checking functionality is working
err = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
} else if (err == AMDSMI_STATUS_NOT_YET_IMPLEMENTED) {
return;
}
if (err == AMDSMI_STATUS_NOT_YET_IMPLEMENTED) {
std::cout << "\t**Get " << name <<
": Not implemented on this machine" << std::endl;
// special driver issue, shouldn't normally occur
} else if (err == AMDSMI_STATUS_UNEXPECTED_DATA) {
return;
}
if (err == AMDSMI_STATUS_UNEXPECTED_DATA) {
// special driver issue, shouldn't normally occur
std::cerr << "WARN: Clock file [" << FreqEnumToStr(t) << "] exists on device [" << i << "] but empty!" << std::endl;
std::cerr << " Likely a driver issue!" << std::endl;
} 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 = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
return;
}
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 = amdsmi_get_clk_freq(processor_handles_[i], t, nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
};
@@ -162,15 +175,15 @@ void TestFrequenciesRead::Run(void) {
std::cout << "\t**Get PCIE Bandwidth "
<< ": Not implemented on this machine" << std::endl;
} else {
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Supported PCIe bandwidths: ";
std::cout << b.transfer_rate.num_supported << std::endl;
print_frequencies(&b.transfer_rate, b.lanes);
// Verify api support checking functionality is working
err = amdsmi_get_gpu_pci_bandwidth(processor_handles_[i], nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
CHK_ERR_ASRT(err)
IF_VERB(STANDARD) {
std::cout << "\t**Supported PCIe bandwidths: ";
std::cout << b.transfer_rate.num_supported << std::endl;
print_frequencies(&b.transfer_rate, b.lanes);
// Verify api support checking functionality is working
err = amdsmi_get_gpu_pci_bandwidth(processor_handles_[i], nullptr);
ASSERT_EQ(err, AMDSMI_STATUS_INVAL);
}
}
}
}