Add wrapper generator
Change-Id: I34a191acfefbef2e40d0242eb121ba9af55cb9de
Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>
[ROCm/amdsmi commit: c94036de21]
Tento commit je obsažen v:
odevzdal
Dmitrii Galantsev
rodič
1dd2942136
revize
f7cb43462e
@@ -118,7 +118,7 @@ To build the documentation locally, run the commands below:
|
||||
``` bash
|
||||
cd docs
|
||||
|
||||
pip3 install -r sphinx/requirements.txt
|
||||
python3 -m pip install -r sphinx/requirements.txt
|
||||
|
||||
python3 -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html
|
||||
```
|
||||
@@ -203,15 +203,14 @@ The python wrapper (binding) is an auto-generated file `py-interface/amdsmi_wrap
|
||||
Wrapper should be re-generated on each C++ API change, by doing:
|
||||
|
||||
```bash
|
||||
cmake .. -DBUILD_WRAPPER=on
|
||||
make python_wrapper # or simply 'make'
|
||||
./update_wrapper.sh
|
||||
```
|
||||
|
||||
After this command, the file in `py-interface/amdsmi_wrapper.py` will be automatically updated on each compile.
|
||||
|
||||
Note: To be able to re-generate python wrapper you need several tools installed on your system: clang-14, clang-format, libclang-dev, and ***python3.7 or newer***.
|
||||
Note: To be able to re-generate python wrapper you need **docker** installed.
|
||||
|
||||
Note: python_wrapper is NOT automatically re-generated. You must run `cmake` with `-DBUILD_WRAPPER=on` argument.
|
||||
Note: python_wrapper is NOT automatically re-generated. You must run `./update_wrapper.sh`.
|
||||
|
||||
## Building AMD SMI
|
||||
|
||||
@@ -219,14 +218,14 @@ Note: python_wrapper is NOT automatically re-generated. You must run `cmake` wit
|
||||
|
||||
In order to build the AMD SMI library, the following components are required. Note that the software versions listed are what was used in development. Earlier versions are not guaranteed to work:
|
||||
|
||||
* CMake (v3.11.0) - `pip3 install cmake`
|
||||
* CMake (v3.14.0) - `python3 -m pip install cmake`
|
||||
* g++ (5.4.0)
|
||||
|
||||
In order to build the AMD SMI python package, the following components are required:
|
||||
|
||||
* clang (14.0 or above)
|
||||
* python (3.6 or above)
|
||||
* virtualenv - `pip3 install virtualenv`
|
||||
* python (3.7 or above)
|
||||
* virtualenv - `python3 -m pip install virtualenv`
|
||||
|
||||
In order to build the latest documentation, the following are required:
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Generate py-interface and package targets
|
||||
|
||||
# CLANG installed must be 14.0 or above
|
||||
set(clang_ver 14.0)
|
||||
set(ctypeslib_ver 2.3.2)
|
||||
# CLANG installed must be 16.0 or above
|
||||
set(clang_ver 16.0)
|
||||
set(clang_ver_py 16.0.1)
|
||||
set(ctypeslib_ver_py 2.3.4)
|
||||
|
||||
set(PY_BUILD_DIR "python_package")
|
||||
# amdsmi part of this string is the directory containing all python files
|
||||
@@ -52,7 +53,7 @@ else()
|
||||
endif()
|
||||
add_custom_target(
|
||||
python_pre_reqs
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install ${Python3_BREAK_SYSTEM_PACKAGES} clang==${clang_ver} ctypeslib2==${ctypeslib_ver})
|
||||
COMMAND ${Python3_EXECUTABLE} -m pip install ${Python3_BREAK_SYSTEM_PACKAGES} clang==${clang_ver_py} ctypeslib2==${ctypeslib_ver_py})
|
||||
# generate new wrapper
|
||||
configure_file(${PROJECT_SOURCE_DIR}/tools/generator.py generator.py @ONLY COPYONLY)
|
||||
add_custom_command(
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
# do not prompt in apt
|
||||
# https://github.com/moby/moby/issues/4032#issuecomment-163689851
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ARG DEBCONF_NONINTERACTIVE_SEEN=true
|
||||
|
||||
# set timezone
|
||||
ENV TZ="America/Chicago"
|
||||
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone
|
||||
|
||||
RUN apt update --yes \
|
||||
&& apt install --yes \
|
||||
build-essential \
|
||||
cmake \
|
||||
gnupg \
|
||||
libdrm-dev \
|
||||
libpython3-dev \
|
||||
lsb-release \
|
||||
pkg-config \
|
||||
pkg-config \
|
||||
python3-pip \
|
||||
software-properties-common \
|
||||
wget \
|
||||
&& apt clean \
|
||||
&& rm -rf /var/cache/apt/ /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /var/tmp
|
||||
RUN TEMPDIR=$(mktemp -d) \
|
||||
&& cd $TEMPDIR \
|
||||
&& wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh \
|
||||
&& ./llvm.sh 16 \
|
||||
&& update-alternatives --install /usr/bin/clang clang $(which clang-16) 91 --slave /usr/bin/clang++ clang++ $(which clang++-16) \
|
||||
&& python3 -m pip install --no-cache-dir clang==16.0.1 ctypeslib2==2.3.4 -U \
|
||||
&& rm -rf $TEMPDIR
|
||||
|
||||
WORKDIR /src
|
||||
CMD cp -r /src /tmp/src \
|
||||
&& cd /tmp/src \
|
||||
&& rm -rf build .cache \
|
||||
&& cmake -B build -DBUILD_WRAPPER=ON \
|
||||
&& make -C build -j $(nproc) \
|
||||
&& cp /tmp/src/py-interface/amdsmi_wrapper.py /src/py-interface/amdsmi_wrapper.py
|
||||
@@ -23,7 +23,7 @@
|
||||
import os
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# TARGET arch is: ['-I/usr/lib64/clang/17/include']
|
||||
# TARGET arch is: ['-I/usr/lib/llvm-16/lib/clang/16/include']
|
||||
# WORD_SIZE is: 8
|
||||
# POINTER_SIZE is: 8
|
||||
# LONGDOUBLE_SIZE is: 16
|
||||
|
||||
Spustitelný soubor
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# this program generates py-interface/amdsmi_wrapper.py
|
||||
|
||||
set -eu
|
||||
|
||||
# get current dir
|
||||
DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
# override by calling this script with:
|
||||
# DOCKER_NAME=yourdockername ./update_wrapper.sh
|
||||
DOCKER_NAME="${DOCKER_NAME:-dmitriigalantsev/amdsmi_wrapper_updater}"
|
||||
|
||||
command -v docker &>/dev/null || {
|
||||
echo "Please install docker!" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
does_image_exist () {
|
||||
docker images | grep -q "$DOCKER_NAME"
|
||||
}
|
||||
|
||||
if ! does_image_exist; then
|
||||
# if you prefer to not generate it yourself:
|
||||
# pull from https://hub.docker.com/r/dmitriigalantsev/amdsmi_wrapper_updater
|
||||
# using the following command:
|
||||
# docker pull dmitriigalantsev/amdsmi_wrapper_updater
|
||||
echo "No docker image found! Generating one"
|
||||
# set to 0 because it's compatible with more systems
|
||||
DOCKER_BUILDKIT="${DOCKER_BUILDKIT:0}" docker build "$DIR/py-interface" -t "$DOCKER_NAME":latest
|
||||
fi
|
||||
|
||||
docker run --rm -ti --volume "$DIR":/src:rw "$DOCKER_NAME":latest
|
||||
|
||||
echo -e "Generated new wrapper!
|
||||
[$DIR/py-interface/amdsmi_wrapper.py]"
|
||||
Odkázat v novém úkolu
Zablokovat Uživatele