Change the get_socket_handles and get_device_handles APIs interface

Those two APIs are changed to let the user get the handles count,
allocate memory, and then return handles to the allocated memory.

Change-Id: Ibe28a89ad188c99da6af3af1740b2b25ff22ba06


[ROCm/amdsmi commit: 2b2d11c446]
Cette révision appartient à :
Bill(Shuzhou) Liu
2022-10-07 10:35:26 -05:00
Parent bd4ff14bd0
révision b546e272e0
9 fichiers modifiés avec 175 ajouts et 95 suppressions
+22 -9
Voir le fichier
@@ -73,24 +73,37 @@ int main() {
// Get all sockets
uint32_t socket_count = 0;
amdsmi_socket_handle *sockets = nullptr;
ret = amdsmi_get_socket_handles(&socket_count, &sockets);
// Get the socket count available for the system.
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
CHK_AMDSMI_RET(ret)
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the sockets of the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
CHK_AMDSMI_RET(ret)
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get identifier and devices
for (uint32_t i = 0; i < socket_count; i++) {
// Get Socket info
char socket_name[128];
ret = amdsmi_get_socket_info(sockets[i], socket_name, 128);
char socket_info[128];
ret = amdsmi_get_socket_info(sockets[i], socket_info, 128);
CHK_AMDSMI_RET(ret)
std::cout << "Socket " << socket_name << std::endl;
std::cout << "Socket " << socket_info << std::endl;
// Get all devices of the socket
// Get the device count available for the socket.
uint32_t device_count = 0;
amdsmi_device_handle *device_handles = nullptr;
ret = amdsmi_get_device_handles(sockets[i], &device_count,
&device_handles);
ret = amdsmi_get_device_handles(sockets[i], &device_count, nullptr);
CHK_AMDSMI_RET(ret)
// Allocate the memory for the device handlers on the socket
std::vector<amdsmi_device_handle> device_handles(device_count);
// Get all devices of the socket
ret = amdsmi_get_device_handles(sockets[i],
&device_count, &device_handles[0]);
CHK_AMDSMI_RET(ret)
// For each device of the socket, get name and temperature.
+22 -9
Voir le fichier
@@ -73,24 +73,37 @@ int main() {
// Get all sockets
uint32_t socket_count = 0;
amdsmi_socket_handle *sockets = nullptr;
ret = amdsmi_get_socket_handles(&socket_count, &sockets);
// Get the socket count available for the system.
ret = amdsmi_get_socket_handles(&socket_count, nullptr);
CHK_AMDSMI_RET(ret)
// Allocate the memory for the sockets
std::vector<amdsmi_socket_handle> sockets(socket_count);
// Get the sockets of the system
ret = amdsmi_get_socket_handles(&socket_count, &sockets[0]);
CHK_AMDSMI_RET(ret)
std::cout << "Total Socket: " << socket_count << std::endl;
// For each socket, get identifier and devices
for (uint32_t i = 0; i < socket_count; i++) {
// Get Socket info
char socket_name[128];
ret = amdsmi_get_socket_info(sockets[i], socket_name, 128);
char socket_info[128];
ret = amdsmi_get_socket_info(sockets[i], socket_info, 128);
CHK_AMDSMI_RET(ret)
std::cout << "Socket " << socket_name << std::endl;
std::cout << "Socket " << socket_info << std::endl;
// Get all devices of the socket
// Get the device count available for the socket.
uint32_t device_count = 0;
amdsmi_device_handle *device_handles = nullptr;
ret = amdsmi_get_device_handles(sockets[i], &device_count,
&device_handles);
ret = amdsmi_get_device_handles(sockets[i], &device_count, nullptr);
CHK_AMDSMI_RET(ret)
// Allocate the memory for the device handlers on the socket
std::vector<amdsmi_device_handle> device_handles(device_count);
// Get all devices of the socket
ret = amdsmi_get_device_handles(sockets[i],
&device_count, &device_handles[0]);
CHK_AMDSMI_RET(ret)
// For each device of the socket, get name and temperature.