Processor Discovery

Processor Discovery#

AMD SMI: Processor Discovery
Processor Discovery

Functions

amdsmi_status_t amdsmi_get_processor_handles (amdsmi_socket_handle socket_handle, uint32_t *processor_count, amdsmi_processor_handle *processor_handles)
 Returns a list of AMD GPU devices in the system. More...
 
amdsmi_status_t amdsmi_get_processor_type (amdsmi_processor_handle processor_handle, processor_type_t *processor_type)
 Get the processor type. More...
 
amdsmi_status_t amdsmi_get_socket_handles (uint32_t *socket_count, amdsmi_socket_handle *socket_handles)
 Returns a list of socket handles in the system. NOT SUPPORTED YET, CURRENTLY HARDCODED TO RETURN EMPTY LIST. More...
 
amdsmi_status_t amdsmi_get_socket_info (amdsmi_socket_handle socket_handle, size_t len, char *name)
 Returns socket information about given socket handle NOT SUPPORTED YET, CURRENTLY HARDCODED TO RETURN EMPTY VALUES. More...
 
amdsmi_status_t amdsmi_get_processor_handle_from_bdf (amdsmi_bdf_t bdf, amdsmi_processor_handle *processor_handle)
 Returns processor handle (PF) from the given BDF. More...
 
amdsmi_status_t amdsmi_get_index_from_processor_handle (amdsmi_processor_handle processor_handle, uint32_t *processor_index)
 Returns the index of the given processor handle. More...
 
amdsmi_status_t amdsmi_get_vf_handle_from_bdf (amdsmi_bdf_t bdf, amdsmi_vf_handle_t *vf_handle)
 Returns VF handle from the given BDF. More...
 
amdsmi_status_t amdsmi_get_gpu_device_bdf (amdsmi_processor_handle processor_handle, amdsmi_bdf_t *bdf)
 Returns BDF of the given processor (PF or VF). More...
 
amdsmi_status_t amdsmi_get_processor_handle_from_index (uint32_t processor_index, amdsmi_processor_handle *processor_handle)
 Returns the processor handle from the given processor index. More...
 
amdsmi_status_t amdsmi_get_vf_bdf (amdsmi_vf_handle_t vf_handle, amdsmi_bdf_t *bdf)
 Returns BDF of the given device (VF). More...
 
amdsmi_status_t amdsmi_get_vf_handle_from_vf_index (amdsmi_processor_handle processor_handle, uint32_t fcn_idx, amdsmi_vf_handle_t *vf_handle)
 Returns the handle of a virtual function given its index. More...
 
amdsmi_status_t amdsmi_get_vf_handle_from_uuid (const char *uuid, amdsmi_vf_handle_t *vf_handle)
 Returns the handle of a virtual function from the given UUID. More...
 
amdsmi_status_t amdsmi_get_processor_handle_from_uuid (const char *uuid, amdsmi_processor_handle *processor_handle)
 Returns the processor handle from the given UUID. More...
 
amdsmi_status_t amdsmi_get_gpu_device_uuid (amdsmi_processor_handle processor_handle, unsigned int *uuid_length, char *uuid)
 Returns the UUID of the processor. More...
 
amdsmi_status_t amdsmi_get_vf_uuid (amdsmi_vf_handle_t processor_handle, unsigned int *uuid_length, char *uuid)
 Returns the UUID of the VF. More...
 
amdsmi_status_t amdsmi_get_gpu_virtualization_mode (amdsmi_processor_handle processor_handle, amdsmi_virtualization_mode_t *mode)
 Returns the virtualization mode for the target device. More...
 
amdsmi_status_t amdsmi_get_cpu_affinity_with_scope (amdsmi_processor_handle processor_handle, uint32_t cpu_set_size, uint64_t *cpu_set, amdsmi_affinity_scope_t scope)
 Retrieves an array of uint64_t (sized to cpu_set_size) of bitmasks with the affinity within numa node or socket for the device. More...
 

Detailed Description

Function Documentation

◆ amdsmi_get_processor_handles()

