Change device_handle to processor_handle
grep -rli 'device_handle' * | xargs -i@ sed -i 's/device_handle/processor_handle/g' @ Change-Id: Ifc8b7fa3b5488ce1fa8d8cf9eb3981a09450de11
This commit is contained in:
committed by
Naveen Krishna Chatradhi
parent
3963036a05
commit
3f9e4d95d4
@@ -76,7 +76,7 @@ Many of the functions in the library take a "socket handle" or "device handle".
|
||||
GPU device and CPU device on the same socket. Moreover, for MI200, it may have multiple GCDs.
|
||||
|
||||
To discover the sockets in the system, `amdsmi_get_socket_handles()` is called to get list of sockets
|
||||
handles, which in turn can be used to query the devices in that socket using `amdsmi_get_device_handles()`. The device handler is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different device handles after restart application, so a device handle should not be relied upon to be constant over process.
|
||||
handles, which in turn can be used to query the devices in that socket using `amdsmi_get_processor_handles()`. The device handler is used to distinguish the detected devices from one another. It is important to note that a device may end up with a different device handles after restart application, so a device handle should not be relied upon to be constant over process.
|
||||
|
||||
## Hello AMD SMI
|
||||
|
||||
@@ -116,20 +116,20 @@ int main() {
|
||||
|
||||
// Get the device count for the socket.
|
||||
uint32_t device_count = 0;
|
||||
ret = amdsmi_get_device_handles(sockets[i], &device_count, nullptr);
|
||||
ret = amdsmi_get_processor_handles(sockets[i], &device_count, nullptr);
|
||||
|
||||
// Allocate the memory for the device handlers on the socket
|
||||
std::vector<amdsmi_processor_handle> device_handles(device_count);
|
||||
std::vector<amdsmi_processor_handle> processor_handles(device_count);
|
||||
// Get all devices of the socket
|
||||
ret = amdsmi_get_device_handles(sockets[i],
|
||||
&device_count, &device_handles[0]);
|
||||
ret = amdsmi_get_processor_handles(sockets[i],
|
||||
&device_count, &processor_handles[0]);
|
||||
|
||||
// For each device of the socket, get name and temperature.
|
||||
for (uint32_t j=0; j < device_count; j++) {
|
||||
// Get device type. Since the amdsmi is initialized with
|
||||
// AMD_SMI_INIT_AMD_GPUS, the device_type must be AMD_GPU.
|
||||
device_type_t device_type;
|
||||
ret = amdsmi_get_device_type(device_handles[j], &device_type);
|
||||
ret = amdsmi_get_device_type(processor_handles[j], &device_type);
|
||||
if (device_type != AMD_GPU) {
|
||||
std::cout << "Expect AMD_GPU device type!\n";
|
||||
return 1;
|
||||
@@ -137,13 +137,13 @@ int main() {
|
||||
|
||||
// Get device name
|
||||
amdsmi_board_info_t board_info;
|
||||
ret = amdsmi_get_board_info(device_handles[j], &board_info);
|
||||
ret = amdsmi_get_board_info(processor_handles[j], &board_info);
|
||||
std::cout << "\tdevice "
|
||||
<< j <<"\n\t\tName:" << board_info.product_name << std::endl;
|
||||
|
||||
// Get temperature
|
||||
int64_t val_i64 = 0;
|
||||
ret = amdsmi_dev_get_temp_metric(device_handles[j], TEMPERATURE_TYPE_EDGE,
|
||||
ret = amdsmi_dev_get_temp_metric(processor_handles[j], TEMPERATURE_TYPE_EDGE,
|
||||
AMDSMI_TEMP_CURRENT, &val_i64);
|
||||
std::cout << "\t\tTemperature: " << val_i64 << "C" << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user