Discovery Queries

Discovery Queries#

AMD SMI: Discovery Queries
Discovery Queries

Functions

amdsmi_status_t amdsmi_get_socket_handles (uint32_t *socket_count, amdsmi_socket_handle *socket_handles)
 Get the list of socket handles in the system. More...
 
amdsmi_status_t amdsmi_get_socket_info (amdsmi_socket_handle socket_handle, char *name, size_t len)
 Get information about the given socket. More...
 
amdsmi_status_t amdsmi_get_device_handles (amdsmi_socket_handle socket_handle, uint32_t *device_count, amdsmi_device_handle *device_handles)
 Get the list of the device handles associated to a socket. More...
 
amdsmi_status_t amdsmi_get_device_type (amdsmi_device_handle device_handle, device_type_t *device_type)
 Get the device type of the device_handle. More...
 
amdsmi_status_t amdsmi_get_device_handle_from_bdf (amdsmi_bdf_t bdf, amdsmi_device_handle *device_handle)
 Get device handle with the matching bdf. More...
 

Detailed Description

These functions provide discovery of the sockets.

Function Documentation

◆ amdsmi_get_socket_handles()

amdsmi_status_t amdsmi_get_socket_handles ( uint32_t *  socket_count,
amdsmi_socket_handle *  socket_handles 
)

Get the list of socket handles in the system.

Depends on what flag is passed to amdsmi_init. AMDSMI_INIT_AMD_GPUS returns sockets with AMD GPUS, and AMDSMI_INIT_AMD_GPUS | AMDSMI_INIT_AMD_CPUS returns sockets with either AMD GPUS or CPUS. The socket handles can be used to query the device handles in that socket, which will be used in other APIs to get device detail information or telemtries.

Parameters
[in,out]socket_countAs input, the value passed through this parameter is the number of ::amdsmi_socket_handle that may be safely written to the memory pointed to by socket_handles. This is the limit on how many socket handles will be written to socket_handles. On return, socket_count will contain the number of socket handles written to socket_handles, or the number of socket handles that could have been written if enough memory had been provided. If socket_handles is NULL, as output, socket_count will contain how many sockets are available to read in the system.
[in,out]socket_handlesA pointer to a block of memory to which the ::amdsmi_socket_handle values will be written. This value may be NULL. In this case, this function can be used to query how many sockets are available to read in the system.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_socket_info()

amdsmi_status_t amdsmi_get_socket_info ( amdsmi_socket_handle  socket_handle,
char *  name,
size_t  len 
)

Get information about the given socket.

This function retrieves socket information. The socket_handle must be provided to retrieve the Socket ID.

Parameters
[in]socket_handlea socket handle
[out]nameThe id of the socket.
[in]lenthe length of the caller provided buffer name.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_device_handles()

amdsmi_status_t amdsmi_get_device_handles ( amdsmi_socket_handle  socket_handle,
uint32_t *  device_count,
amdsmi_device_handle device_handles 
)

Get the list of the device handles associated to a socket.

This function retrieves the device handles of a socket. The socket_handle must be provided for the device. A socket may have mulitple different type devices: An APU on a socket have both CPUs and GPUs. Currently, only AMD GPUs are supported.

The number of device count is returned through device_count if device_handles is NULL. Then the number of device_count can be pass as input to retrieval all devices on the socket to device_handles.

Parameters
[in]socket_handleThe socket to query
[in,out]device_countAs input, the value passed through this parameter is the number of amdsmi_device_handle's that may be safely written to the memory pointed to by device_handles. This is the limit on how many device handles will be written to device_handles. On return, device_count will contain the number of device handles written to device_handles, or the number of device handles that could have been written if enough memory had been provided. If device_handles is NULL, as output, device_count will contain how many devices are available to read for the socket.
[in,out]device_handlesA pointer to a block of memory to which the amdsmi_device_handle values will be written. This value may be NULL. In this case, this function can be used to query how many devices are available to read.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_device_type()

amdsmi_status_t amdsmi_get_device_type ( amdsmi_device_handle  device_handle,
device_type_t device_type 
)

Get the device type of the device_handle.

This function retrieves the device type. A device_handle must be provided for that device.

Parameters
[in]device_handlea device handle
[out]device_typea pointer to device_type_t to which the device type will be written. If this parameter is nullptr, this function will return AMDSMI_STATUS_INVAL.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_device_handle_from_bdf()

amdsmi_status_t amdsmi_get_device_handle_from_bdf ( amdsmi_bdf_t  bdf,
amdsmi_device_handle device_handle 
)

Get device handle with the matching bdf.

Given bdf info bdf, this function will get the device handle with the matching bdf.

Parameters
[in]bdfThe bdf to match with corresponding device handle.
[out]device_handledevice handle with the matching bdf.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail