Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

add xrt dep (and ELFIO...) #5

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/base/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Setup base"

inputs:
OS:
description: 'matrix.os'
required: true
ARCH:
description: 'matrix.arch'
required: true

description: ''

outputs:
BOOST_ROOT:
description: ''
value: ${{ steps.install_boost.outputs.BOOST_ROOT }}

runs:
using: "composite"
steps:
- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: gcc
vcvarsall: ${{ contains(inputs.OS, 'windows') }}
msvc: ${{ contains(inputs.OS, 'windows') }}
choco: ${{ contains(inputs.OS, 'windows') }}
cmake: true
ninja: true

- uses: makslevental/mlir-wheels/actions/setup_ccache@d77bf5dc69c46a8c2738b44528749768888eb361
id: setup_ccache
with:
MATRIX_OS: ${{ inputs.OS }}
MATRIX_ARCH: ${{ inputs.ARCH }}
WORKSPACE_ROOT: ${{ github.workspace }}

- name: Install boost for XRT
if: contains(inputs.OS, 'windows') || contains(inputs.OS, 'ubuntu')
uses: MarkusJx/install-boost@v2.4.5
id: install_boost
with:
boost_version: 1.73.0
78 changes: 51 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,55 @@ on:
pull_request:
types: [assigned, opened, synchronize, reopened]

#concurrency:
# group: test-${{ github.event.number || github.sha }}
# cancel-in-progress: true

jobs:

test-x86:

continue-on-error: true

runs-on: ${{ matrix.OS }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04, windows-2019, macos-12 ]
py_version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
OS: [ ubuntu-20.04, windows-2019, macos-12 ]
PY_VERSION: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]

defaults:
run:
shell: bash

steps:
- name: Setup Cpp
uses: aminya/setup-cpp@v1
- name: Checkout actions
uses: actions/checkout@v3
with:
compiler: gcc
vcvarsall: ${{ contains(matrix.os, 'windows') }}
msvc: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
submodules: true

- uses: actions/setup-python@v4
- uses: ./.github/workflows/base
id: base
with:
python-version: ${{ matrix.py_version }}
OS: ${{ matrix.OS }}
ARCH: ${{ matrix.ARCH }}

- name: Checkout actions
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
submodules: true
python-version: ${{ matrix.PY_VERSION }}

- name: Build and install protoc
if: contains(matrix.OS, 'windows') || contains(matrix.OS, 'ubuntu')
run: |

if [ ${{ matrix.OS }} == 'windows-2019' ]; then
choco install -y pkgconfiglite protoc
else
sudo apt install libdrm-dev ocl-icd-opencl-dev rapidjson-dev libprotobuf-dev systemtap-sdt-dev
fi

- name: build wheel
env:
BOOST_ROOT: ${{ steps.base.outputs.BOOST_ROOT }}
BOOST_VERSION: 1.73.0
run: |

pip install -r requirements-dev.txt
Expand All @@ -55,7 +67,7 @@ jobs:

pushd wheelhouse
pip install xaiepy -f $PWD
if [ ${{ matrix.os }} == 'windows-2019' ]; then
if [ ${{ matrix.OS }} == 'windows-2019' ]; then
pytest -s ../tests
else
pytest --capture=tee-sys ../tests
Expand All @@ -72,38 +84,50 @@ jobs:

test-linux-aarch64:

continue-on-error: true

runs-on: ${{ matrix.OS }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-20.04 ]
py_version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
OS: [ ubuntu-20.04 ]
PY_VERSION: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]

steps:
- name: Checkout actions
uses: actions/checkout@v3
with:
submodules: true

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: gcc
cmake: true
ninja: true

- name: Checkout actions
uses: actions/checkout@v3
with:
submodules: true

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: aarch64

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
python-version: ${{ matrix.PY_VERSION }}

- uses: ./.github/workflows/base
id: base
with:
OS: ${{ matrix.OS }}
ARCH: ${{ matrix.ARCH }}

- name: Install XRT deps
run: |

sudo apt install libdrm-dev ocl-icd-opencl-dev rapidjson-dev libprotobuf-dev systemtap-sdt-dev

- name: build wheel
env:
BOOST_ROOT: ${{ steps.base.outputs.BOOST_ROOT }}
BOOST_VERSION: 1.73.0
run: |

pip install -r requirements-dev.txt
Expand Down
33 changes: 18 additions & 15 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,25 @@ jobs:
with:
submodules: true

- name: Setup Cpp
uses: aminya/setup-cpp@v1
- uses: ./.github/workflows/base
if: contains(matrix.OS, 'windows')
id: base
with:
compiler: gcc
vcvarsall: ${{ contains(matrix.os, 'windows') }}
msvc: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true
OS: ${{ matrix.OS }}
ARCH: ${{ matrix.ARCH }}

- name: Build and install protoc
if: contains(matrix.OS, 'windows')
run: |

choco install -y pkgconfiglite protoc

# build

- name: cibuildwheel python bindings
env:
BOOST_ROOT: ${{ steps.base.outputs.BOOST_ROOT }}
BOOST_VERSION: 1.73.0
run: |

