diff --git a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py index c157d7141a..12b3fb4cd8 100644 --- a/projects/amdsmi/amdsmi_cli/amdsmi_commands.py +++ b/projects/amdsmi/amdsmi_cli/amdsmi_commands.py @@ -678,11 +678,13 @@ class AMDSMICommands(): args.iterations = iterations if fb_usage: args.fb_usage = fb_usage - if replay_count: - args.replay_count = replay_count if mem_usage: args.mem_usage = mem_usage + if not self.helpers.is_virtual_os(): + if replay_count: + args.replay_count = replay_count + if self.helpers.is_linux() and self.helpers.is_baremetal(): if usage: args.usage = usage @@ -753,8 +755,8 @@ class AMDSMICommands(): # Check if any of the options have been set, if not then set them all to true if self.helpers.is_linux() and self.helpers.is_virtual_os(): - if not any([args.fb_usage, args.replay_count, args.mem_usage]): - args.fb_usage = args.replay_count = args.mem_usage = self.all_arguments = True + if not any([args.fb_usage, args.mem_usage]): + args.fb_usage = args.mem_usage = self.all_arguments = True if self.helpers.is_linux() and self.helpers.is_baremetal(): if not any([args.usage, args.fb_usage, args.power, args.clock, args.temperature, @@ -788,6 +790,7 @@ class AMDSMICommands(): values_dict['usage'] = e.get_error_info() if not self.all_arguments: raise e + if args.fb_usage: try: vram_usage = amdsmi_interface.amdsmi_get_gpu_vram_usage(args.gpu) @@ -923,7 +926,6 @@ class AMDSMICommands(): values_dict['ecc'] = e.get_error_info() if not self.all_arguments: raise e - if args.ecc_block: ecc_dict = {} try: @@ -1042,14 +1044,17 @@ class AMDSMICommands(): values_dict['perf_level'] = e.get_error_info() if not self.all_arguments: raise e - if args.replay_count: - try: - pci_replay_counter = amdsmi_interface.amdsmi_get_gpu_pci_replay_counter(args.gpu) - values_dict['replay_count'] = pci_replay_counter - except amdsmi_exception.AmdSmiLibraryException as e: - values_dict['replay_count'] = e.get_error_info() - if not self.all_arguments: - raise e + + if not self.helpers.is_virtual_os(): + if args.replay_count: + try: + pci_replay_counter = amdsmi_interface.amdsmi_get_gpu_pci_replay_counter(args.gpu) + values_dict['replay_count'] = pci_replay_counter + except amdsmi_exception.AmdSmiLibraryException as e: + values_dict['replay_count'] = e.get_error_info() + if not self.all_arguments: + raise e + if self.helpers.is_linux() and self.helpers.is_baremetal(): if args.xgmi_err: try: @@ -1061,6 +1066,7 @@ class AMDSMICommands(): raise e if args.energy: pass + if args.mem_usage: memory_total = {} try: diff --git a/projects/amdsmi/example/amd_smi_drm_example.cc b/projects/amdsmi/example/amd_smi_drm_example.cc index 94c7dbc49e..09e4b72eb3 100644 --- a/projects/amdsmi/example/amd_smi_drm_example.cc +++ b/projects/amdsmi/example/amd_smi_drm_example.cc @@ -621,7 +621,7 @@ int main() { << "\n\n"; // Get frame buffer - amdsmi_vram_info_t vram_usage = {}; + amdsmi_vram_usage_t vram_usage = {}; ret = amdsmi_get_gpu_vram_usage(processor_handles[j], &vram_usage); CHK_AMDSMI_RET(ret) printf(" Output of amdsmi_get_gpu_vram_usage:\n"); diff --git a/projects/amdsmi/example/amd_smi_nodrm_example.cc b/projects/amdsmi/example/amd_smi_nodrm_example.cc index 0c82b81178..2650beed8f 100644 --- a/projects/amdsmi/example/amd_smi_nodrm_example.cc +++ b/projects/amdsmi/example/amd_smi_nodrm_example.cc @@ -305,7 +305,7 @@ int main() { << "\n\n"; // Get frame buffer - amdsmi_vram_info_t vram_usage = {}; + amdsmi_vram_usage_t vram_usage = {}; ret = amdsmi_get_gpu_vram_usage(processor_handles[j], &vram_usage); CHK_AMDSMI_RET(ret) printf(" Output of amdsmi_get_gpu_vram_usage:\n"); diff --git a/projects/amdsmi/example/amdsmi_esmi_intg_example.cc b/projects/amdsmi/example/amdsmi_esmi_intg_example.cc index bc84b7a73d..363124bb01 100644 --- a/projects/amdsmi/example/amdsmi_esmi_intg_example.cc +++ b/projects/amdsmi/example/amdsmi_esmi_intg_example.cc @@ -60,10 +60,10 @@ using namespace std; if (RET != AMDSMI_STATUS_SUCCESS) { \ const char *err_str; \ const char **status_str; \ - std::cout << "AMDSMI call returned " << RET << " at line " \ - << __LINE__ << std::endl; \ - *status_str = amdsmi_get_esmi_err_msg(RET, &err_str); \ - std::cout << *status_str << std::endl; \ + cout << "AMDSMI call returned " << RET << " at line " \ + << __LINE__ << endl; \ + status_str = amdsmi_get_esmi_err_msg(RET, &err_str); \ + cout << *status_str << endl; \ return RET; \ } \ } @@ -85,13 +85,13 @@ int main(int argc, char **argv) { CHK_AMDSMI_RET(ret) // Allocate the memory for the sockets - std::vector sockets(socket_count); + vector sockets(socket_count); // Get the sockets of the system ret = amdsmi_get_cpusocket_handles(&socket_count, &sockets[0]); CHK_AMDSMI_RET(ret) - std::cout << "Total Socket: " << socket_count << std::endl; + cout << "Total Socket: " << socket_count << endl; // For each socket, get identifier and cores for (uint32_t i = 0; i < socket_count; i++) { @@ -99,7 +99,7 @@ int main(int argc, char **argv) { uint32_t socket_info; ret = amdsmi_get_cpusocket_info(sockets[i], socket_info); CHK_AMDSMI_RET(ret) - std::cout << "Socket " << socket_info << std::endl; + cout << "Socket " << socket_info << endl; // Get the core count available for the socket. uint32_t core_count = 0; @@ -107,12 +107,12 @@ int main(int argc, char **argv) { CHK_AMDSMI_RET(ret) // Allocate the memory for the cpu core handles on the socket - std::vector processor_handles(core_count); + vector processor_handles(core_count); // Get all cores of the socket ret = amdsmi_get_cpucore_handles(sockets[i], &core_count, &processor_handles[0]); CHK_AMDSMI_RET(ret) - std::cout << "core_count=" << core_count << std::endl; + cout << "core_count=" << core_count << endl; ret = amdsmi_get_cpu_hsmp_proto_ver(sockets[i], &proto_ver); CHK_AMDSMI_RET(ret) @@ -235,7 +235,6 @@ int main(int argc, char **argv) { } cout<<"\n-------------------------------------------------\n"; -#if 0 uint32_t c_clk = 0; ret = amdsmi_get_cpu_core_current_freq_limit(processor_handles[i], i, &c_clk); CHK_AMDSMI_RET(ret) @@ -243,7 +242,6 @@ int main(int argc, char **argv) { cout<<"--------------------------------------------------------------"; cout<<"\n| CPU["<vram_type = VRAM_TYPE_UNKNOWN; + info->vram_size_mb = 0; + info->vram_vendor = AMDSMI_VRAM_VENDOR__PLACEHOLDER0; + + // Only can read vram type from libdrm + if (gpu_device->check_if_drm_is_supported()) { + struct drm_amdgpu_info_device dev_info = {}; + r = gpu_device->amdgpu_query_info( + AMDGPU_INFO_DEV_INFO, + sizeof(struct drm_amdgpu_info_device), &dev_info); + if (r == AMDSMI_STATUS_SUCCESS) { + info->vram_type = static_cast( + dev_info.vram_type); + } + } + + // map the vendor name to enum + char brand[256]; + r = rsmi_wrapper(rsmi_dev_vram_vendor_get, processor_handle, brand, 255); + if (r == AMDSMI_STATUS_SUCCESS) { + if (strcasecmp(brand, "SAMSUNG") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__SAMSUNG; + if (strcasecmp(brand, "INFINEON") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__INFINEON; + if (strcasecmp(brand, "ELPIDA") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__ELPIDA; + if (strcasecmp(brand, "ETRON") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__ETRON; + if (strcasecmp(brand, "NANYA") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__NANYA; + if (strcasecmp(brand, "HYNIX") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__HYNIX; + if (strcasecmp(brand, "MOSEL") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__MOSEL; + if (strcasecmp(brand, "WINBOND") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__WINBOND; + if (strcasecmp(brand, "ESMT") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__ESMT; + if (strcasecmp(brand, "MICRON") == 0) + info->vram_vendor = AMDSMI_VRAM_VENDOR__MICRON; + } + uint64_t total = 0; + r = rsmi_wrapper(rsmi_dev_memory_total_get, processor_handle, + RSMI_MEM_TYPE_VRAM, &total); + info->vram_size_mb = total; + + return AMDSMI_STATUS_SUCCESS; +} + amdsmi_status_t amdsmi_init_gpu_event_notification(amdsmi_processor_handle processor_handle) { return rsmi_wrapper(rsmi_event_notification_init, processor_handle); @@ -2738,7 +2802,7 @@ amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_cpusocket_handle s return AMDSMI_STATUS_SUCCESS; } -const char* amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string) +const char** 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) { @@ -2746,6 +2810,6 @@ const char* amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_ break; } } - return *status_string; + return status_string; } #endif diff --git a/projects/amdsmi/tests/amd_smi_test/functional/id_info_read.cc b/projects/amdsmi/tests/amd_smi_test/functional/id_info_read.cc index c22f127ac0..35345ffd18 100755 --- a/projects/amdsmi/tests/amd_smi_test/functional/id_info_read.cc +++ b/projects/amdsmi/tests/amd_smi_test/functional/id_info_read.cc @@ -145,6 +145,19 @@ void TestIdInfoRead::Run(void) { } } + + amdsmi_vram_info_t vram_info; + err = amdsmi_get_gpu_vram_info(processor_handles_[i], &vram_info); + CHK_ERR_ASRT(err) + IF_VERB(STANDARD) { + std::cout << "\t**Device Vram type id: " + << vram_info.vram_type << std::endl; + std::cout << "\t**Device Vram vendor id: " + << vram_info.vram_vendor << std::endl; + std::cout << "\t**Device Vram size: " + << vram_info.vram_size_mb << std::endl; + } + err = amdsmi_get_gpu_vendor_name(processor_handles_[i], buffer, kBufferLen); if (err == AMDSMI_STATUS_NOT_SUPPORTED) { std::cout << "\t**Device Vendor name string not found on this system." <<