amdsmi_status_t amdsmi_get_processor_handles ( amdsmi_socket_handle  socket_handle,
uint32_t *  processor_count,
amdsmi_processor_handle *  processor_handles 
)

Returns a list of AMD GPU devices in the system.

Note
This function fills the user-provided buffer with GPU device handles. The processor handles returned are used to instantiate the rest of processor queries in the library. If the buffer is not large enough the call will fail.
Parameters
[in]socket_handleThe socket to query.
[in,out]processor_countAs input, the size of the provided buffer. As output, number of processor handles in the buffer. Parameter must be allocated by user.
[out]processor_handlesReference to list of processor handles returned by the library. Buffer must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_processor_type()

amdsmi_status_t amdsmi_get_processor_type ( amdsmi_processor_handle  processor_handle,
processor_type_t *  processor_type 
)

Get the processor type.

Given a processor handle processor_handle, this function will get its processor type.

Parameters
[in]processor_handlea processor handle
[out]processor_typea pointer to processor_type_t to which the processor 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_socket_handles()

amdsmi_status_t amdsmi_get_socket_handles ( uint32_t *  socket_count,
amdsmi_socket_handle socket_handles 
)

Returns a list of socket handles in the system. NOT SUPPORTED YET, CURRENTLY HARDCODED TO RETURN EMPTY LIST.

Parameters
[in,out]socket_countAs input, the size of the provided buffer. As output, number of socket handles in the buffer. Parameter must be allocated by user.
[out]socket_handlesReference to list of socket handles returned by the library. Buffer must be allocated by user.
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,
size_t  len,
char *  name 
)

Returns socket information about given socket handle NOT SUPPORTED YET, CURRENTLY HARDCODED TO RETURN EMPTY VALUES.

Parameters
[in]socket_handlesocket for which to query
[in]lensize of the allocated character array for the name of the socket
[out]nameReference to character array representing name of the socket returned by the library. Character array must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_processor_handle_from_bdf()

amdsmi_status_t amdsmi_get_processor_handle_from_bdf ( amdsmi_bdf_t  bdf,
amdsmi_processor_handle *  processor_handle 
)

Returns processor handle (PF) from the given BDF.

Parameters
[in]bdfBDF of the processor
[out]processor_handleReference to the processor handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_index_from_processor_handle()

amdsmi_status_t amdsmi_get_index_from_processor_handle ( amdsmi_processor_handle  processor_handle,
uint32_t *  processor_index 
)

Returns the index of the given processor handle.

Parameters
[in]processor_handleProcessor handle for which to query
[out]processor_indexPointer to integer to store the processor index. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_vf_handle_from_bdf()

amdsmi_status_t amdsmi_get_vf_handle_from_bdf ( amdsmi_bdf_t  bdf,
amdsmi_vf_handle_t vf_handle 
)

Returns VF handle from the given BDF.

Parameters
[in]bdfBDF of the VF
[out]vf_handleReference to the VF handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_gpu_device_bdf()

amdsmi_status_t amdsmi_get_gpu_device_bdf ( amdsmi_processor_handle  processor_handle,
amdsmi_bdf_t bdf 
)

Returns BDF of the given processor (PF or VF).

Parameters
[in]processor_handlePF or VF for which to query
[out]bdfReference to BDF. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_processor_handle_from_index()

amdsmi_status_t amdsmi_get_processor_handle_from_index ( uint32_t  processor_index,
amdsmi_processor_handle *  processor_handle 
)

Returns the processor handle from the given processor index.

Parameters
[in]processor_indexFunction processor_index to query
[out]processor_handleReference to the processor handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_vf_bdf()

amdsmi_status_t amdsmi_get_vf_bdf ( amdsmi_vf_handle_t  vf_handle,
amdsmi_bdf_t bdf 
)

Returns BDF of the given device (VF).

Parameters
[in]vf_handleVF for which to query
[out]bdfReference to BDF. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_vf_handle_from_vf_index()

