Skip to content

Commit ff06802

Browse files
Initial support for Altivec
Only supports altivec with vxs extension, tested on both little and big endian architectures. Several operations could be improved, but this should pass CI. Notable changes: - document the fact that slide_left and slide_right are unreliable on big endian architecture - gcc chokes on force_inline for altivec, so dismiss it - some common code were making assumption of conversion between batch_bool registers and batch_registers that proved to be difficult for altivec type system, make the conversion explicit.
1 parent e2a4395 commit ff06802

23 files changed

+1002
-20
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(CMAKE_SYSTEM_PROCESSOR powerpc64)
2+
set(triple powerpc64-linux-gnu)
3+
4+
include(${CMAKE_CURRENT_LIST_DIR}/gcc.cmake)
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(CMAKE_SYSTEM_PROCESSOR powerpc64le)
2+
set(triple powerpc64le-linux-gnu)
3+
4+
include(${CMAKE_CURRENT_LIST_DIR}/gcc.cmake)
5+
File renamed without changes.

.github/workflows/cross-ppc.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: PowerPC cross-compilation build
2+
on: [push, pull_request]
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
name: '${{ matrix.target.arch }}, ${{ matrix.sys.compiler }} ${{ matrix.sys.version }}'
10+
strategy:
11+
matrix:
12+
target:
13+
- { platform: 'ppc64le', dir: 'powerpc64le-linux-gnu', flags: '-maltivec -mvsx -mcpu=power10', full: 'OFF' }
14+
- { platform: 'ppc64', dir: 'powerpc64-linux-gnu', flags: '-maltivec -mvsx -mcpu=power10', full: 'OFF' }
15+
sys:
16+
- { compiler: 'gcc', version: '12' }
17+
steps:
18+
- name: Setup compiler
19+
if: ${{ matrix.sys.compiler == 'gcc' }}
20+
run: |
21+
sudo apt-get update || exit 1
22+
sudo apt-get --no-install-suggests --no-install-recommends install g++-${{ matrix.sys.version }}-${{ matrix.target.dir }} g++-${{ matrix.sys.version }}-multilib || exit 1
23+
sudo update-alternatives --remove-all ${{ matrix.target.dir }}-gcc || true
24+
sudo update-alternatives --remove-all ${{ matrix.target.dir }}-g++ || true
25+
sudo update-alternatives --install /usr/bin/${{ matrix.target.dir }}-gcc ${{ matrix.target.dir }}-gcc /usr/bin/${{ matrix.target.dir }}-gcc-${{ matrix.sys.version }} 20
26+
sudo update-alternatives --install /usr/bin/${{ matrix.target.dir }}-g++ ${{ matrix.target.dir }}-g++ /usr/bin/${{ matrix.target.dir }}-g++-${{ matrix.sys.version }} 20
27+
- name: Setup QEMU
28+
run: |
29+
sudo apt-get --no-install-suggests --no-install-recommends install qemu-user
30+
- name: Setup Ninja
31+
run: |
32+
sudo apt-get install ninja-build
33+
- name: Checkout xsimd
34+
uses: actions/checkout@v3
35+
- name: Setup
36+
run: |
37+
mkdir _build
38+
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DBUILD_BENCHMARK=${{ matrix.target.full }} -DBUILD_EXAMPLES=${{ matrix.target.full }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="${{ matrix.target.flags }}" -DCMAKE_CXX_FLAGS="${{ matrix.target.flags }}" -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/.github/toolchains/${{ matrix.sys.compiler }}-${{ matrix.target.dir }}.cmake
39+
- name: Build
40+
run: cmake --build _build --verbose -j1
41+
- name: Testing xsimd
42+
run: |
43+
qemu-${{ matrix.target.platform }} -cpu power10 -L /usr/${{ matrix.target.dir}}/ ./test/test_xsimd
44+
working-directory: ${{ github.workspace }}/_build

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ ${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse3.hpp
4949
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse4_1.hpp
5050
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse4_2.hpp
5151
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_ssse3.hpp
52+
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_altivec.hpp
5253
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sve.hpp
5354
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_arch.hpp
5455
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_config.hpp
@@ -70,6 +71,7 @@ ${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma3_sse_register.hpp
7071
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma4_register.hpp
7172
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_common_arch.hpp
7273
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_register.hpp
74+
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_altivec_register.hpp
7375
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_rvv_register.hpp
7476
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse2_register.hpp
7577
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse3_register.hpp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ x86 | AVX512BW, AVX512CD, AVX512DQ, AVX512F (gcc7 and higher)
5454
x86 AMD | FMA4
5555
ARM | NEON, NEON64, SVE128/256/512 (fixed vector size)
5656
WebAssembly | WASM
57+
powerpc64 | Altivec+VSX
5758
RISC-V | RISC-V128/256/512 (fixed vector size)
5859

5960
## Installation

docs/Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ INPUT = ../include/xsimd/types/xsimd_api.hpp \
99
../include/xsimd/memory/xsimd_aligned_allocator.hpp \
1010
../include/xsimd/types/xsimd_common_arch.hpp \
1111
../include/xsimd/types/xsimd_traits.hpp \
12+
../include/xsimd/types/xsimd_altivec_register.hpp \
1213
../include/xsimd/types/xsimd_avx2_register.hpp \
1314
../include/xsimd/types/xsimd_avx512bw_register.hpp \
1415
../include/xsimd/types/xsimd_avx512cd_register.hpp \

include/xsimd/arch/common/xsimd_common_arithmetic.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,9 @@ namespace xsimd
203203
{
204204
if (std::is_signed<T>::value)
205205
{
206-
auto mask = (other >> (8 * sizeof(T) - 1));
207206
auto self_pos_branch = min(std::numeric_limits<T>::max() - other, self);
208207
auto self_neg_branch = max(std::numeric_limits<T>::min() - other, self);
209-
return other + select(batch_bool<T, A>(mask.data), self_neg_branch, self_pos_branch);
208+
return other + select(other >= 0, self_pos_branch, self_neg_branch);
210209
}
211210
else
212211
{

include/xsimd/arch/common/xsimd_common_math.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ namespace xsimd
10871087
template <class A, class T>
10881088
XSIMD_INLINE batch<T, A> from_bool(batch_bool<T, A> const& self, requires_arch<common>) noexcept
10891089
{
1090-
return batch<T, A>(self.data) & batch<T, A>(1);
1090+
return batch<T, A>((typename batch<T, A>::register_type)self.data) & batch<T, A>(1);
10911091
}
10921092

10931093
// horner

0 commit comments

Comments
 (0)