SWDEV-492272 [AMDSMI] Build/Compiler warnings messages
Fix compiler warnings
Signed-off-by: Joe Narlo <Joseph.Narlo@amd.com>
Change-Id: I10657b8f3ef18a9b45311e8f6509958297a57823
[ROCm/amdsmi commit: d0a7332d32]
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <inttypes.h>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
|
||||
@@ -262,11 +263,11 @@ int main() {
|
||||
ret = amdsmi_get_gpu_device_bdf(processor_handles[j], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_gpu_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number,
|
||||
bdf.bus_number,
|
||||
bdf.device_number,
|
||||
bdf.function_number);
|
||||
printf("\tDevice[%d] BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n\n", i,
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
|
||||
// Get handle from BDF
|
||||
amdsmi_processor_handle dev_handle;
|
||||
@@ -408,12 +409,12 @@ int main() {
|
||||
printf("\tPCIe max speed: %d\n", pcie_info.pcie_static.max_pcie_speed);
|
||||
|
||||
// additional pcie related metrics
|
||||
printf("\tPCIe bandwidth: %d\n", pcie_info.pcie_metric.pcie_bandwidth);
|
||||
printf("\tPCIe replay count: %d\n", pcie_info.pcie_metric.pcie_replay_count);
|
||||
printf("\tPCIe L0 recovery count: %d\n", pcie_info.pcie_metric.pcie_l0_to_recovery_count);
|
||||
printf("\tPCIe rollover count: %d\n", pcie_info.pcie_metric.pcie_replay_roll_over_count);
|
||||
printf("\tPCIe nak received count: %d\n", pcie_info.pcie_metric.pcie_nak_received_count);
|
||||
printf("\tPCIe nak sent count: %d\n", pcie_info.pcie_metric.pcie_nak_sent_count);
|
||||
printf("\tPCIe bandwidth: %u\n", pcie_info.pcie_metric.pcie_bandwidth);
|
||||
printf("\tPCIe replay count: %" PRIu64 "\n", pcie_info.pcie_metric.pcie_replay_count);
|
||||
printf("\tPCIe L0 recovery count: %" PRIu64 "\n", pcie_info.pcie_metric.pcie_l0_to_recovery_count);
|
||||
printf("\tPCIe rollover count: %" PRIu64 "\n", pcie_info.pcie_metric.pcie_replay_roll_over_count);
|
||||
printf("\tPCIe nak received count: %" PRIu64 "\n", pcie_info.pcie_metric.pcie_nak_received_count);
|
||||
printf("\tPCIe nak sent count: %" PRIu64 "\n", pcie_info.pcie_metric.pcie_nak_sent_count);
|
||||
|
||||
// Get VRAM temperature limit
|
||||
int64_t temperature = 0;
|
||||
@@ -522,13 +523,6 @@ int main() {
|
||||
printf("\tCorrectable errors: %lu\n", err_cnt_info.correctable_count);
|
||||
printf("\tUncorrectable errors: %lu\n\n",
|
||||
err_cnt_info.uncorrectable_count);
|
||||
// Get process list
|
||||
auto compare = [](const void *a, const void *b) -> int {
|
||||
return (*(amdsmi_proc_info_t *)a).pid >
|
||||
(*(amdsmi_proc_info_t *)b).pid
|
||||
? 1
|
||||
: -1;
|
||||
};
|
||||
|
||||
uint32_t num_process = 0;
|
||||
ret = amdsmi_get_gpu_process_list(processor_handles[j], &num_process, nullptr);
|
||||
@@ -542,18 +536,17 @@ int main() {
|
||||
uint64_t mem = 0, gtt_mem = 0, cpu_mem = 0, vram_mem = 0;
|
||||
uint64_t gfx = 0, enc = 0;
|
||||
char bdf_str[20];
|
||||
sprintf(bdf_str, "%04lx:%02x:%02x.%d",
|
||||
bdf.domain_number,
|
||||
bdf.bus_number,
|
||||
bdf.device_number,
|
||||
bdf.function_number);
|
||||
int num = 0;
|
||||
sprintf(bdf_str, "%04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32,
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
ret = amdsmi_get_gpu_process_list(processor_handles[j], &num_process, process_info_list);
|
||||
std::cout << "Allocation size for process list: " << num_process << "\n";
|
||||
CHK_AMDSMI_RET(ret);
|
||||
for (auto idx = uint32_t(0); idx < num_process; ++idx) {
|
||||
process = static_cast<amdsmi_proc_info_t>(process_info_list[idx]);
|
||||
printf("\t *Process id: %ld / Name: %s / VRAM: %lld \n", process.pid, process.name, process.memory_usage.vram_mem);
|
||||
printf("\t *Process id: %d / Name: %s / VRAM: %ld \n", process.pid, process.name, process.memory_usage.vram_mem);
|
||||
}
|
||||
|
||||
printf("+=======+==================+============+=============="
|
||||
@@ -569,7 +562,7 @@ int main() {
|
||||
printf("+=======+"
|
||||
"+=============+=============+=============+============"
|
||||
"==+=========================================+\n");
|
||||
for (int it = 0; it < num_process; it++) {
|
||||
for (int it = 0; it < static_cast<int>(num_process); it++) {
|
||||
char command[30];
|
||||
struct passwd *pwd = nullptr;
|
||||
struct stat st;
|
||||
@@ -609,11 +602,13 @@ int main() {
|
||||
"-+-------------+-------------+-------------+----------"
|
||||
"----+-----------------------------------------+\n");
|
||||
}
|
||||
// TODO: To remove compiler warning, the last 3 values in this printf were
|
||||
// set to 0L. Need to find out what these values need to be.
|
||||
printf("| TOTAL:| %s | %7ld "
|
||||
"KiB | %7ld KiB | %7ld KiB | %7ld KiB | %lu %lu "
|
||||
"%lu %lu %lu |\n",
|
||||
bdf_str, mem, gtt_mem, cpu_mem, vram_mem, gfx,
|
||||
enc);
|
||||
enc, 0L, 0L, 0L);
|
||||
printf("+=======+==================+============+=============="
|
||||
"+=============+=============+=============+============"
|
||||
"=+==========================================+\n");
|
||||
@@ -674,11 +669,11 @@ int main() {
|
||||
ret = amdsmi_get_gpu_metrics_info(processor_handles[j], &smu);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_gpu_metrics_info:\n");
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number,
|
||||
bdf.bus_number,
|
||||
bdf.device_number,
|
||||
bdf.function_number);
|
||||
printf("\tDevice[%d] BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n\n", i,
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
|
||||
std::cout << "METRIC TABLE HEADER:\n";
|
||||
std::cout << "structure_size=" << std::dec
|
||||
@@ -706,7 +701,7 @@ int main() {
|
||||
auto idx = 0;
|
||||
for (const auto& temp : smu.temperature_hbm) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.temperature_hbm)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.temperature_hbm))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -723,7 +718,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.vcn_activity) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.vcn_activity)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.vcn_activity))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -736,7 +731,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.jpeg_activity) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.jpeg_activity)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.jpeg_activity))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -773,7 +768,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.current_gfxclks) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.current_gfxclks)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.current_gfxclks))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -786,7 +781,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.current_socclks) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.current_socclks)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.current_socclks))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -800,7 +795,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.current_vclk0s) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.current_vclk0s)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.current_vclk0s))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -813,7 +808,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.current_dclk0s) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.current_dclk0s)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.current_dclk0s))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -850,7 +845,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.xgmi_read_data_acc) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.xgmi_read_data_acc)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.xgmi_read_data_acc))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -862,7 +857,7 @@ int main() {
|
||||
idx = 0;
|
||||
for (const auto& temp : smu.xgmi_write_data_acc) {
|
||||
std::cout << temp;
|
||||
if ((idx + 1) != std::size(smu.xgmi_write_data_acc)) {
|
||||
if ((idx + 1) != static_cast<int>(std::size(smu.xgmi_write_data_acc))) {
|
||||
std::cout << ", ";
|
||||
} else {
|
||||
std::cout << "]\n";
|
||||
@@ -922,7 +917,7 @@ int main() {
|
||||
for (auto& row : smu.xcp_stats) {
|
||||
std::cout << "\t XCP [" << idx << "] : [";
|
||||
for (auto& col : row.gfx_busy_inst) {
|
||||
if ((idy + 1) != std::size(row.gfx_busy_inst)) {
|
||||
if ((idy + 1) != static_cast<int>(std::size(row.gfx_busy_inst))) {
|
||||
std::cout << col << ", ";
|
||||
} else {
|
||||
std::cout << col;
|
||||
@@ -940,7 +935,7 @@ int main() {
|
||||
for (auto& row : smu.xcp_stats) {
|
||||
std::cout << "\t XCP [" << idx << "] : [";
|
||||
for (auto& col : row.vcn_busy) {
|
||||
if ((idy + 1) != std::size(row.vcn_busy)) {
|
||||
if ((idy + 1) != static_cast<int>(std::size(row.vcn_busy))) {
|
||||
std::cout << col << ", ";
|
||||
} else {
|
||||
std::cout << col;
|
||||
@@ -958,7 +953,7 @@ int main() {
|
||||
for (auto& row : smu.xcp_stats) {
|
||||
std::cout << "\t XCP [" << idx << "] : [";
|
||||
for (auto& col : row.jpeg_busy) {
|
||||
if ((idy + 1) != std::size(row.jpeg_busy)) {
|
||||
if ((idy + 1) != static_cast<int>(std::size(row.jpeg_busy))) {
|
||||
std::cout << col << ", ";
|
||||
} else {
|
||||
std::cout << col;
|
||||
@@ -976,7 +971,7 @@ int main() {
|
||||
for (auto& row : smu.xcp_stats) {
|
||||
std::cout << "\t XCP [" << idx << "] : [";
|
||||
for (auto& col : row.gfx_busy_acc) {
|
||||
if ((idy + 1) != std::size(row.gfx_busy_acc)) {
|
||||
if ((idy + 1) != static_cast<int>(std::size(row.gfx_busy_acc))) {
|
||||
std::cout << col << ", ";
|
||||
} else {
|
||||
std::cout << col;
|
||||
@@ -1040,8 +1035,11 @@ int main() {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf("\t\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
printf("\t\tGPU BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n",
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include <pwd.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -114,11 +115,11 @@ int main() {
|
||||
ret = amdsmi_get_gpu_device_bdf(processor_handles[j], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf(" Output of amdsmi_get_gpu_device_bdf:\n");
|
||||
printf("\tDevice[%d] BDF %04lx:%02x:%02x.%d\n\n", i,
|
||||
bdf.domain_number,
|
||||
bdf.bus_number,
|
||||
bdf.device_number,
|
||||
bdf.function_number);
|
||||
printf("\tDevice[%d] BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n\n", i,
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
|
||||
amdsmi_asic_info_t asic_info = {};
|
||||
ret = amdsmi_get_gpu_asic_info(processor_handles[j], &asic_info);
|
||||
@@ -319,7 +320,7 @@ int main() {
|
||||
CHK_AMDSMI_RET(ret)
|
||||
std::cout << "\t amdsmi_get_soc_pstate total:" << policy.num_supported
|
||||
<<" current:" << policy.current << "\n";
|
||||
for (int x=0; x < policy.num_supported; x++) {
|
||||
for (uint32_t x=0; x < policy.num_supported; x++) {
|
||||
std::cout << x <<": (" << policy.policies[x].policy_id
|
||||
<<"," << policy.policies[x].policy_description << ")\n";
|
||||
}
|
||||
@@ -349,8 +350,11 @@ int main() {
|
||||
amdsmi_bdf_t bdf = {};
|
||||
ret = amdsmi_get_gpu_device_bdf(topology_nearest_info.processor_list[k], &bdf);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
printf("\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
printf("\tGPU BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n",
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ using std::fixed;
|
||||
using std::setprecision;
|
||||
using std::vector;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) {
|
||||
amdsmi_status_t ret;
|
||||
uint32_t proto_ver;
|
||||
amdsmi_smu_fw_version_t smu_fw = {};
|
||||
@@ -157,7 +157,7 @@ int main(int argc, char **argv) {
|
||||
retVal = snprintf(str, SHOWLINESZ, "\n| mclk (Mhz)\t\t\t |");
|
||||
|
||||
len = strlen(str);
|
||||
uint32_t fclk, mclk, cclk;
|
||||
uint32_t fclk, mclk;
|
||||
err_bits = 0;
|
||||
|
||||
ret = amdsmi_get_cpu_fclk_mclk(plist[index], &fclk, &mclk);
|
||||
@@ -265,7 +265,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
double fraction_q10 = 1/pow(2,10);
|
||||
double fraction_uq10 = fraction_q10;
|
||||
const char* err_str1;
|
||||
|
||||
amdsmi_hsmp_metrics_table_t mtbl = {};
|
||||
ret = amdsmi_get_hsmp_metrics_table(plist[index], &mtbl);
|
||||
|
||||
@@ -695,7 +695,7 @@ static rsmi_status_t test_set_memory_partition(uint32_t dv_ind) {
|
||||
}
|
||||
|
||||
template<typename T> constexpr float convert_mw_to_w(T mw) {
|
||||
return static_cast<float>(mw / 1000.0);
|
||||
return static_cast<float>(static_cast<double>(mw) / 1000.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1112,7 +1112,7 @@ int main() {
|
||||
if (ret == RSMI_STATUS_SUCCESS) {
|
||||
ret = rsmi_dev_fan_speed_max_get(i, 0, &val_ui64);
|
||||
CHK_AND_PRINT_RSMI_ERR_RET(ret)
|
||||
std::cout << (static_cast<float>(val_i64)/val_ui64) * 100;
|
||||
std::cout << (static_cast<float>(val_i64)/static_cast<float>(val_ui64)) * 100;
|
||||
std::cout << "% (" << std::dec << val_i64 << "/"
|
||||
<< std::dec << val_ui64 << ")" << "\n";
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ class TagTextContents_t
|
||||
|
||||
decltype(auto) get_structured_data_subkey_last(const PrimaryKeyType& prim_key) {
|
||||
return (get_structured_value_by_keys(prim_key, get_structured_data_subkey_by_position(prim_key,
|
||||
(get_structured_subkeys_size(prim_key) - 1))));
|
||||
static_cast<int>((get_structured_subkeys_size(prim_key) - 1)))));
|
||||
}
|
||||
|
||||
void reset() {
|
||||
|
||||
@@ -186,39 +186,6 @@ static uint64_t freq_string_to_int(const std::vector<std::string> &freq_lines,
|
||||
return static_cast<uint64_t>(freq*multiplier);
|
||||
}
|
||||
|
||||
static void freq_volt_string_to_point(std::string in_line,
|
||||
rsmi_od_vddc_point_t *pt) {
|
||||
std::istringstream fs_vlt(in_line);
|
||||
|
||||
assert(pt != nullptr);
|
||||
THROW_IF_NULLPTR_DEREF(pt)
|
||||
|
||||
uint32_t ind;
|
||||
float freq;
|
||||
float volts;
|
||||
std::string junk;
|
||||
std::string freq_units_str;
|
||||
std::string volts_units_str;
|
||||
|
||||
fs_vlt >> ind;
|
||||
fs_vlt >> junk; // colon
|
||||
fs_vlt >> freq;
|
||||
fs_vlt >> freq_units_str;
|
||||
fs_vlt >> volts;
|
||||
fs_vlt >> volts_units_str;
|
||||
|
||||
if (freq < 0) {
|
||||
throw amd::smi::rsmi_exception(RSMI_STATUS_UNEXPECTED_SIZE, __FUNCTION__);
|
||||
}
|
||||
|
||||
long double multiplier = get_multiplier_from_str(freq_units_str[0]);
|
||||
|
||||
pt->frequency = static_cast<uint64_t>(freq*multiplier);
|
||||
|
||||
multiplier = get_multiplier_from_str(volts_units_str[0]);
|
||||
pt->voltage = static_cast<uint64_t>(volts*multiplier);
|
||||
}
|
||||
|
||||
static void od_value_pair_str_to_range(std::string in_line, rsmi_range_t *rg) {
|
||||
std::istringstream fs_rng(in_line);
|
||||
|
||||
@@ -898,7 +865,7 @@ rsmi_status_t rsmi_ras_feature_info_get(
|
||||
auto eeprom_version = strtoul(
|
||||
feature_line.substr(strlen(version_key)).c_str(), nullptr, 16);
|
||||
if (errno == 0) {
|
||||
ras_feature->ras_eeprom_version = eeprom_version;
|
||||
ras_feature->ras_eeprom_version = static_cast<uint32_t>(eeprom_version);
|
||||
} else {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -922,7 +889,7 @@ rsmi_status_t rsmi_ras_feature_info_get(
|
||||
auto schema = strtoul(
|
||||
feature_line.substr(strlen(schema_key)).c_str(), nullptr, 16);
|
||||
if (errno == 0) {
|
||||
ras_feature->ecc_correction_schema_flag = schema;
|
||||
ras_feature->ecc_correction_schema_flag = static_cast<uint32_t>(schema);
|
||||
} else {
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -2044,7 +2011,7 @@ rsmi_dev_gpu_clk_freq_set(uint32_t dv_ind,
|
||||
// will have read-only perms, and the OS will deny access, before the request hits the driver level
|
||||
if (status == RSMI_STATUS_PERMISSION){
|
||||
bool read_only = false;
|
||||
int perms = amd::smi::isReadOnlyForAll(dev->path(), &read_only);
|
||||
amd::smi::isReadOnlyForAll(dev->path(), &read_only);
|
||||
if(read_only){
|
||||
return RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
@@ -2113,8 +2080,6 @@ rsmi_status_t rsmi_dev_process_isolation_get(uint32_t dv_ind,
|
||||
|
||||
rsmi_status_t rsmi_dev_process_isolation_set(uint32_t dv_ind,
|
||||
uint32_t pisolate) {
|
||||
rsmi_status_t ret;
|
||||
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
|
||||
@@ -2178,8 +2143,6 @@ rsmi_status_t rsmi_dev_process_isolation_set(uint32_t dv_ind,
|
||||
}
|
||||
|
||||
rsmi_status_t rsmi_dev_gpu_run_cleaner_shader(uint32_t dv_ind) {
|
||||
rsmi_status_t ret;
|
||||
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
|
||||
@@ -2294,8 +2257,6 @@ rsmi_dev_xgmi_plpd_get(uint32_t dv_ind,
|
||||
rsmi_status_t
|
||||
rsmi_dev_xgmi_plpd_set(uint32_t dv_ind,
|
||||
uint32_t plpd_id) {
|
||||
rsmi_status_t ret;
|
||||
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
|
||||
@@ -2408,8 +2369,6 @@ rsmi_dev_soc_pstate_get(uint32_t dv_ind,
|
||||
rsmi_status_t
|
||||
rsmi_dev_soc_pstate_set(uint32_t dv_ind,
|
||||
uint32_t policy_id) {
|
||||
rsmi_status_t ret;
|
||||
|
||||
TRY
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << " | ======= start =======";
|
||||
@@ -2977,25 +2936,25 @@ rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *b) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Hardcode based on PCIe specification: Search PCI_Express on wikipedia
|
||||
// Hardcode based on PCIe specification: search PCI_Express on wikipedia
|
||||
const uint32_t link_width[] = {1, 2, 4, 8, 12, 16};
|
||||
const uint32_t link_speed[] = {25, 50, 80, 160}; // 0.1 Ghz
|
||||
const uint32_t WIDTH_DATA_LENGTH = sizeof(link_width)/sizeof(uint32_t);
|
||||
const uint32_t SPEED_DATA_LENGTH = sizeof(link_speed)/sizeof(uint32_t);
|
||||
|
||||
// Calculate the index
|
||||
uint32_t width_index = -1;
|
||||
uint32_t speed_index = -1;
|
||||
int32_t width_index = -1;
|
||||
int32_t speed_index = -1;
|
||||
uint32_t cur_index = 0;
|
||||
for (cur_index = 0; cur_index < WIDTH_DATA_LENGTH; cur_index++) {
|
||||
if (link_width[cur_index] == gpu_metrics.pcie_link_width) {
|
||||
width_index = cur_index;
|
||||
width_index = static_cast<int32_t>(cur_index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (cur_index = 0; cur_index < SPEED_DATA_LENGTH; cur_index++) {
|
||||
if (link_speed[cur_index] == gpu_metrics.pcie_link_speed) {
|
||||
speed_index = cur_index;
|
||||
speed_index = static_cast<int32_t>(cur_index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3004,7 +2963,7 @@ rsmi_dev_pci_bandwidth_get(uint32_t dv_ind, rsmi_pcie_bandwidth_t *b) {
|
||||
}
|
||||
// Set possible lanes and frequencies
|
||||
b->transfer_rate.num_supported = WIDTH_DATA_LENGTH * SPEED_DATA_LENGTH;
|
||||
b->transfer_rate.current = speed_index*WIDTH_DATA_LENGTH + width_index;
|
||||
b->transfer_rate.current = static_cast<uint32_t>(speed_index)*WIDTH_DATA_LENGTH + static_cast<uint32_t>(width_index);
|
||||
for (cur_index = 0; cur_index < WIDTH_DATA_LENGTH * SPEED_DATA_LENGTH; cur_index++) {
|
||||
b->transfer_rate.frequency[cur_index] =
|
||||
static_cast<long>(link_speed[cur_index/WIDTH_DATA_LENGTH]) * 100 * 1000000L;
|
||||
@@ -3930,7 +3889,6 @@ rsmi_dev_memory_total_get(uint32_t dv_ind, rsmi_memory_type_t mem_type,
|
||||
rsmi_status_t rsmi_dev_cache_info_get(
|
||||
uint32_t dv_ind, rsmi_gpu_cache_info_t *info) {
|
||||
TRY
|
||||
rsmi_status_t ret;
|
||||
std::ostringstream ss;
|
||||
ss << __PRETTY_FUNCTION__ << "| ======= start =======";
|
||||
LOG_TRACE(ss);
|
||||
@@ -4214,7 +4172,6 @@ rsmi_utilization_count_get(uint32_t dv_ind,
|
||||
|
||||
rsmi_status_t ret;
|
||||
rsmi_gpu_metrics_t gpu_metrics;
|
||||
uint32_t val_ui32;
|
||||
uint16_t val_counter(0);
|
||||
|
||||
ret = rsmi_dev_gpu_metrics_info_get(dv_ind, &gpu_metrics);
|
||||
@@ -5704,10 +5661,6 @@ rsmi_dev_memory_partition_set(uint32_t dv_ind,
|
||||
REQUIRE_ROOT_ACCESS
|
||||
DEVICE_MUTEX
|
||||
const int k1000_MS_WAIT = 1000;
|
||||
const uint32_t kMaxBoardLength = 128;
|
||||
bool isCorrectDevice = false;
|
||||
char boardName[kMaxBoardLength];
|
||||
boardName[0] = '\0';
|
||||
|
||||
const uint32_t kMaxMemoryCapabilitiesSize = 30;
|
||||
char available_memory_capabilities[kMaxMemoryCapabilitiesSize];
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "rocm_smi/rocm_smi_logger.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -134,7 +135,7 @@ int present_pmmetrics(const char* fname,
|
||||
}
|
||||
|
||||
table = NULL;
|
||||
len = fread(buf1, 1, 65536, infile);
|
||||
len = static_cast<int32_t>(fread(buf1, 1, 65536, infile));
|
||||
fseek(infile, 0, SEEK_SET);
|
||||
memcpy(&pmmetrics_version, &buf1[12], 4);
|
||||
|
||||
@@ -156,11 +157,11 @@ int present_pmmetrics(const char* fname,
|
||||
static int parse_reg_state_table(uint8_t *buf, int32_t buflen,
|
||||
struct metric_field *table,
|
||||
rsmi_name_value_t **kv, uint32_t *kvnum) {
|
||||
int skip_smn, x, y, cur_instance, cur_smn,
|
||||
num_instance, num_smn, instance_start, smn_start;
|
||||
uint64_t skip_smn, x, y, cur_instance, cur_smn,
|
||||
num_instance, num_smn, instance_start, smn_start;
|
||||
uint64_t v;
|
||||
uint8_t *obuf, *origbuf;
|
||||
int kvsize = 64;
|
||||
uint32_t kvsize = 64;
|
||||
|
||||
*kv = reinterpret_cast<rsmi_name_value_t*>(calloc(kvsize, sizeof **kv));
|
||||
*kvnum = 0;
|
||||
@@ -171,7 +172,7 @@ static int parse_reg_state_table(uint8_t *buf, int32_t buflen,
|
||||
origbuf = buf;
|
||||
top:
|
||||
while (table[x].field_name != NULL) {
|
||||
for (y = 0; y < table[x].field_arr_size; y++) {
|
||||
for (y = 0; y < static_cast<uint64_t>(table[x].field_arr_size); y++) {
|
||||
obuf = buf;
|
||||
v = get_value(&buf, &table[x]);
|
||||
if ((intptr_t)(buf - origbuf) > buflen) {
|
||||
@@ -203,10 +204,10 @@ top:
|
||||
}
|
||||
break;
|
||||
case FIELD_FLAG_NUM_INSTANCE:
|
||||
num_instance = v;
|
||||
num_instance = static_cast<int64_t>(v);
|
||||
break;
|
||||
case FIELD_FLAG_NUM_SMN:
|
||||
num_smn = v;
|
||||
num_smn = static_cast<int64_t>(v);
|
||||
if (v)
|
||||
skip_smn = 0;
|
||||
else
|
||||
@@ -220,12 +221,12 @@ top:
|
||||
}
|
||||
sprintf((*kv)[*kvnum].name, "%s", table[x].field_name);
|
||||
if (table[x].field_arr_size > 1) {
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), "[%d]", y);
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), "[%" PRId64 "]", y);
|
||||
}
|
||||
if (x >= instance_start)
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), ".instance[%d]", cur_instance);
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), ".instance[%" PRId64 "]", cur_instance);
|
||||
if (x >= smn_start)
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), ".smn[%d]", cur_smn);
|
||||
sprintf((*kv)[*kvnum].name + strlen((*kv)[*kvnum].name), ".smn[%" PRId64 "]", cur_smn);
|
||||
(*kv)[*kvnum].value = v;
|
||||
++(*kvnum);
|
||||
}
|
||||
@@ -290,7 +291,7 @@ int present_reg_state(const char* fname,
|
||||
return -2;
|
||||
}
|
||||
|
||||
len = fread(buf, 1, sizeof buf, infile);
|
||||
len = static_cast<int32_t>(fread(buf, 1, sizeof buf, infile));
|
||||
fclose(infile);
|
||||
return parse_reg_state_table(buf, len, tab, kv, kvnum);
|
||||
}
|
||||
|
||||
@@ -1474,7 +1474,6 @@ rsmi_status_t Device::restartAMDGpuDriver(void) {
|
||||
bool success = false;
|
||||
std::string out;
|
||||
bool wasGdmServiceActive = false;
|
||||
bool restartInProgress = true;
|
||||
bool isRestartInProgress = true;
|
||||
bool isAMDGPUModuleLive = false;
|
||||
bool restartGDM = false;
|
||||
@@ -1560,7 +1559,6 @@ rsmi_status_t Device::isRestartInProgress(bool *isRestartInProgress,
|
||||
bool *isAMDGPUModuleLive) {
|
||||
REQUIRE_ROOT_ACCESS
|
||||
std::ostringstream ss;
|
||||
bool restartSuccessful = true;
|
||||
bool success = false;
|
||||
std::string out;
|
||||
bool deviceRestartInProgress = true; // Assume in progress, we intend to disprove
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace amd::smi
|
||||
|
||||
constexpr uint16_t join_metrics_version(uint8_t format_rev, uint8_t content_rev)
|
||||
{
|
||||
return (format_rev << 8 | content_rev);
|
||||
return static_cast<uint16_t>((format_rev << 8 | content_rev));
|
||||
}
|
||||
|
||||
constexpr uint16_t join_metrics_version(const AMDGpuMetricsHeader_v1_t& metrics_header)
|
||||
@@ -473,8 +473,8 @@ AMDGpuDynamicMetricTblValues_t format_metric_row(const T& metric, const std::str
|
||||
void GpuMetricsBase_v16_t::dump_internal_metrics_table()
|
||||
{
|
||||
std::ostringstream ss;
|
||||
auto idx = uint64_t(0);
|
||||
auto idy = uint64_t(0);
|
||||
auto idx = int64_t(0);
|
||||
auto idy = int64_t(0);
|
||||
std::cout << __PRETTY_FUNCTION__ << " | ======= start ======= \n";
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< " | ======= DEBUG ======= "
|
||||
@@ -570,9 +570,16 @@ void GpuMetricsBase_v16_t::dump_internal_metrics_table()
|
||||
}
|
||||
for (auto& col : row.gfx_busy_inst) {
|
||||
ss << "\t [" << idx << "] [" << idy << "]: " << col;
|
||||
#if 1 // TODO: Refactor this code using make_ostream_joiner
|
||||
// Do for all occurences in this file
|
||||
if (idy + 1 != (std::end(row.gfx_busy_inst) - std::end(row.gfx_busy_inst) - 1)) {
|
||||
ss << ", ";
|
||||
}
|
||||
#else
|
||||
std::copy(std::begin(row.gfx_busy_inst),
|
||||
std::end(row.gfx_busy_inst),
|
||||
amd::smi::make_ostream_joiner(&ss, ", "));
|
||||
#endif
|
||||
if (idx + 1 !=
|
||||
(std::end(m_gpu_metrics_tbl.m_xcp_stats) - std::end(m_gpu_metrics_tbl.m_xcp_stats) - 1)) {
|
||||
ss << "\n";
|
||||
@@ -4024,7 +4031,7 @@ rsmi_dev_gpu_metrics_info_get(uint32_t dv_ind, rsmi_gpu_metrics_t* smu) {
|
||||
|
||||
dev->set_smi_device_id(dv_ind);
|
||||
uint32_t partition_id = 0;
|
||||
auto ret = rsmi_dev_partition_id_get(dv_ind, &partition_id);
|
||||
rsmi_dev_partition_id_get(dv_ind, &partition_id);
|
||||
dev->set_smi_partition_id(partition_id);
|
||||
dev->dev_log_gpu_metrics(ostrstream);
|
||||
const auto [error_code, external_metrics] = dev->dev_copy_internal_to_external_metrics();
|
||||
|
||||
@@ -879,7 +879,7 @@ int KFDNode::get_used_memory(uint64_t* used) {
|
||||
return 1;
|
||||
}
|
||||
struct kfd_ioctl_get_available_memory_args mem = {0, 0, 0};
|
||||
mem.gpu_id = gpu_id_;
|
||||
mem.gpu_id = static_cast<uint32_t>(gpu_id_);
|
||||
if (ioctl(kfd_fd, AMDKFD_IOC_AVAILABLE_MEMORY , &mem) != 0) {
|
||||
close(kfd_fd);
|
||||
return 1;
|
||||
@@ -925,8 +925,7 @@ int KFDNode::get_cache_info(rsmi_gpu_cache_info_t *info) {
|
||||
// num_cu_shared – this can be fetched by counting the number of 1’s in the sibling_map.
|
||||
std::string sibling_map =
|
||||
get_properties_from_file(prop_file, "sibling_map ");
|
||||
uint32_t num_cu_shared =
|
||||
std::count(sibling_map.begin(), sibling_map.end(), '1');
|
||||
uint32_t num_cu_shared = static_cast<uint32_t>(std::count(sibling_map.begin(), sibling_map.end(), '1'));
|
||||
|
||||
// known cache type
|
||||
bool is_count_already = false;
|
||||
|
||||
@@ -755,10 +755,9 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
|
||||
int ret_unique_id = read_node_properties(node_id, "unique_id", &unique_id);
|
||||
int ret_loc_id =
|
||||
read_node_properties(node_id, "location_id", &location_id);
|
||||
int ret_domain =
|
||||
read_node_properties(node_id, "domain", &domain);
|
||||
read_node_properties(node_id, "domain", &domain);
|
||||
if (ret_gpu_id == 0 &&
|
||||
~(ret_unique_id != 0 || ret_loc_id != 0 || ret_unique_id != 0)) {
|
||||
!(ret_unique_id != 0 || ret_loc_id != 0 || ret_unique_id != 0)) {
|
||||
// Do not try to build a node if one of these fields
|
||||
// do not exist in KFD (0 as values okay)
|
||||
systemNode myNode;
|
||||
@@ -804,7 +803,7 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
|
||||
|
||||
uint32_t cardAdded = 0;
|
||||
// Discover all root cards & gpu partitions associated with each
|
||||
for (uint32_t cardId = 0; cardId <= max_cardId; cardId++) {
|
||||
for (int32_t cardId = 0; cardId <= max_cardId; cardId++) {
|
||||
std::string path = kPathDRMRoot;
|
||||
path += "/card";
|
||||
path += std::to_string(cardId);
|
||||
@@ -917,7 +916,6 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
|
||||
LOG_DEBUG(ss);
|
||||
|
||||
uint64_t temp_primary_unique_id = 0;
|
||||
uint64_t primary_location_id = 0;
|
||||
if (allSystemNodes.empty()) {
|
||||
cardAdded++;
|
||||
ss << __PRETTY_FUNCTION__
|
||||
@@ -966,7 +964,7 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
|
||||
} else {
|
||||
cardAdded++;
|
||||
// remove already added nodes associated with current card
|
||||
auto erasedNodes = allSystemNodes.erase(0);
|
||||
allSystemNodes.erase(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -988,7 +986,6 @@ uint32_t RocmSMI::DiscoverAmdgpuDevices(void) {
|
||||
auto removalLocId = it->second.s_location_id;
|
||||
auto removaldomain = it->second.s_domain;
|
||||
auto nodesErased = 1;
|
||||
primary_location_id = removalLocId;
|
||||
allSystemNodes.erase(it++);
|
||||
ss << __PRETTY_FUNCTION__
|
||||
<< "\nPRIMARY --> num_nodes == temp_numb_nodes; ERASING "
|
||||
|
||||
@@ -1090,6 +1090,7 @@ std::string splitString(std::string str, char delim) {
|
||||
tokens.push_back(token);
|
||||
return token; // return 1st match
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static std::string pt_rng_Mhz(std::string title, rsmi_range *r) {
|
||||
@@ -1118,26 +1119,6 @@ static std::string pt_rng_mV(std::string title, rsmi_range *r) {
|
||||
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) {
|
||||
@@ -1242,7 +1223,7 @@ rsmi_status_t rsmi_dev_number_of_computes_get(uint32_t dv_ind, uint32_t* num_com
|
||||
return rsmi_status_t::RSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
*num_computes = (tmp_simd_count / tmp_simd_per_cu);
|
||||
*num_computes = static_cast<uint32_t>((tmp_simd_count / tmp_simd_per_cu));
|
||||
return rsmi_status_t::RSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1296,7 +1277,7 @@ void system_wait(int milli_seconds) {
|
||||
}
|
||||
|
||||
int countDigit(uint64_t n) {
|
||||
return static_cast<int>(std::floor(log10(n) + 1));
|
||||
return static_cast<int>(std::floor(log10(static_cast<double>(n)) + 1));
|
||||
}
|
||||
|
||||
} // namespace smi
|
||||
|
||||
@@ -1020,8 +1020,9 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i
|
||||
|
||||
// If vendor name is empty and the vendor id is 0x1002, set vendor name to AMD vendor string
|
||||
if ((info->vendor_name != NULL && info->vendor_name[0] == '\0') && info->vendor_id == 0x1002) {
|
||||
memset(info->vendor_name, 0, 38);
|
||||
strncpy(info->vendor_name, "Advanced Micro Devices Inc. [AMD/ATI]", 37);
|
||||
std::string amd_name = "Advanced Micro Devices Inc. [AMD/ATI]";
|
||||
memset(info->vendor_name, 0, amd_name.size()+1);
|
||||
strncpy(info->vendor_name, amd_name.c_str(), amd_name.size()+1);
|
||||
}
|
||||
|
||||
// default to 0xffff as not supported
|
||||
@@ -1506,7 +1507,6 @@ amdsmi_get_gpu_accelerator_partition_profile(amdsmi_processor_handle processor_h
|
||||
|
||||
// TODO(amdsmi_team): add resources here ^
|
||||
auto tmp_partition_id = uint32_t(0);
|
||||
auto tmp_xcd_count = uint16_t(0);
|
||||
amdsmi_status_t status = AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
|
||||
status = rsmi_wrapper(rsmi_dev_partition_id_get, processor_handle, &tmp_partition_id);
|
||||
@@ -2196,7 +2196,7 @@ amdsmi_get_clock_info(amdsmi_processor_handle processor_handle, amdsmi_clk_type_
|
||||
}
|
||||
info->max_clk = max_freq;
|
||||
info->min_clk = min_freq;
|
||||
info->clk_deep_sleep = sleep_state_freq;
|
||||
info->clk_deep_sleep = static_cast<uint8_t>(sleep_state_freq);
|
||||
|
||||
switch (clk_type) {
|
||||
case AMDSMI_CLK_TYPE_GFX:
|
||||
@@ -2493,7 +2493,6 @@ amdsmi_get_gpu_device_uuid(amdsmi_processor_handle processor_handle, unsigned in
|
||||
amdsmi_status_t status = AMDSMI_STATUS_SUCCESS;
|
||||
SMIGPUDEVICE_MUTEX(gpu_device->get_mutex())
|
||||
|
||||
size_t len = AMDSMI_GPU_UUID_SIZE;
|
||||
amdsmi_asic_info_t asic_info = {};
|
||||
const uint8_t fcn = 0xff;
|
||||
|
||||
@@ -2556,7 +2555,7 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
|
||||
}
|
||||
|
||||
// pcie speed in sysfs returns in GT/s
|
||||
info->pcie_static.max_pcie_speed = pcie_speed * 1000;
|
||||
info->pcie_static.max_pcie_speed = static_cast<uint32_t>(pcie_speed * 1000);
|
||||
|
||||
switch (info->pcie_static.max_pcie_speed) {
|
||||
case 2500:
|
||||
@@ -2722,8 +2721,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
|
||||
|
||||
auto status(amdsmi_status_t::AMDSMI_STATUS_SUCCESS);
|
||||
constexpr auto kKFD_CRAT_INTRA_SOCKET_WEIGHT = uint32_t(13);
|
||||
constexpr auto kKFD_CRAT_XGMI_WEIGHT = uint32_t(15);
|
||||
|
||||
/*
|
||||
* Note: This will need to be eventually consolidated within a unique link type.
|
||||
@@ -2766,7 +2763,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
uint64_t link_weight;
|
||||
};
|
||||
|
||||
using LinkTopogyOrderPair_t = std::pair<uint64_t, uint64_t>;
|
||||
/*
|
||||
* Note: The link topology table is sorted by the number of hops and link weight.
|
||||
*/
|
||||
@@ -2822,7 +2818,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
|
||||
// Link type matches what we are searching for?
|
||||
auto io_link_type = translated_link_type(link_type);
|
||||
auto io_link_type_bck(io_link_type);
|
||||
auto num_hops = uint64_t(0);
|
||||
if (auto api_status = amdsmi_topo_get_link_type(processor_handle, device_list[device_idx], &num_hops, &io_link_type);
|
||||
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || (translated_io_link_type(io_link_type) != link_type)) {
|
||||
@@ -2853,7 +2848,7 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
|
||||
* Note: The link topology table is sorted by the number of hops and link weight.
|
||||
*/
|
||||
topology_nearest_info->processor_list[AMDSMI_MAX_DEVICES] = {nullptr};
|
||||
topology_nearest_info->count = link_topology_order.size();
|
||||
topology_nearest_info->count = static_cast<uint32_t>(link_topology_order.size());
|
||||
auto topology_nearest_counter = uint32_t(0);
|
||||
while (!link_topology_order.empty()) {
|
||||
auto link_info = link_topology_order.top();
|
||||
@@ -3959,13 +3954,15 @@ amdsmi_status_t amdsmi_get_cpu_handles(uint32_t *cpu_count,
|
||||
}
|
||||
|
||||
// Get the cpu count
|
||||
*cpu_count = cpu_handles.size();
|
||||
if (processor_handles == nullptr)
|
||||
*cpu_count = static_cast<uint32_t>(cpu_handles.size());
|
||||
if (processor_handles == nullptr) {
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Copy the cpu socket handles
|
||||
for (uint32_t i = 0; i < *cpu_count; i++)
|
||||
for (uint32_t i = 0; i < *cpu_count; i++) {
|
||||
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(cpu_handles[i]);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -4008,28 +4005,32 @@ amdsmi_status_t amdsmi_get_cpucore_handles(uint32_t *cores_count,
|
||||
// Get the coress for each socket
|
||||
status = amdsmi_get_processor_handles_by_type(sockets[index], processor_type,
|
||||
&plist[0], &cores_per_soc);
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
|
||||
core_handles.insert(core_handles.end(), plist.begin(), plist.end());
|
||||
}
|
||||
|
||||
// Get the cores count
|
||||
*cores_count = core_handles.size();
|
||||
if (processor_handles == nullptr)
|
||||
*cores_count = static_cast<uint32_t>(core_handles.size());
|
||||
if (processor_handles == nullptr) {
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Copy the core handles
|
||||
for (uint32_t i = 0; i < *cores_count; i++)
|
||||
for (uint32_t i = 0; i < *cores_count; i++) {
|
||||
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(core_handles[i]);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string)
|
||||
{
|
||||
for (auto& iter : amd::smi::esmi_status_map) {
|
||||
if (iter.first == status) {
|
||||
for (const auto& iter : amd::smi::esmi_status_map) {
|
||||
const amdsmi_status_t _status = status;
|
||||
if (static_cast<int>(iter.first) == static_cast<int>(_status)) {
|
||||
*status_string = esmi_get_err_msg(static_cast<esmi_status_t>(iter.first));
|
||||
return iter.second;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace smi {
|
||||
std::string AMDSmiDrm::find_file_in_folder(const std::string& folder,
|
||||
const std::string& regex) {
|
||||
std::string file_name;
|
||||
// TODO: The closedir function has some non-standard attributes that are being ignored here
|
||||
// which is causing a warning to be thrown
|
||||
using dir_ptr = std::unique_ptr<DIR, decltype(&closedir)>;
|
||||
|
||||
struct dirent *dir = nullptr;
|
||||
@@ -64,7 +66,6 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
// using drm_device_ptr = std::unique_ptr(drmDevicePtr,
|
||||
// decltype(&drmFreeDevice));
|
||||
|
||||
struct dirent *dir = nullptr;
|
||||
int fd = -1;
|
||||
|
||||
|
||||
@@ -162,7 +163,7 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
<< "bdf_rocm | Received bdf: "
|
||||
<< "\nWhole BDF: " << amd::smi::print_unsigned_hex_and_int(bdf_rocm)
|
||||
<< "\nDomain = "
|
||||
<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xFFFFFFFF00000000) >> 32)
|
||||
<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & static_cast<uint64_t>(0xFFFFFFFF00000000)) >> 32)
|
||||
<< "; \nBus# = " << amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xFF00) >> 8)
|
||||
<< "; \nDevice# = "<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xF8) >> 3)
|
||||
<< "; \nFunction# = " << amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0x7));
|
||||
@@ -170,6 +171,8 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
bdf.function_number = ((bdf_rocm & 0x7));
|
||||
bdf.device_number = ((bdf_rocm & 0xF8) >> 3);
|
||||
bdf.bus_number = ((bdf_rocm & 0xFF00) >> 8);
|
||||
// TODO: This is throwing a compiler warning since bdf.domain_number is part of a struct
|
||||
// and is 48 bits long and throws a conversion warning
|
||||
bdf.domain_number = ((bdf_rocm & 0xFFFFFFFF00000000) >> 32);
|
||||
ss << __PRETTY_FUNCTION__ << " | " << "Received bdf: Domain = " << bdf.domain_number
|
||||
<< "; Bus# = " << bdf.bus_number << "; Device# = "<< bdf.device_number
|
||||
|
||||
@@ -229,11 +229,15 @@ amdsmi_status_t AMDSmiSystem::get_gpu_socket_id(uint32_t index,
|
||||
*/
|
||||
|
||||
uint64_t domain = (bdfid >> 32) & 0xffffffff;
|
||||
/* May need later
|
||||
// may need to identify with partition_id in the future as well... TBD
|
||||
uint64_t partition_id = (bdfid >> 28) & 0xf;
|
||||
*/
|
||||
uint64_t bus = (bdfid >> 8) & 0xff;
|
||||
uint64_t device_id = (bdfid >> 3) & 0x1f;
|
||||
/* May need later
|
||||
uint64_t function = bdfid & 0x7;
|
||||
*/
|
||||
|
||||
// The BD part of the BDF is used as the socket id as it
|
||||
// represents a physical device.
|
||||
|
||||
@@ -527,7 +527,7 @@ amdsmi_status_t smi_amdgpu_get_driver_version(amd::smi::AMDSmiGPUDevice* device,
|
||||
|
||||
fclose(fp);
|
||||
if (length) {
|
||||
*length = version[len-1] == '\n' ? len - 1 : len;
|
||||
*length = version[len-1] == '\n' ? static_cast<int>(len - 1) : static_cast<int>(len);
|
||||
}
|
||||
version[len-1] = version[len-1] == '\n' ? '\0' : version[len-1];
|
||||
}
|
||||
@@ -647,6 +647,7 @@ std::string smi_amdgpu_split_string(std::string str, char delim) {
|
||||
tokens.push_back(token);
|
||||
return token; // return 1st match
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
// wrapper to return string expression of a rsmi_status_t return
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -75,11 +76,11 @@ amdsmi_status_t gpuvsmi_get_pids(const amdsmi_bdf_t &bdf, std::vector<long int>
|
||||
struct dirent *dir;
|
||||
|
||||
/* 0000:00:00.0 */
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
|
||||
bdf.domain_number & 0xffff,
|
||||
bdf.bus_number & 0xff,
|
||||
bdf.device_number & 0x1f,
|
||||
bdf.function_number & 0x7);
|
||||
snprintf(bdf_str, 13, "%04" PRIx32 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32,
|
||||
static_cast<uint32_t>(bdf.domain_number & 0xffff),
|
||||
static_cast<uint32_t>(bdf.bus_number & 0xff),
|
||||
static_cast<uint32_t>(bdf.device_number & 0x1f),
|
||||
static_cast<uint32_t>(bdf.function_number & 0x7));
|
||||
|
||||
d = opendir("/proc");
|
||||
if (!d)
|
||||
@@ -124,12 +125,11 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
struct dirent *dir;
|
||||
|
||||
/* 0000:00:00.0 */
|
||||
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
|
||||
bdf.domain_number & 0xffff,
|
||||
bdf.bus_number & 0xff,
|
||||
bdf.device_number & 0x1f,
|
||||
bdf.function_number & 0x7);
|
||||
|
||||
snprintf(bdf_str, 13, "%04" PRIx32 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32,
|
||||
static_cast<uint32_t>(bdf.domain_number & 0xffff),
|
||||
static_cast<uint32_t>(bdf.bus_number & 0xff),
|
||||
static_cast<uint32_t>(bdf.device_number & 0x1f),
|
||||
static_cast<uint32_t>(bdf.function_number & 0x7));
|
||||
|
||||
std::string path = "/proc/" + std::to_string(pid) + "/fdinfo/";
|
||||
std::string name_path = "/proc/" + std::to_string(pid) + "/comm";
|
||||
@@ -158,7 +158,7 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
|
||||
char fd_bdf_str[13];
|
||||
|
||||
/* Only check against fdinfo files that contain a bdf */
|
||||
if (sscanf(bdfline.c_str(), "drm-pdev: %s", &fd_bdf_str) != 1)
|
||||
if (sscanf(bdfline.c_str(), "drm-pdev: %s", &fd_bdf_str[0]) != 1)
|
||||
continue;
|
||||
|
||||
/* Populate amdsmi_proc_info_t struct only if the bdf in
|
||||
|
||||
@@ -63,8 +63,6 @@ void TestAPISupportRead::Close() {
|
||||
}
|
||||
|
||||
void TestAPISupportRead::Run(void) {
|
||||
amdsmi_status_t err;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
IF_VERB(STANDARD) {
|
||||
|
||||
@@ -100,7 +100,7 @@ void TestFanRead::Run(void) {
|
||||
err = amdsmi_get_gpu_fan_speed_max(processor_handles_[i], 0, &val_ui64);
|
||||
CHK_ERR_ASRT(err)
|
||||
IF_VERB(STANDARD) {
|
||||
std::cout << val_i64/static_cast<float>(val_ui64)*100;
|
||||
std::cout << static_cast<float>(val_i64)/static_cast<float>(val_ui64)*100;
|
||||
std::cout << "% ("<< val_i64 << "/" << val_ui64 << ")" << std::endl;
|
||||
}
|
||||
// Verify api support checking functionality is working
|
||||
|
||||
@@ -100,7 +100,7 @@ void TestFanReadWrite::Run(void) {
|
||||
ret = amdsmi_get_gpu_fan_speed_max(processor_handles_[dv_ind], 0, &max_speed);
|
||||
CHK_ERR_ASRT(ret)
|
||||
|
||||
new_speed = 1.1 * orig_speed;
|
||||
new_speed = static_cast<int64_t>(1.1F * static_cast<float>(orig_speed));
|
||||
|
||||
if (new_speed > static_cast<int64_t>(max_speed)) {
|
||||
std::cout <<
|
||||
@@ -135,8 +135,9 @@ void TestFanReadWrite::Run(void) {
|
||||
// cur_speed < 1.1 * new_speed) ||
|
||||
// cur_speed > 0.95 * AMDSMI_MAX_FAN_SPEED);
|
||||
IF_VERB(STANDARD) {
|
||||
if (!((cur_speed > 0.95 * new_speed && cur_speed < 1.1 * new_speed) ||
|
||||
(cur_speed > 0.95 * AMDSMI_MAX_FAN_SPEED))) {
|
||||
if (!((cur_speed > static_cast<int64_t>(0.95 * static_cast<double>(new_speed)) &&
|
||||
cur_speed < static_cast<int64_t>(1.10 * static_cast<double>(new_speed))) ||
|
||||
(cur_speed > static_cast<int64_t>(0.95 * AMDSMI_MAX_FAN_SPEED)))) {
|
||||
std::cout << "WARNING: Fan speed is not within the expected range!" <<
|
||||
std::endl;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,6 @@ void TestGPUBusyRead::Close() {
|
||||
|
||||
|
||||
void TestGPUBusyRead::Run(void) {
|
||||
amdsmi_status_t err;
|
||||
uint32_t val_ui32;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
std::cout << "** SetUp Failed for this test. Skipping.**" << std::endl;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@@ -477,8 +478,11 @@ void TestHWTopologyRead::Run(void) {
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("\tGPU BDF %04lx:%02x:%02x.%d\n", bdf.domain_number,
|
||||
bdf.bus_number, bdf.device_number, bdf.function_number);
|
||||
printf("\tGPU BDF %04" PRIx64 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32 "\n",
|
||||
static_cast<uint64_t>(bdf.domain_number),
|
||||
static_cast<uint32_t>(bdf.bus_number),
|
||||
static_cast<uint32_t>(bdf.device_number),
|
||||
static_cast<uint32_t>(bdf.function_number));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -67,7 +67,6 @@ void TestIdInfoRead::Run(void) {
|
||||
amdsmi_status_t err;
|
||||
uint16_t id;
|
||||
uint64_t val_ui64;
|
||||
uint32_t drm_render_minor;
|
||||
|
||||
char buffer[kBufferLen];
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ rsmi_test_refcount(uint64_t refcnt_type);
|
||||
|
||||
static void rand_sleep_mod(int msec) {
|
||||
assert(msec > 10);
|
||||
unsigned int seed = time(NULL);
|
||||
uint64_t seed = static_cast<uint64_t>(time(NULL));
|
||||
std::mt19937_64 eng{seed};
|
||||
std::uniform_int_distribution<> dist{10, msec};
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{dist(eng)});
|
||||
|
||||
@@ -117,7 +117,7 @@ void TestMemUtilRead::Run(void) {
|
||||
std::cout << "\t**" <<
|
||||
kDevMemoryTypeNameMap.at(static_cast<amdsmi_memory_type_t>(mem_type))
|
||||
<< " Calculated Utilization: " <<
|
||||
(static_cast<float>(usage)*100)/total << "% ("<< usage <<
|
||||
(static_cast<float>(usage)*100)/static_cast<float>(total) << "% ("<< usage <<
|
||||
"/" << total << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void TestMetricsCounterRead::Run(void) {
|
||||
std::cout << std::dec << "energy_accumulator counter="
|
||||
<< energy_accumulator << '\n';
|
||||
std::cout << "energy_accumulator in uJ="
|
||||
<< (double)(energy_accumulator * counter_resolution) << '\n';
|
||||
<< static_cast<double>((static_cast<double>(energy_accumulator) * counter_resolution)) << '\n';
|
||||
std::cout << std::dec << "timestamp="
|
||||
<< timestamp << '\n';
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ void TestMutualExclusion::Run(void) {
|
||||
// Set dummy values should to working, deterministic values.
|
||||
uint16_t dmy_ui16 = 0;
|
||||
uint32_t dmy_ui32 = 1;
|
||||
uint32_t dmy_i32 = 0;
|
||||
uint64_t dmy_ui64 = 0;
|
||||
int64_t dmy_i64 = 0;
|
||||
char dmy_str[10];
|
||||
|
||||
@@ -121,7 +121,7 @@ void TestPerfCntrReadWrite::CountEvents(amdsmi_processor_handle dv_ind,
|
||||
std::cout << "\t\t\tTime Enabled (nS): " << val->time_enabled << std::endl;
|
||||
std::cout << "\t\t\tTime Running (nS): " << val->time_running << std::endl;
|
||||
std::cout << "\t\t\tEvents/Second Running: " <<
|
||||
val->value/static_cast<float>(val->time_running) << std::endl;
|
||||
static_cast<float>(val->value)/static_cast<float>(val->time_running) << std::endl;
|
||||
}
|
||||
ret = amdsmi_gpu_destroy_counter(evt_handle);
|
||||
CHK_ERR_ASRT(ret)
|
||||
@@ -158,14 +158,14 @@ TestPerfCntrReadWrite::testEventsIndividually(amdsmi_processor_handle dv_ind) {
|
||||
|
||||
CountEvents(dv_ind, evt, &val, 1);
|
||||
double coll_time_sec = static_cast<double>(val.time_running)/kGig;
|
||||
throughput = (val.value * 32)/coll_time_sec;
|
||||
throughput = static_cast<uint64_t>(static_cast<double>((val.value * 32L))/coll_time_sec);
|
||||
std::cout << "\t\t\tCollected events for " << coll_time_sec <<
|
||||
" seconds" << std::endl;
|
||||
std::cout << "\t\t\tEvents collected: " << val.value << std::endl;
|
||||
std::cout << "\t\t\tXGMI throughput: " << throughput <<
|
||||
" bytes/second" << std::endl;
|
||||
std::cout << "\t\t\tXGMI Channel Utilization: " <<
|
||||
100*throughput/static_cast<double>(kVg20Level1Bandwidth*kGigByte) <<
|
||||
static_cast<double>(100*throughput)/static_cast<double>(kVg20Level1Bandwidth*kGigByte) <<
|
||||
"%" << std::endl;
|
||||
std::cout << "\t\t\t****" << std::endl;
|
||||
}
|
||||
|
||||
@@ -64,8 +64,6 @@ void TestPowerRead::Close() {
|
||||
|
||||
void TestPowerRead::Run(void) {
|
||||
amdsmi_status_t err;
|
||||
uint64_t val_ui64, val2_ui64;
|
||||
amdsmi_power_type_t type = AMDSMI_INVALID_POWER;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
|
||||
@@ -69,9 +69,7 @@ void TestSysInfoRead::Close() {
|
||||
void TestSysInfoRead::Run(void) {
|
||||
amdsmi_status_t err;
|
||||
uint64_t val_ui64;
|
||||
uint32_t val_ui32;
|
||||
int32_t val_i32;
|
||||
char buffer[80];
|
||||
amdsmi_version_t ver = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, nullptr};
|
||||
|
||||
TestBase::Run();
|
||||
|
||||
@@ -65,7 +65,6 @@ void TestXGMIReadWrite::Run(void) {
|
||||
GTEST_SKIP_("Temporarily disabled");
|
||||
amdsmi_status_t err;
|
||||
amdsmi_xgmi_status_t err_stat;
|
||||
uint64_t hive_id;
|
||||
|
||||
TestBase::Run();
|
||||
if (setup_failed_) {
|
||||
|
||||
Reference in New Issue
Block a user