pip install cibuildwheel
Expand All @@ -72,19 +79,12 @@ jobs:
runs-on: ubuntu-20.04

steps:

- name: Checkout actions
uses: actions/checkout@v3
with:
submodules: true

- name: Install cross-compilation toolchain
shell: bash
run: |

sudo apt-get update
sudo apt-get install -y binutils-aarch64-linux-gnu \
g++-aarch64-linux-gnu gcc-aarch64-linux-gnu

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
Expand All @@ -93,6 +93,9 @@ jobs:
# build

- name: cibuildwheel python bindings aarch64
env:
BOOST_ROOT: ${{ steps.base.outputs.BOOST_ROOT }}
BOOST_VERSION: 1.73.0
run: |

pip install cibuildwheel
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "third_party/aie-rt"]
path = third_party/aie-rt
url = git@github.com:stephenneuendorffer/aie-rt.git
[submodule "third_party/XRT"]
path = third_party/XRT
url = git@github.com:Xilinx/XRT.git
[submodule "third_party/ELFIO"]
path = third_party/ELFIO
url = git@github.com:serge1/ELFIO.git
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
cmake_minimum_required(VERSION 3.15)
project(xaiepy)
set(CMAKE_CXX_STANDARD 17)

include(collect)

if(POLICY CMP0144)
# respect all caps <PACKAGENAME>_ROOT environment variable to search for
# package stuff
cmake_policy(SET CMP0144 NEW)
endif()

if(POLICY CMP0148)
cmake_policy(SET CMP0148 NEW)
endif()

include(scripts/stuff.cmake)
configure_python_dev_packages()

set(AIERT_SRC_DIR ${PROJECT_SOURCE_DIR}/third_party/aie-rt/driver/src)
# gotta add the subdirectory so the copies to build/include/xaiengine occur...
add_subdirectory(${AIERT_SRC_DIR})
Expand Down Expand Up @@ -33,3 +47,29 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-Wl,-U,_cdo_MaskWrite32
-Wl,-U,_cdo_Write32)
endif()

option(BUILD_PYXRT "Build XRT" ON)
if(BUILD_PYXRT)
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})

include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/ELFIO)
if(WIN32)
file(
READ
${PROJECT_SOURCE_DIR}/third_party/XRT/src/runtime_src/core/common/memalign.h
FILE_CONTENTS)
string(
REPLACE
"defined(_WINDOWS)"
"defined(_WINDOWS) || defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)"
FILE_CONTENTS
"${FILE_CONTENTS}")
file(
WRITE
${PROJECT_SOURCE_DIR}/third_party/XRT/src/runtime_src/core/common/memalign.h
"${FILE_CONTENTS}")
endif()
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/XRT/src)
add_dependencies(xaie pyxrt)
endif()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before-build = [
"rm -rf {project}/build",
"rm -rf *egg*",
"pip install -r requirements-dev.txt",
"yum install -y epel-release && yum install -y ninja-build cmake openssl openssl-devel"
"yum install -y epel-release && yum install -y ninja-build cmake openssl openssl-devel boost-devel protobuf-devel libdrm-devel ocl-icd-devel systemtap-sdt-devel rapidjson ncurses-devel zlib-static libuuid-devel"
]

[tool.cibuildwheel.macos]
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ ctypesgen
cmake-format
black
pytest
cffi
cffi
pybind11[global]
51 changes: 51 additions & 0 deletions scripts/stuff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,54 @@ function(print_target_properties target)
endif()
endforeach()
endfunction()

macro(configure_python_dev_packages)
# apparently alma 8 doesn't have the full development lib???
set(_python_development_component Development.Module)

find_package(
Python3 ${PY_VERSION}
COMPONENTS Interpreter ${_python_development_component}
REQUIRED)
unset(_python_development_component)
message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
detect_pybind11_install()
find_package(pybind11 CONFIG REQUIRED)
message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIR}")
message(STATUS "Python prefix = '${PYTHON_MODULE_PREFIX}', "
"suffix = '${PYTHON_MODULE_SUFFIX}', "
"extension = '${PYTHON_MODULE_EXTENSION}")
endmacro()

# Detects a pybind11 package installed in the current python environment and
# sets variables to allow it to be found. This allows pybind11 to be installed
# via pip, which typically yields a much more recent version than the OS
# install, which will be available otherwise.
function(detect_pybind11_install)
if(pybind11_DIR)
message(
STATUS
"Using explicit pybind11 cmake directory: ${pybind11_DIR} (-Dpybind11_DIR to change)"
)
else()
message(STATUS "Checking for pybind11 in python path...")
execute_process(
COMMAND "${Python3_EXECUTABLE}" -c
"import pybind11;print(pybind11.get_cmake_dir(), end='')"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE STATUS
OUTPUT_VARIABLE PACKAGE_DIR
ERROR_QUIET)
if(NOT STATUS EQUAL "0")
message(
STATUS
"not found (install via 'pip install pybind11' or set pybind11_DIR)")
return()
endif()
message(STATUS "found (${PACKAGE_DIR})")
set(pybind11_DIR
"${PACKAGE_DIR}"
PARENT_SCOPE)
endif()
endfunction()
Loading
Loading