mirror of https://github.com/llvm/torch-mlir
ci: enable ccache on Windows (#1548)
This patch makes a few small, but key, changes to enable ccache on Windows. First, it replaces the hendrikmuhs/ccache-action action with command line invocations to the ccache binary, since the action has two bugs, one of which causes CI to refer to different ccache artifacts before versus after the build on Windows whereas the other bug can sometimes cause the action to incorrectly infer that the cache is empty. Second, this patch slightly alters the cache key, so that our old cache artifacts, which have grown too big, are eventually discarded in favor of the new, smaller cache artifacts. Along the way, this patch also keeps the RollPyTorch's cache artifact separate from the regular build's cache artifact so as to keep these artifacts small, and also because the RollPyTorch action is off the critical path for most contributors. Finally, this patch makes small changes to the CMake file so that on Windows, the ccache binary is added as a prefix, as recommended on the [ccache Wiki](https://github.com/ccache/ccache/wiki/MS-Visual-Studio).pull/1553/head
parent
f847642495
commit
2846776897
|
@ -7,7 +7,8 @@ inputs:
|
||||||
Additional string that is used to compute the ccache hash.
|
Additional string that is used to compute the ccache hash.
|
||||||
Different jobs running the action need distinct values for this key,
|
Different jobs running the action need distinct values for this key,
|
||||||
but the content is irrelevant.
|
but the content is irrelevant.
|
||||||
required: true
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
|
@ -28,24 +29,38 @@ runs:
|
||||||
python -m pip install -r requirements.txt
|
python -m pip install -r requirements.txt
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Ninja (Linux)
|
- name: Install prerequisites (Linux)
|
||||||
if: ${{ runner.os == 'Linux' }}
|
if: ${{ runner.os == 'Linux' }}
|
||||||
run: sudo apt-get install -y ninja-build
|
run: sudo apt-get install --yes ccache ninja-build
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Ninja (macOS)
|
- name: Install prerequisites (macOS)
|
||||||
if: ${{ runner.os == 'macOS' }}
|
if: ${{ runner.os == 'macOS' }}
|
||||||
run: brew install ninja
|
run: brew install ccache ninja
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Ninja (Windows)
|
- name: Install prerequisites (Windows)
|
||||||
if: ${{ runner.os == 'Windows' }}
|
if: ${{ runner.os == 'Windows' }}
|
||||||
run: pip install ninja
|
run: |
|
||||||
|
pip install ninja
|
||||||
|
choco install ccache --yes
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Ccache for C++ compilation
|
- name: Configure ccache
|
||||||
uses: hendrikmuhs/ccache-action@v1.2
|
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: Enable ccache
|
||||||
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
key: ${{ runner.os }}-torch_mlir_build_assets-${{ inputs.cache-suffix }}
|
path: ${{ github.workspace }}/.ccache
|
||||||
max-size: 300M
|
key: ${{ runner.os }}-${{ inputs.cache-suffix }}-${{ github.sha }}
|
||||||
verbose: 2
|
restore-keys: |
|
||||||
|
${{ runner.os }}-${{ inputs.cache-suffix }}-
|
||||||
|
${{ runner.os }}-
|
||||||
|
|
|
@ -23,7 +23,7 @@ jobs:
|
||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
uses: ./.github/actions/setup-build
|
uses: ./.github/actions/setup-build
|
||||||
with:
|
with:
|
||||||
cache-suffix: x86_64-out-of-tree-OFF
|
cache-suffix: 'rollPyTorch'
|
||||||
|
|
||||||
- name: Determine nightly PyTorch version
|
- name: Determine nightly PyTorch version
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -65,7 +65,7 @@ jobs:
|
||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
uses: ./.github/actions/setup-build
|
uses: ./.github/actions/setup-build
|
||||||
with:
|
with:
|
||||||
cache-suffix: ${{ matrix.os-arch }}-${{ matrix.llvm-build }}-${{ matrix.torch-binary }}
|
cache-suffix: 'build-${{ matrix.llvm-build }}'
|
||||||
|
|
||||||
- name: Set up Visual Studio shell
|
- name: Set up Visual Studio shell
|
||||||
if: ${{ matrix.os-arch == 'windows-x86_64' }}
|
if: ${{ matrix.os-arch == 'windows-x86_64' }}
|
||||||
|
@ -123,8 +123,8 @@ jobs:
|
||||||
if: ${{ matrix.os-arch == 'macos-arm64' }}
|
if: ${{ matrix.os-arch == 'macos-arm64' }}
|
||||||
run: |
|
run: |
|
||||||
cmake --build build_arm64
|
cmake --build build_arm64
|
||||||
- name: Build torch-mlir (Windows)
|
|
||||||
|
- name: Build (Windows)
|
||||||
if: ${{ matrix.os-arch == 'windows-x86_64' }}
|
if: ${{ matrix.os-arch == 'windows-x86_64' }}
|
||||||
shell: pwsh
|
shell: bash
|
||||||
run: |
|
run: ./build_tools/python_deploy/build_windows_ci.sh
|
||||||
./build_tools/python_deploy/build_windows_ci.ps1
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ jobs:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
- uses: ./.github/actions/setup-build
|
- uses: ./.github/actions/setup-build
|
||||||
with:
|
with:
|
||||||
cache-suffix: ''
|
cache-suffix: 'release'
|
||||||
- name: Build Python wheels and smoke test.
|
- name: Build Python wheels and smoke test.
|
||||||
run: |
|
run: |
|
||||||
cd $GITHUB_WORKSPACE
|
cd $GITHUB_WORKSPACE
|
||||||
|
@ -62,7 +62,7 @@ jobs:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
- uses: ./.github/actions/setup-build
|
- uses: ./.github/actions/setup-build
|
||||||
with:
|
with:
|
||||||
cache-suffix: ''
|
cache-suffix: 'release'
|
||||||
- name: Build Python wheels and smoke test.
|
- name: Build Python wheels and smoke test.
|
||||||
run: |
|
run: |
|
||||||
cd $GITHUB_WORKSPACE
|
cd $GITHUB_WORKSPACE
|
||||||
|
@ -105,7 +105,7 @@ jobs:
|
||||||
submodules: 'true'
|
submodules: 'true'
|
||||||
- uses: ./.github/actions/setup-build
|
- uses: ./.github/actions/setup-build
|
||||||
with:
|
with:
|
||||||
cache-suffix: ''
|
cache-suffix: 'release'
|
||||||
- name: Set up Visual Studio shell
|
- name: Set up Visual Studio shell
|
||||||
uses: egor-tensin/vs-shell@v2
|
uses: egor-tensin/vs-shell@v2
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -58,6 +58,21 @@ torch_mlir_add_llvm_external_project(
|
||||||
|
|
||||||
option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)
|
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)
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR TORCH_MLIR_OUT_OF_TREE_BUILD)
|
||||||
message(STATUS "Torch-MLIR out-of-tree build.")
|
message(STATUS "Torch-MLIR out-of-tree build.")
|
||||||
# Out-of-tree build
|
# Out-of-tree build
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
# Uncomment if you want to install Python. GHA provides this
|
|
||||||
|
|
||||||
#Write-Host "Installing python"
|
|
||||||
|
|
||||||
#Start-Process choco 'install python --version=3.10.8' -wait -NoNewWindow
|
|
||||||
|
|
||||||
#Write-Host "python installation completed successfully"
|
|
||||||
|
|
||||||
#Write-Host "Reload environment variables"
|
|
||||||
#$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
|
||||||
#Write-Host "Reloaded environment variables"
|
|
||||||
|
|
||||||
Write-Host "Installing Build Dependencies"
|
|
||||||
python -m venv .\mlir_venv\
|
|
||||||
.\mlir_venv\Scripts\activate
|
|
||||||
pip install -r .\requirements.txt
|
|
||||||
Write-Host "Build Deps installation completed successfully"
|
|
||||||
|
|
||||||
Write-Host "Building torch-mlir"
|
|
||||||
$env:CMAKE_GENERATOR='Ninja'
|
|
||||||
$env:TORCH_MLIR_ENABLE_LTC='0'
|
|
||||||
python -m pip wheel -v -w wheelhouse ./ -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html -r whl-requirements.txt
|
|
||||||
|
|
||||||
Write-Host "Build completed successfully"
|
|
|
@ -1,42 +0,0 @@
|
||||||
#Uncomment if you want to test locally. GHA provides Python
|
|
||||||
#Write-Host "Installing python"
|
|
||||||
|
|
||||||
#Start-Process choco 'install python --version=3.10.8' -wait -NoNewWindow
|
|
||||||
|
|
||||||
#Write-Host "python installation completed successfully"
|
|
||||||
|
|
||||||
#Write-Host "Reload environment variables"
|
|
||||||
#$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
|
|
||||||
#Write-Host "Reloaded environment variables"
|
|
||||||
|
|
||||||
Write-Host "Installing Build Dependencies"
|
|
||||||
python -m venv .\mlir_venv\
|
|
||||||
.\mlir_venv\Scripts\activate
|
|
||||||
pip install -r .\requirements.txt
|
|
||||||
Write-Host "Build Deps installation completed successfully"
|
|
||||||
|
|
||||||
Write-Host "Building torch-mlir"
|
|
||||||
|
|
||||||
#Start-Process cmake '-GNinja -Bbuild \
|
|
||||||
# -DCMAKE_BUILD_TYPE=Release \
|
|
||||||
# -DPython3_FIND_VIRTUALENV=ONLY \
|
|
||||||
# -DLLVM_ENABLE_PROJECTS=mlir \
|
|
||||||
# -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 \
|
|
||||||
# -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
|
|
||||||
# -DLLVM_TARGETS_TO_BUILD=host \
|
|
||||||
# /externals/llvm-project/llvm'
|
|
||||||
#Write-Host "Build completed successfully"
|
|
||||||
|
|
||||||
Write-Host "Building torch-mlir"
|
|
||||||
$env:CMAKE_GENERATOR='Ninja'
|
|
||||||
$env:TORCH_MLIR_ENABLE_LTC='0'
|
|
||||||
python -m pip wheel -v -w wheelhouse ./ -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html -r whl-requirements.txt
|
|
||||||
Write-Host "Build completed successfully"
|
|
||||||
|
|
||||||
Write-Host "Testing torch-mlir"
|
|
||||||
$env:PYTHONPATH = "$PWD/build/cmake_build/tools/torch-mlir/python_packages/torch_mlir;$PWD/examples"
|
|
||||||
# Uncomment here to enable tests. TODO: Fix paths
|
|
||||||
#cmake --build cmake_build/build --target check-torch-mlir-all
|
|
||||||
Write-Host "Testing completed successfully"
|
|
|
@ -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"
|
Loading…
Reference in New Issue