Updated esmi error checking for graceful return
Change-Id: I1bcd498e3482dc7acd92b1a762f892b3dd978ff2
This commit is contained in:
کامیت شده توسط
Deepak Mewar
والد
f96c7663b5
کامیت
14cf5f2762
@@ -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<amdsmi_cpusocket_handle> sockets(socket_count);
|
||||
vector<amdsmi_cpusocket_handle> 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<amdsmi_processor_handle> processor_handles(core_count);
|
||||
vector<amdsmi_processor_handle> 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["<<i<<"] core clock current frequency limit (MHz) : "<<c_clk<<"\t|\n";
|
||||
cout<<"--------------------------------------------------------------\n";
|
||||
#endif
|
||||
|
||||
uint32_t power;
|
||||
cout<<"\n-------------------------------------------------";
|
||||
@@ -310,7 +308,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
|
||||
#if 0
|
||||
uint8_t mode;
|
||||
const char *err_str;
|
||||
cout <<"Enter the power efficiency mode to be set[0, 1 or 2]:\n";
|
||||
@@ -329,7 +326,6 @@ int main(int argc, char **argv) {
|
||||
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
|
||||
|
||||
uint32_t svi_power;
|
||||
cout<<"\n| SVI Power Telemetry (mWatts) \t |";
|
||||
|
||||
@@ -343,7 +339,6 @@ int main(int argc, char **argv) {
|
||||
cout<<" NA (Err:" <<ret<<" |";
|
||||
}
|
||||
cout<<"\n-------------------------------------------------\n";
|
||||
#endif
|
||||
}
|
||||
// Clean up resources allocated at amdsmi_init
|
||||
ret = amdsmi_shut_down();
|
||||
|
||||
@@ -4246,9 +4246,9 @@ amdsmi_status_t amdsmi_first_online_core_on_cpu_socket(amdsmi_cpusocket_handle s
|
||||
* @param[in,out] status_string - A pointer to a const char * which will be made
|
||||
* to point to a description of the provided error code
|
||||
*
|
||||
* @return const char* returned on success
|
||||
* @return const char** returned on 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);
|
||||
#endif
|
||||
/** @} */
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -2738,7 +2738,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 +2746,6 @@ const char* amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_
|
||||
break;
|
||||
}
|
||||
}
|
||||
return *status_string;
|
||||
return status_string;
|
||||
}
|
||||
#endif
|
||||
|
||||
مرجع در شماره جدید
Block a user