Skip to content

Commit

Permalink
Windows support (#677)
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental authored Aug 19, 2024
1 parent aa112f7 commit 20e778f
Show file tree
Hide file tree
Showing 52 changed files with 1,132 additions and 915 deletions.
69 changes: 47 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,76 @@ concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-cpp-linux-${{ github.event.number || github.sha }}
group: ci-build-test-${{ github.event.number || github.sha }}
cancel-in-progress: true

defaults:
run:
# force bash for windows
shell: bash

jobs:
build_test_linux:
name: Build and Test (Linux, ASSERTIONS)
runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64
build_and_ctest:
name: Build and Test (${{ matrix.os }}, ASSERTIONS)
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- os: linux
runs-on: nod-ai-shared-cpubuilder-manylinux-x86_64
- os: windows
runs-on: windows-2019
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
steps:
- name: Configure local git mirrors
if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }}
run: |
/gitmirror/scripts/trigger_update_mirrors.sh
/gitmirror/scripts/git_config.sh
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
submodules: recursive

- name: Install static libs
if: ${{ matrix.runs-on == 'nod-ai-shared-cpubuilder-manylinux-x86_64' }}
run: |
dnf install -y almalinux-release-devel
yum remove -y openssl-devel zlib-devel boost boost-all || true
yum install -y openssl-static zlib-static
yum remove -y openssl-devel zlib-devel || true
yum install -y protobuf-devel protobuf-compiler
yum install -y boost-static
- name: Setup Cpp
uses: aminya/setup-cpp@v1
if: ${{ matrix.os == 'windows' }}
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
ccache: true

- uses: actions/setup-python@v4
if: ${{ matrix.os == 'windows' }}
with:
python-version: '3.11'

- name: Sync source deps
run: |
python ./sync_deps.py
- name: Python deps
run: |
pip install "numpy<2" pyyaml "pybind11[global]==2.10.3" nanobind
- name: Enable cache
uses: actions/cache/restore@v3
with:
path: ${{ env.CACHE_DIR }}
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}
restore-keys: |
linux-build-test-cpp-
key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}"
restore-keys: "${{ matrix.os }}-build-test-cpp-"

- name: Build packages
run: |
Expand All @@ -62,32 +92,28 @@ jobs:
- name: Create artifacts
if: ${{ !cancelled() }}
run: |
# TODO: https://github.com/openxla/iree/issues/16230
# We should not be packaging clang and llvm-link in the default dist
# installs.
rm -f iree-install/bin/clang*
rm -f iree-install/bin/llvm-link*
tar cf iree-dist.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test
tar cf iree-${{ matrix.os }}-dist.tar -C iree-install . -C ../iree-build tools/testing/e2e/iree-e2e-matmul-test
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: linux_x86_64_release_packages
path: |
iree-dist.tar
name: "${{ matrix.os }}_x86_64_release_packages"
path: "iree-${{ matrix.os }}-dist.tar"
if-no-files-found: warn

- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: linux-build-test-cpp-asserts-manylinux-v2-${{ github.sha }}
key: "${{ matrix.os }}-build-test-cpp-asserts-v1-${{ github.sha }}"

