Change device_type to processor_type
also rename amdsmi_get_device_type to amdsmi_get_processor_type grep -rli 'device_type' * | xargs -i@ sed -i 's/device_type/processor_type/g' @ Change-Id: Ic6a73c1a170757d5ab5d10ad20b4fc2f0b280e78
Этот коммит содержится в:
коммит произвёл
Naveen Krishna Chatradhi
родитель
3f9e4d95d4
Коммит
dd00a16124
+4
-4
@@ -127,10 +127,10 @@ int main() {
|
||||
// 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(processor_handles[j], &device_type);
|
||||
if (device_type != AMD_GPU) {
|
||||
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMD_GPU.
|
||||
processor_type_t processor_type;
|
||||
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
|
||||
if (processor_type != AMD_GPU) {
|
||||
std::cout << "Expect AMD_GPU device type!\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -257,11 +257,11 @@ int main() {
|
||||
// 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(processor_handles[j], &device_type);
|
||||
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMD_GPU.
|
||||
processor_type_t processor_type = {};
|
||||
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
if (device_type != AMD_GPU) {
|
||||
if (processor_type != AMD_GPU) {
|
||||
std::cout << "Expect AMD_GPU device type!\n";
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
@@ -109,11 +109,11 @@ int main() {
|
||||
// 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(processor_handles[j], &device_type);
|
||||
// AMD_SMI_INIT_AMD_GPUS, the processor_type must be AMD_GPU.
|
||||
processor_type_t processor_type = {};
|
||||
ret = amdsmi_get_processor_type(processor_handles[j], &processor_type);
|
||||
CHK_AMDSMI_RET(ret)
|
||||
if (device_type != AMD_GPU) {
|
||||
if (processor_type != AMD_GPU) {
|
||||
std::cout << "Expect AMD_GPU device type!\n";
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ typedef enum {
|
||||
AMD_CPU,
|
||||
NON_AMD_GPU,
|
||||
NON_AMD_CPU
|
||||
} device_type_t;
|
||||
} processor_type_t;
|
||||
|
||||
/**
|
||||
* @brief Error codes returned by amdsmi functions
|
||||
@@ -1263,14 +1263,14 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
|
||||
*
|
||||
* @param[in] processor_handle a device handle
|
||||
*
|
||||
* @param[out] device_type a pointer to device_type_t to which the device type
|
||||
* @param[out] processor_type a pointer to processor_type_t to which the device type
|
||||
* will be written. If this parameter is nullptr, this function will return
|
||||
* ::AMDSMI_STATUS_INVAL.
|
||||
*
|
||||
* @return ::amdsmi_status_t | ::AMDSMI_STATUS_SUCCESS on success, non-zero on fail
|
||||
*/
|
||||
amdsmi_status_t amdsmi_get_device_type(amdsmi_processor_handle processor_handle,
|
||||
device_type_t* device_type);
|
||||
amdsmi_status_t amdsmi_get_processor_type(amdsmi_processor_handle processor_handle,
|
||||
processor_type_t* processor_type);
|
||||
|
||||
/**
|
||||
* @brief Get device handle with the matching bdf.
|
||||
|
||||
@@ -51,11 +51,11 @@ namespace smi {
|
||||
|
||||
class AMDSmiProcessor {
|
||||
public:
|
||||
explicit AMDSmiProcessor(device_type_t device) : device_type_(device) {}
|
||||
explicit AMDSmiProcessor(processor_type_t device) : processor_type_(device) {}
|
||||
virtual ~AMDSmiProcessor() {}
|
||||
device_type_t get_device_type() const { return device_type_;}
|
||||
processor_type_t get_processor_type() const { return processor_type_;}
|
||||
private:
|
||||
device_type_t device_type_;
|
||||
processor_type_t processor_type_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -102,20 +102,20 @@ except AmdSmiException as e:
|
||||
print(e)
|
||||
```
|
||||
|
||||
## amdsmi_get_device_type
|
||||
## amdsmi_get_processor_type
|
||||
Description: Checks the type of device with provided handle.
|
||||
|
||||
Input parameters: device handle as an instance of `amdsmi_processor_handle`
|
||||
|
||||
Output: Integer, type of gpu
|
||||
|
||||
Exceptions that can be thrown by `amdsmi_get_device_type` function:
|
||||
Exceptions that can be thrown by `amdsmi_get_processor_type` function:
|
||||
* `AmdSmiLibraryException`
|
||||
|
||||
Example:
|
||||
```python
|
||||
try:
|
||||
type_of_GPU = amdsmi_get_device_type(processor_handle)
|
||||
type_of_GPU = amdsmi_get_processor_type(processor_handle)
|
||||
if type_of_GPU == 1:
|
||||
print("This is an AMD GPU")
|
||||
except AmdSmiException as e:
|
||||
|
||||
@@ -24,7 +24,7 @@ from .amdsmi_interface import amdsmi_init
|
||||
from .amdsmi_interface import amdsmi_shut_down
|
||||
|
||||
# Device Descovery
|
||||
from .amdsmi_interface import amdsmi_get_device_type
|
||||
from .amdsmi_interface import amdsmi_get_processor_type
|
||||
from .amdsmi_interface import amdsmi_get_processor_handles
|
||||
from .amdsmi_interface import amdsmi_get_socket_handles
|
||||
from .amdsmi_interface import amdsmi_get_socket_info
|
||||
|
||||
@@ -550,7 +550,7 @@ def amdsmi_shut_down():
|
||||
_check_res(amdsmi_wrapper.amdsmi_shut_down())
|
||||
|
||||
|
||||
def amdsmi_get_device_type(
|
||||
def amdsmi_get_processor_type(
|
||||
processor_handle: amdsmi_wrapper.amdsmi_processor_handle,
|
||||
) -> ctypes.c_uint32:
|
||||
if not isinstance(processor_handle, amdsmi_wrapper.amdsmi_processor_handle):
|
||||
@@ -558,9 +558,9 @@ def amdsmi_get_device_type(
|
||||
processor_handle, amdsmi_wrapper.amdsmi_processor_handle
|
||||
)
|
||||
|
||||
dev_type = amdsmi_wrapper.device_type_t()
|
||||
dev_type = amdsmi_wrapper.processor_type_t()
|
||||
_check_res(
|
||||
amdsmi_wrapper.amdsmi_get_device_type(
|
||||
amdsmi_wrapper.amdsmi_get_processor_type(
|
||||
processor_handle, ctypes.byref(dev_type))
|
||||
)
|
||||
return dev_type.value
|
||||
|
||||
@@ -232,8 +232,8 @@ amdsmi_container_types_t__enumvalues = c__EA_amdsmi_container_types_t__enumvalue
|
||||
amdsmi_processor_handle = ctypes.POINTER(None)
|
||||
amdsmi_socket_handle = ctypes.POINTER(None)
|
||||
|
||||
# values for enumeration 'c__EA_device_type_t'
|
||||
c__EA_device_type_t__enumvalues = {
|
||||
# values for enumeration 'c__EA_processor_type_t'
|
||||
c__EA_processor_type_t__enumvalues = {
|
||||
0: 'UNKNOWN',
|
||||
1: 'AMD_GPU',
|
||||
2: 'AMD_CPU',
|
||||
@@ -245,9 +245,9 @@ AMD_GPU = 1
|
||||
AMD_CPU = 2
|
||||
NON_AMD_GPU = 3
|
||||
NON_AMD_CPU = 4
|
||||
c__EA_device_type_t = ctypes.c_uint32 # enum
|
||||
device_type_t = c__EA_device_type_t
|
||||
device_type_t__enumvalues = c__EA_device_type_t__enumvalues
|
||||
c__EA_processor_type_t = ctypes.c_uint32 # enum
|
||||
processor_type_t = c__EA_processor_type_t
|
||||
processor_type_t__enumvalues = c__EA_processor_type_t__enumvalues
|
||||
|
||||
# values for enumeration 'c__EA_amdsmi_status_t'
|
||||
c__EA_amdsmi_status_t__enumvalues = {
|
||||
@@ -1414,9 +1414,9 @@ amdsmi_get_socket_info.argtypes = [amdsmi_socket_handle, ctypes.POINTER(ctypes.c
|
||||
amdsmi_get_processor_handles = _libraries['libamd_smi.so'].amdsmi_get_processor_handles
|
||||
amdsmi_get_processor_handles.restype = amdsmi_status_t
|
||||
amdsmi_get_processor_handles.argtypes = [amdsmi_socket_handle, ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.POINTER(None))]
|
||||
amdsmi_get_device_type = _libraries['libamd_smi.so'].amdsmi_get_device_type
|
||||
amdsmi_get_device_type.restype = amdsmi_status_t
|
||||
amdsmi_get_device_type.argtypes = [amdsmi_processor_handle, ctypes.POINTER(c__EA_device_type_t)]
|
||||
amdsmi_get_processor_type = _libraries['libamd_smi.so'].amdsmi_get_processor_type
|
||||
amdsmi_get_processor_type.restype = amdsmi_status_t
|
||||
amdsmi_get_processor_type.argtypes = [amdsmi_processor_handle, ctypes.POINTER(c__EA_processor_type_t)]
|
||||
amdsmi_get_processor_handle_from_bdf = _libraries['libamd_smi.so'].amdsmi_get_processor_handle_from_bdf
|
||||
amdsmi_get_processor_handle_from_bdf.restype = amdsmi_status_t
|
||||
amdsmi_get_processor_handle_from_bdf.argtypes = [amdsmi_bdf_t, ctypes.POINTER(ctypes.POINTER(None))]
|
||||
@@ -1900,7 +1900,7 @@ __all__ = \
|
||||
'amdsmi_get_compute_process_info',
|
||||
'amdsmi_get_compute_process_info_by_pid', 'amdsmi_get_device_bdf',
|
||||
'amdsmi_get_processor_handle_from_bdf', 'amdsmi_get_processor_handles',
|
||||
'amdsmi_get_device_type', 'amdsmi_get_device_uuid',
|
||||
'amdsmi_get_processor_type', 'amdsmi_get_device_uuid',
|
||||
'amdsmi_get_driver_version', 'amdsmi_get_ecc_error_count',
|
||||
'amdsmi_get_event_notification', 'amdsmi_get_func_iter_value',
|
||||
'amdsmi_get_fw_info', 'amdsmi_get_gpu_activity',
|
||||
@@ -1964,8 +1964,8 @@ __all__ = \
|
||||
'c__EA_amdsmi_temperature_metric_t',
|
||||
'c__EA_amdsmi_temperature_type_t',
|
||||
'c__EA_amdsmi_voltage_metric_t', 'c__EA_amdsmi_voltage_type_t',
|
||||
'c__EA_amdsmi_xgmi_status_t', 'c__EA_device_type_t',
|
||||
'device_type_t', 'device_type_t__enumvalues', 'size_t',
|
||||
'c__EA_amdsmi_xgmi_status_t', 'c__EA_processor_type_t',
|
||||
'processor_type_t', 'processor_type_t__enumvalues', 'size_t',
|
||||
'struct_amdsmi_func_id_iter_handle',
|
||||
'struct_c__SA_amd_metrics_table_header_t',
|
||||
'struct_c__SA_amdsmi_asic_info_t',
|
||||
|
||||
@@ -89,7 +89,7 @@ static amdsmi_status_t get_gpu_device_from_handle(amdsmi_processor_handle proces
|
||||
.handle_to_device(processor_handle, &device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS) return r;
|
||||
|
||||
if (device->get_device_type() == AMD_GPU) {
|
||||
if (device->get_processor_type() == AMD_GPU) {
|
||||
*gpudevice = static_cast<amd::smi::AMDSmiGPUDevice*>(processor_handle);
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -249,19 +249,19 @@ amdsmi_status_t amdsmi_get_processor_handles(amdsmi_socket_handle socket_handle,
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_get_device_type(amdsmi_processor_handle processor_handle ,
|
||||
device_type_t* device_type) {
|
||||
amdsmi_status_t amdsmi_get_processor_type(amdsmi_processor_handle processor_handle ,
|
||||
processor_type_t* processor_type) {
|
||||
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (device_type == nullptr) {
|
||||
if (processor_type == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
amd::smi::AMDSmiProcessor* device = nullptr;
|
||||
amdsmi_status_t r = amd::smi::AMDSmiSystem::getInstance()
|
||||
.handle_to_device(processor_handle, &device);
|
||||
if (r != AMDSMI_STATUS_SUCCESS) return r;
|
||||
*device_type = device->get_device_type();
|
||||
*processor_type = device->get_processor_type();
|
||||
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ amdsmi_status_t amdsmi_get_vram_usage(amdsmi_processor_handle processor_handle,
|
||||
.handle_to_device(processor_handle, &device);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) return ret;
|
||||
|
||||
if (device->get_device_type() != AMD_GPU) {
|
||||
if (device->get_processor_type() != AMD_GPU) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ amdsmi_status_t amdsmi_get_caps_info(amdsmi_processor_handle processor_handle,
|
||||
.handle_to_device(processor_handle, &amd_device);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) return ret;
|
||||
|
||||
if (amd_device->get_device_type() != AMD_GPU) {
|
||||
if (amd_device->get_processor_type() != AMD_GPU) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device = nullptr;
|
||||
|
||||
@@ -188,7 +188,7 @@ amdsmi_status_t AMDSmiSystem::gpu_index_to_handle(uint32_t gpu_index,
|
||||
auto iter = devices_.begin();
|
||||
for (; iter != devices_.end(); iter++) {
|
||||
auto cur_device = (*iter);
|
||||
if (cur_device->get_device_type() != AMD_GPU)
|
||||
if (cur_device->get_processor_type() != AMD_GPU)
|
||||
continue;
|
||||
amd::smi::AMDSmiGPUDevice* gpu_device =
|
||||
static_cast<amd::smi::AMDSmiGPUDevice*>(cur_device);
|
||||
|
||||
Ссылка в новой задаче
Block a user