Skip to content

ci: enable ccache on Windows #1548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2022
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
39 changes: 27 additions & 12 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ inputs:
Additional string that is used to compute the ccache hash.
Different jobs running the action need distinct values for this key,
but the content is irrelevant.
required: true
required: false
default: ''

runs:
using: "composite"
Expand All @@ -28,24 +29,38 @@ runs:
python -m pip install -r requirements.txt
shell: bash

- name: Install Ninja (Linux)
- name: Install prerequisites (Linux)
if: ${{ runner.os == 'Linux' }}
run: sudo apt-get install -y ninja-build
run: sudo apt-get install --yes ccache ninja-build
shell: bash

- name: Install Ninja (macOS)
- name: Install prerequisites (macOS)
if: ${{ runner.os == 'macOS' }}
run: brew install ninja
run: brew install ccache ninja
shell: bash

- name: Install Ninja (Windows)
- name: Install prerequisites (Windows)
if: ${{ runner.os == 'Windows' }}
run: pip install ninja
run: |
pip install ninja
choco install ccache --yes
shell: bash

- name: Configure ccache
run: |
rm -rf ${{ github.workspace }}/.ccache
mkdir -p ${{ github.workspace }}/.ccache
ccache --set-config "cache_dir=${{ github.workspace }}/.ccache"
ccache --set-config "compression=true"
ccache --set-config "max_size=300M"
ccache --zero-stats
shell: bash

- name: Ccache for C++ compilation
uses: hendrikmuhs/ccache-action@v1.2
- name: Enable ccache
uses: actions/cache@v3
with:
key: ${{ runner.os }}-torch_mlir_build_assets-${{ inputs.cache-suffix }}
max-size: 300M
verbose: 2
path: ${{ github.workspace }}/.ccache
key: ${{ runner.os }}-${{ inputs.cache-suffix }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ inputs.cache-suffix }}-
${{ runner.os }}-
2 changes: 1 addition & 1 deletion .github/workflows/RollPyTorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup ccache
uses: ./.github/actions/setup-build
with:
cache-suffix: x86_64-out-of-tree-OFF
cache-suffix: 'rollPyTorch'

- name: Determine nightly PyTorch version
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup ccache
uses: ./.github/actions/setup-build
with:
cache-suffix: ${{ matrix.os-arch }}-${{ matrix.llvm-build }}-${{ matrix.torch-binary }}
cache-suffix: 'build-${{ matrix.llvm-build }}'

- name: Set up Visual Studio shell
if: ${{ matrix.os-arch == 'windows-x86_64' }}
Expand Down Expand Up @@ -123,8 +123,8 @@ jobs:
if: ${{ matrix.os-arch == 'macos-arm64' }}
run: |
cmake --build build_arm64
- name: Build torch-mlir (Windows)

- name: Build (Windows)
if: ${{ matrix.os-arch == 'windows-x86_64' }}
shell: pwsh
run: |
./build_tools/python_deploy/build_windows_ci.ps1
shell: bash
run: ./build_tools/python_deploy/build_windows_ci.sh
6 changes: 3 additions & 3 deletions .github/workflows/buildRelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: ''
cache-suffix: 'release'
- name: Build Python wheels and smoke test.
run: |
cd $GITHUB_WORKSPACE
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: ''
cache-suffix: 'release'
- name: Build Python wheels and smoke test.
run: |
cd $GITHUB_WORKSPACE
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
submodules: 'true'
- uses: ./.github/actions/setup-build
with:
cache-suffix: ''
cache-suffix: 'release'
- name: Set up Visual Studio shell
uses: egor-tensin/vs-shell@v2
with:
Expand Down
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ torch_mlir_add_llvm_external_project(

option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)

# Adjustments to use ccache on Windows
if (WIN32)
find_program(ccache_exe ccache)
if(ccache_exe)
file(COPY_FILE ${ccache_exe} ${CMAKE_BINARY_DIR}/cl.exe ONLY_IF_DIFFERENT)
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"TrackFileAccess=false"
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)
endif()
endif()

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR TORCH_MLIR_OUT_OF_TREE_BUILD)
message(STATUS "Torch-MLIR out-of-tree build.")
# Out-of-tree build
Expand Down
24 changes: 0 additions & 24 deletions build_tools/python_deploy/build_windows.ps1

This file was deleted.

42 changes: 0 additions & 42 deletions build_tools/python_deploy/build_windows_ci.ps1

This file was deleted.

21 changes: 21 additions & 0 deletions build_tools/python_deploy/build_windows_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

echo "Building torch-mlir"

cmake -GNinja -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_TARGETS_TO_BUILD=host \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DPython3_FIND_VIRTUALENV=ONLY \
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="$PWD/externals/llvm-external-projects/torch-mlir-dialects" \
-DPython3_EXECUTABLE="$(which python)" \
$GITHUB_WORKSPACE/externals/llvm-project/llvm

cmake --build build

echo "Build completed successfully"