Skip to content

Commit

Permalink
Add support form emulated<N> arch
Browse files Browse the repository at this point in the history
As a side effect:

- provide a scalar version for xsimd::bitwise_cast.
- reorder some functions in xsimd_sse2.hpp

Fix #998
  • Loading branch information
serge-sans-paille committed Mar 24, 2024
1 parent 63ea057 commit 9409867
Show file tree
Hide file tree
Showing 16 changed files with 1,079 additions and 79 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/emulated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Linux emulated build
on: [push, pull_request]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-20.04
name: '${{ matrix.sys.compiler }} ${{ matrix.sys.version }} - emulated'
strategy:
matrix:
sys:
- { compiler: 'gcc', version: '7'}
- { compiler: 'clang', version: '8'}
steps:
- name: Setup compiler
if: ${{ matrix.sys.compiler == 'gcc' }}
run: |
GCC_VERSION=${{ matrix.sys.version }}
sudo apt-get update
sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION
CC=gcc-$GCC_VERSION
echo "CC=$CC" >> $GITHUB_ENV
CXX=g++-$GCC_VERSION
echo "CXX=$CXX" >> $GITHUB_ENV
CXXFLAGS="-Wno-noexcept-type -Wno-stringop-overflow"
echo "CXXFLAGS=$CXXFLAGS" >> $GITHUB_ENV
- name: Setup compiler
if: ${{ matrix.sys.compiler == 'clang' }}
run: |
LLVM_VERSION=${{ matrix.sys.version }}
#sudo add-apt-repository ppa:ubuntu-toolchain-r/test || exit 1
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1
sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1
sudo apt-get update || exit 1
sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1
sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1
sudo ln -s /usr/include/asm-generic /usr/include/asm
CC=clang-$LLVM_VERSION
echo "CC=$CC" >> $GITHUB_ENV
CXX=clang++-$LLVM_VERSION
echo "CXX=$CXX" >> $GITHUB_ENV
- name: Checkout xsimd
uses: actions/checkout@v3
- name: Install mamba
uses: mamba-org/provision-with-micromamba@main
with:
environment-file: environment.yml
- name: Configure build
env:
CC: ${{ env.CC }}
CXX: ${{ env.CXX }}
run: |
mkdir _build
cd _build
cmake .. -DBUILD_TESTS=ON \
-DBUILD_BENCHMARK=ON \
-DBUILD_EXAMPLES=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DXSIMD_ENABLE_WERROR=ON \
-DCMAKE_CXX_FLAGS="-DXSIMD_DEFAULT_ARCH=emulated\<128\> -DXSIMD_WITH_EMULATED=1 ${CXXFLAGS}" \
-G Ninja
- name: Build
run: ninja -C _build
- name: Test
run: |
cd _build/test
./test_xsimd
9 changes: 9 additions & 0 deletions docs/source/api/arch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,12 @@ The best available architecture is available at compile time through
.. doxygengroup:: architectures
:project: xsimd
:members:


Emulated mode
-------------

When compiled with the macro ``XSIMD_WITH_EMULATED`` set to ``1``, xsimd also
exhibits a specific architecture ``xsimd::emulated<N>``, which consists of a
vector of ``N`` bits emulated using scalar mode.
It is mostly available for testing and debugging.
12 changes: 12 additions & 0 deletions include/xsimd/arch/generic/xsimd_generic_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ namespace xsimd
return true;
}

template <typename ITy>
constexpr bool is_zip_lo(size_t, ITy)
{
return false;
}

template <typename ITy0, typename ITy1, typename... ITys>
constexpr bool is_zip_lo(size_t bsize, ITy0 index0, ITy1 index1, ITys... indices)
{
Expand All @@ -423,6 +429,12 @@ namespace xsimd
return true;
}

template <typename ITy>
constexpr bool is_zip_hi(size_t, ITy)
{
return false;
}

template <typename ITy0, typename ITy1, typename... ITys>
constexpr bool is_zip_hi(size_t bsize, ITy0 index0, ITy1 index1, ITys... indices)
{
Expand Down
Loading

0 comments on commit 9409867

Please sign in to comment.