Skip to content

Commit 767345a

Browse files
committed
enable MSVC cl.exe build on Windows ARM64
1 parent 23282a2 commit 767345a

File tree

4 files changed

+1097
-46
lines changed

4 files changed

+1097
-46
lines changed

.github/workflows/windows.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
- name: Setup compiler
9595
uses: ilammy/msvc-dev-cmd@v1
9696
with:
97-
arch: amd64
97+
arch: arm64
9898
- name: Setup Ninja
9999
run: |
100100
python3 -m pip install --upgrade pip setuptools wheel
@@ -107,3 +107,52 @@ jobs:
107107
run: cmake --build _build
108108
- name: Testing xsimd
109109
run: ./_build/test/test_xsimd
110+
- name: Run benchmark
111+
run: ./_build/benchmark/benchmark_xsimd
112+
- name: Run example
113+
run: ./_build/examples/mandelbrot
114+
115+
build-windows-arm64-clang:
116+
name: 'MSYS2 CLANG64 arm64'
117+
runs-on: windows-11-arm
118+
defaults:
119+
run:
120+
shell: msys2 {0}
121+
steps:
122+
- name: Setup MSYS2 with Clang (ARM64)
123+
uses: msys2/setup-msys2@v2
124+
with:
125+
# CLANG64 environment: uses clang/clang++ targeting Windows ARM64 natively.
126+
# This is the ARM64-native MSYS2 Clang toolchain — not a cross-compiler.
127+
msystem: CLANG64
128+
update: true
129+
path-type: minimal
130+
pacboy: >-
131+
cc:p
132+
cmake:p
133+
ninja:p
134+
135+
- name: Checkout xsimd
136+
uses: actions/checkout@v4
137+
138+
- name: Configure
139+
run: |
140+
cmake -B _build \
141+
-DBUILD_TESTS=ON \
142+
-DDOWNLOAD_DOCTEST=ON \
143+
-DBUILD_BENCHMARK=ON \
144+
-DBUILD_EXAMPLES=ON \
145+
-DCMAKE_BUILD_TYPE=Release \
146+
-G Ninja
147+
148+
- name: Build
149+
run: cmake --build _build
150+
151+
- name: Test xsimd
152+
run: ./_build/test/test_xsimd
153+
154+
- name: Run benchmark
155+
run: ./_build/benchmark/benchmark_xsimd
156+
157+
- name: Run mandelbrot example
158+
run: ./_build/examples/mandelbrot

include/xsimd/arch/common/xsimd_common_memory.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <algorithm>
1616
#include <array>
1717
#include <complex>
18+
#include <cstdio>
1819
#include <stdexcept>
1920

2021
#include "../../types/xsimd_batch_constant.hpp"
@@ -71,6 +72,9 @@ namespace xsimd
7172
for (size_t i = 0; i < sizeof...(Is); ++i)
7273
if ((bitmask >> i) & 1u)
7374
std::swap(mask_buffer[inserted++], mask_buffer[i]);
75+
// Fill remaining positions with the last valid index to avoid undefined behavior
76+
for (size_t i = inserted; i < sizeof...(Is); ++i)
77+
mask_buffer[i] = mask_buffer[inserted > 0 ? inserted - 1 : 0];
7478
return batch<IT, A>::load_aligned(&mask_buffer[0]);
7579
}
7680
}
@@ -85,7 +89,12 @@ namespace xsimd
8589
auto bitmask = mask.mask();
8690
auto z = select(mask, x, batch<T, A>((T)0));
8791
auto compress_mask = detail::create_compress_swizzle_mask<IT, A>(bitmask, std::make_index_sequence<size>());
88-
return swizzle(z, compress_mask);
92+
alignas(A::alignment()) IT mask_out[size];
93+
compress_mask.store_aligned(&mask_out[0]);
94+
alignas(A::alignment()) T z_out[size];
95+
z.store_aligned(&z_out[0]);
96+
auto res = swizzle(z, compress_mask);
97+
return res;
8998
}
9099

91100
// expand

0 commit comments

Comments
 (0)