test_linux:
runs-on: amd7940hs
needs: build_test_linux
needs: build_and_ctest
strategy:
fail-fast: true
env:
Expand All @@ -106,7 +132,7 @@ jobs:
- name: Extract artifact
run: |
mkdir iree-install
tar -xf iree-dist.tar -C iree-install
tar -xf iree-linux-dist.tar -C iree-install
bash build_tools/download_peano.sh
- name: Create venv and install dependencies
Expand All @@ -115,7 +141,6 @@ jobs:
source .venv/bin/activate
pip install -r tests/matmul/requirements.txt
- name: E2E correctness matmul test
run: |
source .venv/bin/activate
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
path = third_party/bootgen
url = https://github.com/Xilinx/bootgen.git
shallow = true
[submodule "third_party/openssl"]
path = third_party/openssl
url = https://github.com/viaduck/openssl-cmake.git
63 changes: 11 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ Preparing repository:
git submodule update --init
```

Building the runtime driver (see below) for the amd-aie backend/plugin for IREE (this repo) requires Boost:

```
# Debian/Ubuntu
sudo apt-get install libboost-all-dev
# Alma/CentOS/RHEL
yum install -y boost-static
```

## Building (along with IREE)

### Just show me the CMake
Expand All @@ -39,7 +30,7 @@ cmake -B $WHERE_YOU_WOULD_LIKE_TO_BUILD -S $IREE_REPO_SRC_DIR \
-DIREE_CMAKE_PLUGIN_PATHS=$IREE_AMD_AIE_REPO_SRC_DIR -DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_INPUT_STABLEHLO=OFF -DIREE_INPUT_TORCH=OFF -DIREE_INPUT_TOSA=OFF \
-DIREE_HAL_DRIVER_DEFAULTS=OFF -DIREE_TARGET_BACKEND_DEFAULTS=OFF -DIREE_TARGET_BACKEND_LLVM_CPU=ON \
-DIREE_BUILD_TESTS=ON -DIREE_EXTERNAL_HAL_DRIVERS=xrt -DXRT_DIR=$XRT_INSTALL_DIR/share/cmake/XRT \
-DIREE_BUILD_TESTS=ON -DIREE_EXTERNAL_HAL_DRIVERS=xrt \
-DCMAKE_INSTALL_PREFIX=$WHERE_YOU_WOULD_LIKE_TO_INSTALL
```

Expand Down Expand Up @@ -97,54 +88,30 @@ ctest -R amd-aie

## Runtime driver setup

To enable the runtime driver. You need to make sure XRT cmake package is discoverable by cmake.
One option is to add it to your PATH.
Note that with a standard setup, XRT is installed in `/opt/xilinx/xrt`.

Now from within the iree-amd-aie root directory. Then,
To enable the runtime driver, you need to also enable the XRT HAL:

```
cd ../iree-build
cmake . -DIREE_CMAKE_PLUGIN_PATHS=../iree-amd-aie \
-DIREE_EXTERNAL_HAL_DRIVERS=xrt \
-DXRT_DIR=/opt/xilinx/xrt/share/cmake/XRT
-DIREE_EXTERNAL_HAL_DRIVERS=xrt
ninja
```

### Building XRT

For the CI, we prefer to build against the pinned XRT. Note that XRT has
submodules so recursively submodule initialization is required.

You can build using the same script the CI does:

```
./build_tools/ci/build_xrt.sh ../xrt-build ../xrt-install
```

Then instead of using the default system install location for `-DXRT_DIR=`
above, prepend the `../xrt-install/` prefix for the one you just built.

### Ubuntu Dependencies

Presently XRT is a monolithic build that unconditionally requires a number of
packages. Here are the requirements for various operating systems:
XRT requires a number of packages. Here are the requirements for various operating systems:

```
apt install \
libboost-dev libboost-filesystem-dev libboost-program-options-dev \
libboost-system-dev \
pkg-config libdrm-dev opencl-headers ocl-icd-opencl-dev ocl-icd-dev \
libssl-dev \
rapidjson-dev \
protobuf-compiler \
libprotobuf-dev \
python3-pybind11 \
uuid-dev \
libcurl4-openssl-dev \
libdrm-dev \
libelf-dev \
libprotobuf-dev \
libudev-dev \
systemtap-sdt-dev \
libelf-dev
pkg-config \
protobuf-compiler \
python3-pybind11 \
systemtap-sdt-dev
```

### RH Based Deps
Expand All @@ -154,21 +121,13 @@ base manylinux (AlmaLinux 8) image.

```
yum install \
boost-devel \
boost-filesystem \
boost-program-options \
boost-static \
libcurl-devel \
libdrm-devel \
libudev-devel \
libuuid-devel \
ncurses-devel \
ocl-icd-devel \
openssl-devel \
pkgconfig \
protobuf-compiler \
protobuf-devel \
rapidjson-devel \
systemtap-sdt-devel
```
22 changes: 11 additions & 11 deletions build_tools/ci/build_test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ mkdir -p "${cache_dir}/pip"
python="$(which python)"
echo "Using python: $python"

