Skip to content

Commit

Permalink
[wip] Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Aug 15, 2024
1 parent 8b9c73e commit e7150ec
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 86 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/ci-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: CI Windows

on:
workflow_call:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- main

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-windows-${{ github.event.number || github.sha }}
cancel-in-progress: true

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

jobs:
build_test_windows:
name: Build and Test (Windows, ASSERTIONS)
runs-on: windows-2019
strategy:
fail-fast: true
env:
CACHE_DIR: ${{ github.workspace }}/.container-cache
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
with:
submodules: recursive

- name: Setup Cpp
uses: aminya/setup-cpp@v1
with:
compiler: msvc
vcvarsall: true
cmake: true
ninja: true
cppcheck: false
clangtidy: false
clangformat: false

- name: Install boost
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_install_dir: ${{ github.workspace }}
boost_version: 1.78.0
platform_version: 2019
toolset: msvc

- name: Sync source deps
run: |
pip install numpy pyyaml
python ./sync_deps.py
- name: Enable cache
uses: actions/cache/restore@v3
with:
path: "${{ github.workspace }}/.ccache"
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}
restore-keys: |
windows-build-test-cpp-
- name: Build packages
run: |
export cache_dir="${{ github.workspace }}/.ccache"
# switch to linux paths instead of windows paths
# also make into abs path
export BOOST_ROOT="/$(echo "${{ steps.install-boost.outputs.BOOST_ROOT }}" | sed -e 's/\\/\//g' -e 's/://')"
bash build_tools/ci/build_test_cpp_windows.sh
- 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
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: windows_x86_64_release_packages
path: |
iree-dist-win64.tar
if-no-files-found: warn

- name: Save cache
uses: actions/cache/save@v3
if: ${{ !cancelled() }}
with:
path: ${{ env.CACHE_DIR }}
key: windows-build-test-cpp-asserts-v1-${{ github.sha }}
102 changes: 102 additions & 0 deletions build_tools/ci/build_test_cpp_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

set -eu -o errtrace

this_dir="$(cd $(dirname $0) && pwd)"
repo_root="$(cd $this_dir/../.. && pwd)"
iree_dir="$(cd $repo_root/../iree && pwd)"
build_dir="$repo_root/iree-build"
install_dir="$repo_root/iree-install"
mkdir -p "$build_dir"
build_dir="$(cd $build_dir && pwd)"
cache_dir="${cache_dir:-}"

# Setup cache dir.
if [ -z "${cache_dir}" ]; then
cache_dir="${repo_root}/.build-cache"
mkdir -p "${cache_dir}"
cache_dir="$(cd ${cache_dir} && pwd)"
fi
echo "Caching to ${cache_dir}"
mkdir -p "${cache_dir}/ccache"
mkdir -p "${cache_dir}/pip"

python="$(which python)"
echo "Using python: $python"

#export CCACHE_DIR="${cache_dir}/ccache"
#export CCACHE_MAXSIZE="700M"
#export CMAKE_C_COMPILER_LAUNCHER=ccache
#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 '{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"include": [
"build_tools/cmake/presets/all.json"
]
}' > $iree_dir/CMakeUserPresets.json

cd $iree_dir

pip download -q mlir -f https://makslevental.github.io/wheels
unzip -q mlir*whl
python3 -m pip install "numpy<2" pyyaml "pybind11[global]" nanobind

cmake -S "$iree_dir" -B "$build_dir" \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$install_dir" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DIREE_ENABLE_ASSERTIONS=ON \
-DIREE_BUILD_SAMPLES=OFF \
-DIREE_BUILD_PYTHON_BINDINGS=OFF \
-DIREE_BUILD_BINDINGS_TFLITE=OFF \
-DIREE_HAL_DRIVER_DEFAULTS=OFF \
-DIREE_HAL_DRIVER_LOCAL_SYNC=ON \
-DIREE_HAL_DRIVER_LOCAL_TASK=ON \
-DIREE_TARGET_BACKEND_DEFAULTS=OFF \
-DIREE_TARGET_BACKEND_LLVM_CPU=ON \
-DIREE_INPUT_TOSA=OFF \
-DIREE_INPUT_STABLEHLO=OFF \
-DIREE_INPUT_TORCH=OFF \
-DIREE_CMAKE_PLUGIN_PATHS=../iree-amd-aie \
-DCMAKE_OBJECT_PATH_MAX=4096 \
-DBoost_INCLUDE_DIR=${BOOST_ROOT}/include\
-DBoost_LIBRARY_DIRS=${BOOST_ROOT}/lib \
-DIREE_ERROR_ON_MISSING_SUBMODULES=OFF \
-DIREE_BUILD_BUNDLED_LLVM=OFF \
-DCMAKE_PREFIX_PATH=$PWD/mlir \
-DPython3_EXECUTABLE=$(which python3)
# -DIREE_EXTERNAL_HAL_DRIVERS=xrt \
# -DXRT_DIR=$XRT_INSTALL_DIR/opt/xilinx/xrt/share/cmake/XRT

echo "Building all"
echo "------------"
cmake --build "$build_dir" -- -k 0

echo "Installing"
echo "----------"
echo "Install to: $install_dir"
cmake --build "$build_dir" --target iree-install-dist

echo "CTest"
echo "-----"
ctest --test-dir "$build_dir" -R amd-aie --output-on-failure -j

# Show ccache stats.
#ccache --show-stats
5 changes: 5 additions & 0 deletions build_tools/remove_path_limit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://stackoverflow.com/a/68353105
# Cannot open compiler generated file: '': Invalid argument
# -DCMAKE_OBJECT_PATH_MAX=4096
# The registry value will be cached by the system (per process) after the first call to an affected Win32 file or directory function (see below for the list of functions). The registry value will not be reloaded during the lifetime of the process. In order for all apps on the system to recognize the value, a reboot might be required because some processes may have started before the key was set.
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
1 change: 0 additions & 1 deletion compiler/plugins/target/AMD-AIE/air/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(IREE_PACKAGE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
set(IREE_PACKAGE_ROOT_PREFIX "iree::target::amd-aie::air")

list(APPEND IREE_COMPILER_TABLEGEN_INCLUDE_DIRS
Expand Down
4 changes: 2 additions & 2 deletions compiler/plugins/target/AMD-AIE/iree-amd-aie/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ iree_cc_library(
iree::target::amd-aie::Transforms
iree::target::amd-aie::aie::AIEDialectIR
iree::target::amd-aie::aie::AIEXDialectIR
iree::target::amd-aie::air::AIRDialectIR
iree_target_amd-aie_air_AIRDialectIR
iree::target::amd-aie::aie::AIEPasses
iree::target::amd-aie::air::AIRPasses
iree_target_amd-aie_air_AIRPasses
iree::base::core_headers
iree::base::internal::flatcc::building
iree-amd-aie::schemas::xrt_executable_def_c_fbs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ iree_cc_library(
iree::compiler::Dialect::HAL::Target
iree::target::amd-aie::IR::AMDAIEDialect
iree::target::amd-aie::Transforms
iree::target::amd-aie::air::AIRDialectIR
iree_target_amd-aie_air_AIRDialectIR
MLIRLLVMDialect
PUBLIC
)
Loading

0 comments on commit e7150ec

Please sign in to comment.