amdsmi_status_t amdsmi_get_vf_handle_from_vf_index ( amdsmi_processor_handle  processor_handle,
uint32_t  fcn_idx,
amdsmi_vf_handle_t vf_handle 
)

Returns the handle of a virtual function given its index.

Parameters
[in]processor_handlePF of a processor for which to query
[in]fcn_idxFunction index to query
[out]vf_handleVF handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_vf_handle_from_uuid()

amdsmi_status_t amdsmi_get_vf_handle_from_uuid ( const char *  uuid,
amdsmi_vf_handle_t vf_handle 
)

Returns the handle of a virtual function from the given UUID.

Parameters
[in]uuidFunction UUID to query.
[out]vf_handleReference to the VF handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_processor_handle_from_uuid()

amdsmi_status_t amdsmi_get_processor_handle_from_uuid ( const char *  uuid,
amdsmi_processor_handle *  processor_handle 
)

Returns the processor handle from the given UUID.

Parameters
[in]uuidFunction UUID to query.
[out]processor_handleReference to the processor handle. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_gpu_device_uuid()

amdsmi_status_t amdsmi_get_gpu_device_uuid ( amdsmi_processor_handle  processor_handle,
unsigned int *  uuid_length,
char *  uuid 
)

Returns the UUID of the processor.

Parameters
[in]processor_handlePF for which to query
[in,out]uuid_lengthLength of the uuid string. As inpout, must be equal or greater than AMDSMI_GPU_UUID_SIZE and be allocated by user. As output it is the length of the uuid string.
[out]uuidPointer to string to store the UUID. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_vf_uuid()

amdsmi_status_t amdsmi_get_vf_uuid ( amdsmi_vf_handle_t  processor_handle,
unsigned int *  uuid_length,
char *  uuid 
)

Returns the UUID of the VF.

Parameters
[in]processor_handleVF for which to query
[in,out]uuid_lengthLength of the uuid string. As inpout, must be equal or greater than AMDSMI_GPU_UUID_SIZE and be allocated by user. As output it is the length of the uuid string.
[out]uuidPointer to string to store the UUID. Must be allocated by user.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_gpu_virtualization_mode()

amdsmi_status_t amdsmi_get_gpu_virtualization_mode ( amdsmi_processor_handle  processor_handle,
amdsmi_virtualization_mode_t *  mode 
)

Returns the virtualization mode for the target device.

Platform:

gpu_bm_linux

guest_1vf

host

Parameters
[in]processor_handlePF of a processor for which to query.
[out]modeReference to the enum representing virtualization mode.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail

◆ amdsmi_get_cpu_affinity_with_scope()

amdsmi_status_t amdsmi_get_cpu_affinity_with_scope ( amdsmi_processor_handle  processor_handle,
uint32_t  cpu_set_size,
uint64_t *  cpu_set,
amdsmi_affinity_scope_t  scope 
)

Retrieves an array of uint64_t (sized to cpu_set_size) of bitmasks with the affinity within numa node or socket for the device.

Platform:
gpu_bm_linux {host}

Given a processor handle processor_handle, the size of the cpu_set array cpu_set_size, and a pointer to an array of int64_t cpu_set, and scope, this function will write the CPU affinity bitmask to the array pointed to by cpu_set.

User must allocate the enough memory for the cpu_set array. The size of the array is determined by the number of CPU cores in the system. As an example, if there are 2 CPUs and each has 112 cores, the size should be ceiling(2*112/64) = 4, where 64 is the bits of uint64_t. The function will write the CPU affinity bitmask to the array. For example, to describe the CPU cores 0-55,112-167, it will set the 0-55 and 112-167 bits to 1 and the reset of bits to 0 in the cpu_set array.

Parameters
[in]processor_handlea processor handle
[in]cpu_set_sizeThe size of the cpu_set array that is safe to access
[in,out]cpu_setArray reference in which to return a bitmask of CPU cores that this processor affinities with.
[in]scopeScope for socket or numa affinity.
Returns
amdsmi_status_t | AMDSMI_STATUS_SUCCESS on success, non-zero on fail