export CMAKE_TOOLCHAIN_FILE="$this_dir/linux_default_toolchain.cmake"
export CC=clang
export CXX=clang++
# https://stackoverflow.com/a/8597411/9045206
# note: on windows (git-bash) result is "msys"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
export CMAKE_TOOLCHAIN_FILE="$this_dir/linux_default_toolchain.cmake"
export CC=clang
export CXX=clang++
fi
export CCACHE_DIR="${cache_dir}/ccache"
export CCACHE_MAXSIZE="700M"
export CMAKE_C_COMPILER_LAUNCHER=ccache
Expand All @@ -35,11 +39,6 @@ export CMAKE_CXX_COMPILER_LAUNCHER=ccache
# Clear ccache stats.
ccache -z

# Build XRT.
XRT_BUILD_DIR=$repo_root/xrt-build
XRT_INSTALL_DIR=$repo_root/xrt-install
$this_dir/build_xrt.sh $XRT_BUILD_DIR $XRT_INSTALL_DIR

echo "Building IREE"
echo "============="
echo '{
Expand All @@ -62,7 +61,7 @@ cmake -S "$iree_dir" -B "$build_dir" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DIREE_ENABLE_ASSERTIONS=ON \
-DIREE_BUILD_SAMPLES=OFF \
-DIREE_BUILD_PYTHON_BINDINGS=OFF \
-DIREE_BUILD_PYTHON_BINDINGS=ON \
-DIREE_BUILD_BINDINGS_TFLITE=OFF \
-DIREE_HAL_DRIVER_DEFAULTS=OFF \
-DIREE_HAL_DRIVER_LOCAL_SYNC=ON \
Expand All @@ -71,9 +70,10 @@ cmake -S "$iree_dir" -B "$build_dir" \
-DIREE_TARGET_BACKEND_LLVM_CPU=ON \
-DIREE_INPUT_TOSA=OFF \
-DIREE_INPUT_STABLEHLO=OFF \
-DIREE_INPUT_TORCH=OFF \
-DCMAKE_OBJECT_PATH_MAX=4096 \
-DIREE_CMAKE_PLUGIN_PATHS=../iree-amd-aie \
-DIREE_EXTERNAL_HAL_DRIVERS=xrt \
-DXRT_DIR=$XRT_INSTALL_DIR/opt/xilinx/xrt/share/cmake/XRT
-DIREE_EXTERNAL_HAL_DRIVERS=xrt

echo "Building all"
echo "------------"
Expand Down
29 changes: 0 additions & 29 deletions build_tools/ci/build_xrt.sh

This file was deleted.

1 change: 0 additions & 1 deletion build_tools/ci/print_ir_aie2xclbin/print_ir_aie2xclbin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ ${FILECHECK_EXE} --input-file ${STDERR_FULLPATH} ${0} --check-prefix=CHECK-STDER
# CHECK-STDERRTIME-DAG: Total
${FILECHECK_EXE} --input-file ${STDERR_FULLPATH} ${0} --check-prefix=CHECK-STDERRTIME

# CHECK-STDOUT-DAG: Bootgen
# CHECK-STDOUT-DAG: MEM_TOPOLOGY
${FILECHECK_EXE} --input-file ${STDOUT_FULLPATH} ${0} --check-prefix=CHECK-STDOUT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ if(WIN32 AND NOT CYGWIN)
endif ()
message(STATUS "searching for MSVC libs in ${_OPENSSL_PATH_SUFFIXES_DEBUG}")
message(STATUS "searching for MSVC libs in ${_OPENSSL_PATH_SUFFIXES_RELEASE}")
message(FATAL_ERROR)

find_library(LIB_EAY_DEBUG
NAMES
Expand Down
File renamed without changes.
Loading

0 comments on commit 20e778f

Please sign in to comment.