Skip to content

Commit 3e39a9a

Browse files
DRovaraburgholzerpre-commit-ci[bot]
authored
👷 add windows CI for MLIR (#952)
## Description This PR adds MLIR CI tests for windows runners. This is achieved by building MLIR from source so the first execution should take a bit longer. Afterwards, the cache will be used to store the built versions of MLIR. This PR contributes to #925 **Note:** To install a specific version, the runner clones the tag `llvmorg-{version}.1.0`. It seems that the first release of a new major `llvm-project` version is typically called `{version}.1.0` so this should keep working, but there is no guarantee. ## Checklist: - [x] The pull request only contains commits that are focused and relevant to this change. - [x] I have added appropriate tests that cover the new/changed functionality. - [x] I have updated the documentation to reflect these changes. - [x] I have added entries to the changelog for any noteworthy additions, changes, fixes or removals. - [x] I have added migration instructions to the upgrade guide (if needed). - [x] The changes follow the project's style guidelines and introduce no new warnings. - [x] The changes are fully tested and pass the CI checks. - [x] I have reviewed my own code changes. --------- Signed-off-by: burgholzer <[email protected]> Co-authored-by: burgholzer <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent b7bf3d9 commit 3e39a9a

File tree

1 file changed

+106
-1
lines changed

1 file changed

+106
-1
lines changed

.github/workflows/ci_mlir.yml

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ concurrency:
1818

1919
jobs:
2020
cpp-test-mlir:
21-
name: 🇨‌ Test MLIR with LLVM@${{ matrix.llvm-version }}
21+
name: 🐧 Test MLIR with LLVM@${{ matrix.llvm-version }}
2222
runs-on: ubuntu-24.04
2323
strategy:
2424
matrix:
@@ -90,3 +90,108 @@ jobs:
9090
# build the project and run the tests
9191
- name: Build MLIR components and directly run lit tests
9292
run: cmake --build build --config Release --target check-quantum-opt
93+
94+
cpp-test-mlir-windows:
95+
name: 🏁 Test MLIR with LLVM@${{ matrix.llvm-version }}
96+
runs-on: windows-latest
97+
strategy:
98+
matrix:
99+
llvm-version: [19, 20]
100+
env:
101+
CMAKE_BUILD_PARALLEL_LEVEL: 4
102+
CTEST_PARALLEL_LEVEL: 4
103+
FORCE_COLOR: 3
104+
outputs:
105+
llvm-latest-tag: ${{ steps.get-latest.outputs.latest }}
106+
steps:
107+
# check out the repository
108+
- uses: actions/checkout@v4
109+
with:
110+
fetch-depth: 0
111+
112+
- name: Find latest release of llvm-project
113+
id: get-latest
114+
run: |
115+
$tag = git ls-remote --tags https://github.com/llvm/llvm-project.git "llvmorg-${{ matrix.llvm-version }}.*" |
116+
Where-Object { $_ -match "llvmorg-\d+\.\d+\.\d+" } |
117+
Sort-Object -Property {
118+
if ($_ -match "llvmorg-(\d+)\.(\d+)\.(\d+)") {
119+
[int]$Matches[1]*10000 + [int]$Matches[2]*100 + [int]$Matches[3]
120+
}
121+
} |
122+
Select-Object -Last 1
123+
$latest = $tag | ForEach-Object {
124+
if ($_ -match "refs/tags/llvmorg-(\d+\.\d+\.\d+)") {
125+
$Matches[1] # Extract just the version number (e.g., "20.1.0")
126+
}
127+
} |
128+
Where-Object { $_ -ne $null }
129+
echo "Latest tag: $tag"
130+
echo "latest=$latest" >> $env:GITHUB_OUTPUT
131+
132+
- name: Try to get MLIR from cache
133+
uses: actions/cache@v4
134+
id: mlir-cache
135+
with:
136+
path: ${{ github.workspace }}/llvm-install
137+
key: ${{ runner.os }}-llvm-${{ steps.get-latest.outputs.latest }}
138+
restore-keys: |
139+
${{ runner.os }}-llvm-${{ steps.get-latest.outputs.latest }}
140+
141+
# build the llvm-project from source
142+
- name: Install llvm and mlir
143+
if: steps.mlir-cache.outputs.cache-hit != 'true'
144+
run: |
145+
git clone --depth 1 https://github.com/llvm/llvm-project.git --branch llvmorg-${{ steps.get-latest.outputs.latest }}
146+
cd llvm-project
147+
cmake -S llvm -B build_llvm `
148+
-DLLVM_ENABLE_PROJECTS=mlir `
149+
-DLLVM_BUILD_EXAMPLES=OFF `
150+
-DLLVM_TARGETS_TO_BUILD="X86" `
151+
-DCMAKE_BUILD_TYPE=Release `
152+
-DLLVM_BUILD_TESTS=OFF `
153+
-DLLVM_INCLUDE_TESTS=OFF `
154+
-DLLVM_INCLUDE_EXAMPLES=OFF `
155+
-DLLVM_ENABLE_ASSERTIONS=ON `
156+
-DLLVM_ENABLE_UTILS=ON `
157+
-DLLVM_INSTALL_UTILS=ON `
158+
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\llvm-install
159+
cmake --build build_llvm --target install --config Release
160+
161+
# set up uv for faster Python package management
162+
- name: Install the latest version of uv
163+
uses: astral-sh/setup-uv@v6
164+
with:
165+
python-version: 3.13
166+
activate-environment: true
167+
168+
# make sure the lit test runner is installed
169+
- name: Install lit
170+
run: |
171+
uv pip install lit
172+
173+
# configure the project with CMake
174+
- name: Configure CMake for MLIR
175+
run: |
176+
cmake -S . -B build `
177+
-DCMAKE_BUILD_TYPE=Release `
178+
-DBUILD_MQT_CORE_MLIR=ON `
179+
-DCMAKE_PREFIX_PATH=${{ github.workspace }}\llvm-install `
180+
-DLLVM_EXTERNAL_LIT=${{ github.workspace }}\.venv\Scripts\lit.exe
181+
182+
# build the project and run the tests
183+
- name: Build MLIR components and directly run lit tests
184+
run: |
185+
cmake --build build --config Release --target quantum-opt
186+
187+
$targetPath = "${{ github.workspace }}\\build\\mlir\\tools\\quantum-opt\\Release\\quantum-opt.exe"
188+
$batchContent = '"{0}" "$@"' -f $targetPath
189+
190+
# Write to a directory that's definitely in PATH
191+
$batchContent | Out-File -FilePath "C:\Windows\quantum-opt" -Encoding ascii
192+
193+
# Verify the batch file
194+
Get-Content "C:\Windows\quantum-opt"
195+
Write-Output "Batch file created at C:\Windows\quantum-opt pointing to $targetPath"
196+
197+
cmake --build build --config Release --target check-quantum-opt

0 commit comments

Comments
 (0)