AMDSMI CLI Initial Packaging
- Added CMake packaging to the amdsmi_cli folder - Updated Headings in the README.md to follow markdown standard - Updated Compatibility to be based on the built package name in bin - Added misc error handling and import corrections - Updated py-interface amdsmi_exception imports to work by relative path - Cleaned up py-interface cmake & generator code for finding libamd_smi.so - Changed line endings in tools/generator.py file to unix Change-Id: I91858ff3dd0cb57ed9b8cd61a0ada27b6af9c51c Signed-off-by: Maisam Arif <Maisam.Arif@amd.com>
Este commit está contenido en:
cometido por
Galantsev, Dmitrii
padre
aa70b77ec5
commit
235c8db949
@@ -64,11 +64,11 @@ else()
|
||||
# extract clang version manually because find_package(clang) doesn't work
|
||||
execute_process(COMMAND ${clang} --version OUTPUT_VARIABLE clang_full_version_string)
|
||||
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string})
|
||||
if(CLANG_VERSION_STRING VERSION_EQUAL 14.0)
|
||||
if(CLANG_VERSION_STRING VERSION_EQUAL clang_ver)
|
||||
message("GOOD CLANG VERSION: ${CLANG_VERSION_STRING}")
|
||||
set(GOOD_CLANG_FOUND TRUE)
|
||||
else()
|
||||
message(AUTHOR_WARNING "CLANG VERSION TOO OLD!: ${CLANG_VERSION_STRING}")
|
||||
message(AUTHOR_WARNING "${clang} VERSION TOO OLD!: ${CLANG_VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT GOOD_CLANG_FOUND)
|
||||
|
||||
@@ -26,8 +26,7 @@ from enum import IntEnum
|
||||
from collections.abc import Iterable
|
||||
|
||||
from . import amdsmi_wrapper
|
||||
from amdsmi_exception import *
|
||||
|
||||
from .amdsmi_exception import *
|
||||
|
||||
class AmdSmiInitFlags(IntEnum):
|
||||
ALL_DEVICES = amdsmi_wrapper.AMDSMI_INIT_ALL_DEVICES
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
import os
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# TARGET arch is: ['-I/usr/lib/llvm-14/lib/clang/14.0.0/include']
|
||||
@@ -28,8 +27,10 @@ import os
|
||||
# POINTER_SIZE is: 8
|
||||
# LONGDOUBLE_SIZE is: 16
|
||||
#
|
||||
import ctypes
|
||||
|
||||
import os
|
||||
import ctypes
|
||||
from pathlib import Path
|
||||
|
||||
c_int128 = ctypes.c_ubyte*16
|
||||
c_uint128 = c_int128
|
||||
@@ -168,16 +169,23 @@ def char_pointer_cast(string, encoding='utf-8'):
|
||||
|
||||
_libraries = {}
|
||||
|
||||
if os.path.isfile('@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so'):
|
||||
# try to find library in install directory provided by CMake
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(os.path.join('@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@', 'libamd_smi.so'))
|
||||
elif os.path.isfile('/opt/rocm/lib/libamd_smi.so'):
|
||||
# try /opt/rocm/lib as a fallback
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(os.path.join('/opt/rocm/lib', 'libamd_smi.so'))
|
||||
else:
|
||||
# lastly - search in current directory
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(os.path.join(os.path.dirname(__file__), 'libamd_smi.so'))
|
||||
libamd_smi_cpack = Path("@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so")
|
||||
libamd_smi_optrocm = Path("/opt/rocm/lib/libamd_smi.so")
|
||||
libamd_smi_parent_dir = Path(__file__).resolve().parent / "libamd_smi.so"
|
||||
libamd_smi_cwd = Path.cwd()
|
||||
|
||||
if libamd_smi_cpack.is_file():
|
||||
# try to find library in install directory provided by CMake
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_cpack)
|
||||
elif libamd_smi_optrocm.is_file():
|
||||
# try /opt/rocm/lib as a fallback
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_optrocm)
|
||||
elif libamd_smi_parent_dir.is_file():
|
||||
# try to fall back to parent directory
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_parent_dir)
|
||||
else:
|
||||
# lastly - search in current working directory
|
||||
_libraries['libamd_smi.so'] = ctypes.CDLL(libamd_smi_cwd)
|
||||
|
||||
|
||||
|
||||
|
||||
Referencia en una nueva incidencia
Block a user