Adjusted folder naming and moved amdsmi_cli into amdsmi project folder

Change-Id: I4b7c42161fc92450f496483e5b49c7def6810437


[ROCm/amdsmi commit: 3eadf3a216]
This commit is contained in:
Maisam Arif
2023-01-18 03:41:27 -06:00
förälder 64b1e4e65b
incheckning 1246feb70d
20 ändrade filer med 65 tillägg och 163 borttagningar
Filskillnaden har hållits tillbaka eftersom den är för stor Load Diff
-217
Visa fil
@@ -1,217 +0,0 @@
#
# Copyright (C) 2022 Advanced Micro Devices. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Library Initialization
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_device_handles
from .amdsmi_interface import amdsmi_get_socket_handles
from .amdsmi_interface import amdsmi_get_socket_info
from .amdsmi_interface import amdsmi_get_device_bdf
from .amdsmi_interface import amdsmi_get_device_uuid
from .amdsmi_interface import amdsmi_get_device_handle_from_bdf
# # SW Version Information
from .amdsmi_interface import amdsmi_get_driver_version
# # ASIC and Bus Static Information
from .amdsmi_interface import amdsmi_get_asic_info
from .amdsmi_interface import amdsmi_get_power_cap_info
from .amdsmi_interface import amdsmi_get_caps_info
# # Microcode and VBIOS Information
from .amdsmi_interface import amdsmi_get_vbios_info
from .amdsmi_interface import amdsmi_get_fw_info
# # GPU Monitoring
from .amdsmi_interface import amdsmi_get_gpu_activity
from .amdsmi_interface import amdsmi_get_vram_usage
from .amdsmi_interface import amdsmi_get_power_measure
from .amdsmi_interface import amdsmi_get_clock_measure
from .amdsmi_interface import amdsmi_get_pcie_link_status
from .amdsmi_interface import amdsmi_get_pcie_link_caps
from .amdsmi_interface import amdsmi_get_bad_page_info
# # Power Management
from .amdsmi_interface import amdsmi_get_target_frequency_range
# # Process Information
from .amdsmi_interface import amdsmi_get_process_list
from .amdsmi_interface import amdsmi_get_process_info
# # ECC Error Information
from .amdsmi_interface import amdsmi_get_ecc_error_count
# # Board Information
from .amdsmi_interface import amdsmi_get_board_info
# # Ras Information
from .amdsmi_interface import amdsmi_get_ras_block_features_enabled
# # Supported Function Checks
from .amdsmi_interface import amdsmi_dev_open_supported_func_iterator
from .amdsmi_interface import amdsmi_dev_open_supported_variant_iterator
from .amdsmi_interface import amdsmi_dev_close_supported_func_iterator
from .amdsmi_interface import amdsmi_next_func_iter
from .amdsmi_interface import amdsmi_get_func_iter_value
# # Unsupported Functions In Virtual Environment
from .amdsmi_interface import amdsmi_dev_set_pci_bandwidth
from .amdsmi_interface import amdsmi_dev_set_power_cap
from .amdsmi_interface import amdsmi_dev_set_power_profile
from .amdsmi_interface import amdsmi_dev_set_clk_range
from .amdsmi_interface import amdsmi_dev_set_od_clk_info
from .amdsmi_interface import amdsmi_dev_set_od_volt_info
from .amdsmi_interface import amdsmi_dev_set_perf_level_v1
from .amdsmi_interface import amdsmi_dev_set_perf_level
from .amdsmi_interface import amdsmi_dev_get_power_profile_presets
from .amdsmi_interface import amdsmi_dev_reset_gpu
from .amdsmi_interface import amdsmi_set_perf_determinism_mode
from .amdsmi_interface import amdsmi_dev_set_fan_speed
from .amdsmi_interface import amdsmi_dev_reset_fan
from .amdsmi_interface import amdsmi_dev_set_clk_freq
from .amdsmi_interface import amdsmi_dev_set_overdrive_level_v1
from .amdsmi_interface import amdsmi_dev_set_overdrive_level
# # Physical State Queries
from .amdsmi_interface import amdsmi_dev_get_fan_rpms
from .amdsmi_interface import amdsmi_dev_get_fan_speed
from .amdsmi_interface import amdsmi_dev_get_fan_speed_max
from .amdsmi_interface import amdsmi_dev_get_temp_metric
from .amdsmi_interface import amdsmi_dev_get_volt_metric
# # Clock, Power and Performance Query
from .amdsmi_interface import amdsmi_dev_get_busy_percent
from .amdsmi_interface import amdsmi_get_utilization_count
from .amdsmi_interface import amdsmi_dev_get_perf_level
from .amdsmi_interface import amdsmi_set_perf_determinism_mode
from .amdsmi_interface import amdsmi_dev_get_overdrive_level
from .amdsmi_interface import amdsmi_dev_get_gpu_clk_freq
from .amdsmi_interface import amdsmi_dev_get_od_volt_info
from .amdsmi_interface import amdsmi_dev_get_gpu_metrics_info
from .amdsmi_interface import amdsmi_dev_get_od_volt_curve_regions
from .amdsmi_interface import amdsmi_dev_get_power_profile_presets
# # Performance Counters
from .amdsmi_interface import amdsmi_dev_counter_group_supported
from .amdsmi_interface import amdsmi_dev_create_counter
from .amdsmi_interface import amdsmi_dev_destroy_counter
from .amdsmi_interface import amdsmi_control_counter
from .amdsmi_interface import amdsmi_read_counter
from .amdsmi_interface import amdsmi_counter_get_available_counters
# # Error Query
from .amdsmi_interface import amdsmi_dev_get_ecc_count
from .amdsmi_interface import amdsmi_dev_get_ecc_enabled
from .amdsmi_interface import amdsmi_dev_get_ecc_status
from .amdsmi_interface import amdsmi_status_string
# # System Information Query
from .amdsmi_interface import amdsmi_get_compute_process_info
from .amdsmi_interface import amdsmi_get_compute_process_info_by_pid
from .amdsmi_interface import amdsmi_get_compute_process_gpus
from .amdsmi_interface import amdsmi_dev_xgmi_error_status
from .amdsmi_interface import amdsmi_dev_reset_xgmi_error
# # PCIE information
from .amdsmi_interface import amdsmi_dev_get_pci_id
from .amdsmi_interface import amdsmi_dev_get_pci_bandwidth
from .amdsmi_interface import amdsmi_dev_get_pci_throughput
from .amdsmi_interface import amdsmi_dev_get_pci_replay_counter
from .amdsmi_interface import amdsmi_topo_get_numa_affinity
# # Power information
from .amdsmi_interface import amdsmi_dev_get_power_ave
from .amdsmi_interface import amdsmi_dev_get_energy_count
# # Memory information
from .amdsmi_interface import amdsmi_dev_get_memory_total
from .amdsmi_interface import amdsmi_dev_get_memory_usage
from .amdsmi_interface import amdsmi_dev_get_memory_busy_percent
from .amdsmi_interface import amdsmi_dev_get_memory_reserved_pages
# # Events
from .amdsmi_interface import AmdSmiEventReader
# # Device Identification information
from .amdsmi_interface import amdsmi_dev_get_vendor_name
from .amdsmi_interface import amdsmi_dev_get_id
from .amdsmi_interface import amdsmi_dev_get_vram_vendor
from .amdsmi_interface import amdsmi_dev_get_drm_render_minor
from .amdsmi_interface import amdsmi_dev_get_subsystem_id
from .amdsmi_interface import amdsmi_dev_get_subsystem_name
# # Version information
from .amdsmi_interface import amdsmi_get_version
from .amdsmi_interface import amdsmi_get_version_str
# # Hardware topology query
from .amdsmi_interface import amdsmi_topo_get_numa_node_number
from .amdsmi_interface import amdsmi_topo_get_link_weight
from .amdsmi_interface import amdsmi_get_minmax_bandwidth
from .amdsmi_interface import amdsmi_topo_get_link_type
from .amdsmi_interface import amdsmi_is_P2P_accessible
from .amdsmi_interface import amdsmi_get_xgmi_info
# # Enums
from .amdsmi_interface import AmdSmiInitFlags
from .amdsmi_interface import AmdSmiContainerTypes
from .amdsmi_interface import AmdSmiDeviceType
from .amdsmi_interface import AmdSmiMmIp
from .amdsmi_interface import AmdSmiFwBlock
from .amdsmi_interface import AmdSmiClkType
from .amdsmi_interface import AmdSmiTemperatureType
from .amdsmi_interface import AmdSmiDevPerfLevel
from .amdsmi_interface import AmdSmiSwComponent
from .amdsmi_interface import AmdSmiEventGroup
from .amdsmi_interface import AmdSmiEventType
from .amdsmi_interface import AmdSmiCounterCommand
from .amdsmi_interface import AmdSmiEvtNotificationType
from .amdsmi_interface import AmdSmiTemperatureMetric
from .amdsmi_interface import AmdSmiVoltageMetric
from .amdsmi_interface import AmdSmiVoltageType
from .amdsmi_interface import AmdSmiPowerProfilePresetMasks
from .amdsmi_interface import AmdSmiGpuBlock
from .amdsmi_interface import AmdSmiRasErrState
from .amdsmi_interface import AmdSmiMemoryType
from .amdsmi_interface import AmdSmiFreqInd
from .amdsmi_interface import AmdSmiXgmiStatus
from .amdsmi_interface import AmdSmiMemoryPageStatus
from .amdsmi_interface import AmdSmiIoLinkType
from .amdsmi_interface import AmdSmiUtilizationCounterType
from .amdsmi_interface import AmdSmiSwComponent
from .amdsmi_interface import AmdSmiIoLinkType
# Exceptions
from .amdsmi_exception import AmdSmiLibraryException
from .amdsmi_exception import AmdSmiRetryException
from .amdsmi_exception import AmdSmiParameterException
from .amdsmi_exception import AmdSmiKeyException
from .amdsmi_exception import AmdSmiBdfFormatException
from .amdsmi_exception import AmdSmiTimeoutException
from .amdsmi_exception import AmdSmiException
from .amdsmi_exception import AmdSmiRetCode
@@ -1,168 +0,0 @@
#
# Copyright (C) 2022 Advanced Micro Devices. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
from enum import IntEnum
from . import amdsmi_wrapper
class AmdSmiRetCode(IntEnum):
SUCCESS = amdsmi_wrapper.AMDSMI_STATUS_SUCCESS
ERR_INVAL = amdsmi_wrapper.AMDSMI_STATUS_INVAL
ERR_NOT_SUPPORTED = amdsmi_wrapper.AMDSMI_STATUS_NOT_SUPPORTED
FILE_ERROR = amdsmi_wrapper.AMDSMI_STATUS_FILE_ERROR
ERR_NO_PERM = amdsmi_wrapper.AMDSMI_STATUS_NO_PERM
ERR_OUT_OF_RESOURCES = amdsmi_wrapper.AMDSMI_STATUS_OUT_OF_RESOURCES
INTERNAL_EXCEPTION = amdsmi_wrapper.AMDSMI_STATUS_INTERNAL_EXCEPTION
INPUT_OUT_OF_BOUNDS = amdsmi_wrapper.AMDSMI_STATUS_INPUT_OUT_OF_BOUNDS
INIT_ERROR = amdsmi_wrapper.AMDSMI_STATUS_INIT_ERROR
NOT_IMPLEMENTED = amdsmi_wrapper.AMDSMI_STATUS_NOT_YET_IMPLEMENTED
ERR_NOT_FOUND = amdsmi_wrapper.AMDSMI_STATUS_NOT_FOUND
INSUFFICIENT_SIZE = amdsmi_wrapper.AMDSMI_STATUS_INSUFFICIENT_SIZE
INTERRUPT = amdsmi_wrapper.AMDSMI_STATUS_INTERRUPT
UNEXPECTED_SIZE = amdsmi_wrapper.AMDSMI_STATUS_UNEXPECTED_SIZE
NO_DATA = amdsmi_wrapper.AMDSMI_STATUS_NO_DATA
UNEXPECTED_DATA = amdsmi_wrapper.AMDSMI_STATUS_UNEXPECTED_DATA
ERR_BUSY = amdsmi_wrapper.AMDSMI_STATUS_BUSY
REFCOUNT_OVERFLOW = amdsmi_wrapper.AMDSMI_STATUS_REFCOUNT_OVERFLOW
FAIL_LOAD_MODULE = amdsmi_wrapper.AMDSMI_STATUS_FAIL_LOAD_MODULE
FAIL_LOAD_SYMBOL = amdsmi_wrapper.AMDSMI_STATUS_FAIL_LOAD_SYMBOL
DRM_ERROR = amdsmi_wrapper.AMDSMI_STATUS_DRM_ERROR
ERR_IO = amdsmi_wrapper.AMDSMI_STATUS_IO
API_FAILED = amdsmi_wrapper.AMDSMI_STATUS_API_FAILED
TIMEOUT = amdsmi_wrapper.AMDSMI_STATUS_TIMEOUT
NO_SLOT = amdsmi_wrapper.AMDSMI_STATUS_NO_SLOT
RETRY = amdsmi_wrapper.AMDSMI_STATUS_RETRY
NOT_INIT = amdsmi_wrapper.AMDSMI_STATUS_NOT_INIT
UNKNOWN_ERROR = amdsmi_wrapper.AMDSMI_STATUS_UNKNOWN_ERROR
class AmdSmiException(Exception):
"""Base smi exception class"""
pass
class AmdSmiLibraryException(AmdSmiException):
def __init__(self, err_code):
err_code = abs(err_code)
super().__init__(err_code)
self.err_code = err_code
self.set_err_info()
def __str__(self):
return "An error occured with code: {err_code}({err_info})".format(
err_code=self.err_code, err_info=self.err_info
)
def get_error_code(self):
return self.err_code
def set_err_info(self):
switch = {
AmdSmiRetCode.ERR_INVAL: "AMDSMI_STATUS_INVAL - Invalid parameters",
AmdSmiRetCode.ERR_NOT_SUPPORTED: "AMDSMI_STATUS_NOT_SUPPORTED - Feature not supported",
AmdSmiRetCode.FILE_ERROR: "AMDSMI_STATUS_FILE_ERROR - Error opening file",
AmdSmiRetCode.ERR_OUT_OF_RESOURCES: "AMDSMI_STATUS_OUT_OF_RESOURCES - Not enough memory",
AmdSmiRetCode.INTERNAL_EXCEPTION: "AMDSMI_STATUS_INTERNAL_EXCEPTION - Internal error",
AmdSmiRetCode.ERR_NO_PERM: "AMDSMI_STATUS_NO_PERM - Permission Denied",
AmdSmiRetCode.INPUT_OUT_OF_BOUNDS: "AMDSMI_STATUS_INPUT_OUT_OF_BOUNDS - Out of bounds",
AmdSmiRetCode.INIT_ERROR: "AMDSMI_STATUS_INIT_ERROR - Initialization error",
AmdSmiRetCode.ERR_BUSY: "AMDSMI_STATUS_BUSY - Device busy",
AmdSmiRetCode.ERR_NOT_FOUND: "AMDSMI_STATUS_NOT_FOUND - Device Not found",
AmdSmiRetCode.ERR_IO: "AMDSMI_STATUS_IO - I/O Error",
AmdSmiRetCode.NOT_IMPLEMENTED: "AMDSMI_STATUS_NOT_YET_IMPLEMENTED - Feature not yet implemented",
AmdSmiRetCode.INSUFFICIENT_SIZE: "AMDSMI_STATUS_INSUFFICIENT_SIZE - Insufficient size for operation",
AmdSmiRetCode.INTERRUPT: "AMDSMI_STATUS_INTERRUPT - Interrupt ocurred during execution",
AmdSmiRetCode.UNEXPECTED_SIZE: "AMDSMI_STATUS_UNEXPECTED_SIZE - unexpected size of data was read",
AmdSmiRetCode.NO_DATA: "AMDSMI_STATUS_NO_DATA - No data was found for given input",
AmdSmiRetCode.UNEXPECTED_DATA: "AMDSMI_STATUS_UNEXPECTED_DATA - The data read or provided was unexpected",
AmdSmiRetCode.REFCOUNT_OVERFLOW: "AMDSMI_STATUS_REFCOUNT_OVERFLOW - Internal reference counter exceeded INT32_MAX",
AmdSmiRetCode.FAIL_LOAD_MODULE: "AMDSMI_STATUS_FAIL_LOAD_MODULE - Fail to load lib",
AmdSmiRetCode.FAIL_LOAD_SYMBOL: "AMDSMI_STATUS_FAIL_LOAD_SYMBOL - Fail to load symbol",
AmdSmiRetCode.DRM_ERROR: "AMDSMI_STATUS_DRM_ERROR - Error when called libdrm",
AmdSmiRetCode.API_FAILED: "AMDSMI_STATUS_API_FAILED - API call failed",
AmdSmiRetCode.TIMEOUT: "AMDSMI_STATUS_TIMEOUT - Timeout in API call",
AmdSmiRetCode.NO_SLOT: "AMDSMI_STATUS_NO_SLOT - No more free slot",
AmdSmiRetCode.RETRY: "AMDSMI_STATUS_RETRY - Retry operation",
AmdSmiRetCode.NOT_INIT: "AMDSMI_STATUS_NOT_INIT - Device not initialized",
}
self.err_info = switch.get(self.err_code, "AMDSMI_STATUS_UNKNOWN_ERROR - An unknown error occurred")
class AmdSmiRetryException(AmdSmiLibraryException):
def __init__(self):
super().__init__(AmdSmiRetCode.RETRY)
class AmdSmiTimeoutException(AmdSmiLibraryException):
def __init__(self):
super().__init__(AmdSmiRetCode.TIMEOUT)
class AmdSmiParameterException(AmdSmiException):
def __init__(self, receivedValue, expectedType, msg=None):
super().__init__(msg)
self.actualType = type(receivedValue)
self.expectedType = expectedType
self.set_err_msg()
if msg is not None:
self.err_msg = msg
def set_err_msg(self):
self.err_msg = (
"Invalid parameter:\n"
+ "Actual type: {actualType}\n".format(actualType=self.actualType)
+ "Expected type: {expectedType}".format(expectedType=self.expectedType)
)
def __str__(self):
return self.err_msg
class AmdSmiKeyException(AmdSmiException):
def __init__(self, key):
super().__init__()
self.key = key
self.set_err_msg()
def set_err_msg(self):
self.err_msg = "Key " + self.key + " is missing from dictionary"
def __str__(self):
return self.err_msg
class AmdSmiBdfFormatException(AmdSmiException):
def __init__(self, bdf):
super().__init__()
self.bdf = bdf
def __str__(self):
return (
"Wrong BDF format: {}. \n"
+ "BDF string should be: <domain>:<bus>:<device>.<function>\n"
+ " or <bus>:<device>.<function> in hexcode format.\n"
+ "Where:\n\t<domain> is 4 hex digits long from 0000-FFFF interval\n"
+ "\t<bus> is 2 hex digits long from 00-FF interval\n"
+ "\t<device> is 2 hex digits long from 00-1F interval\n"
+ "\t<function> is 1 hex digit long from 0-7 interval"
).format(self.bdf)
Filskillnaden har hållits tillbaka eftersom den är för stor Load Diff
Filskillnaden har hållits tillbaka eftersom den är för stor Load Diff
Filskillnaden har hållits tillbaka eftersom den är för stor Load Diff
-16
Visa fil
@@ -1,16 +0,0 @@
from setuptools import setup
with open("amdsmi/README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name='amdsmi',
version='0.1',
description="SMI LIB - AMD GPU Monitoring Library",
long_description=long_description,
long_description_content_type="text/markdown",
packages=['amdsmi'],
package_data={'': ['LICENSE']},
include_package_data=True,
python_requires=">=3.6",
)