Skip to content

Commit

Permalink
Release 0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Apr 27, 2020
2 parents 0372d1f + cb7841f commit 8ab8e86
Show file tree
Hide file tree
Showing 19 changed files with 545 additions and 220 deletions.
82 changes: 11 additions & 71 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,33 @@ version: 2.1
##==================================================================================================
docker_gcc: &docker_gcc
docker:
- image: gcc:latest
- image: compilaction/gcc-dev:latest
environment:
COMPILER: g++
docker_i686: &docker_i686
docker:
- image: gcc:latest
environment:
COMPILER_PACKAGE: g++-multilib
COMPILER: g++-8
COMPILER: g++-9
docker_clang: &docker_clang
docker:
- image: ubuntu:disco
- image: compilaction/clang-dev:latest
environment:
COMPILER: clang++-8
COMPILER: clang++-9
docker_ppc64: &docker_ppc64
docker:
- image: ubuntu:disco
- image: compilaction/gcc-dev:latest
environment:
COMPILER_PACKAGE: g++-8-powerpc64-linux-gnu
COMPILER: powerpc64-linux-gnu-g++-8
RUN_COMMAND: qemu-ppc64
EXTRA_PATH: /usr/powerpc64-linux-gnu/lib/
EXTRA_LIB: lib64
EXTRA_NAME: ld64.so.1
COMPILER: powerpc64-linux-gnu-g++-9
docker_aarch64: &docker_aarch64
docker:
- image: ubuntu:disco
- image: compilaction/gcc-dev:latest
environment:
COMPILER_PACKAGE: g++-8-aarch64-linux-gnu
COMPILER: aarch64-linux-gnu-g++-8
RUN_COMMAND: qemu-aarch64
EXTRA_PATH: /usr/aarch64-linux-gnu/lib/
EXTRA_LIB: lib
EXTRA_NAME: ld-linux-aarch64.so.1
COMPILER: aarch64-linux-gnu-g++-9


##==================================================================================================
## Build configurations
##==================================================================================================
config_gcc_amd64: &config_gcc_amd64
<<: *docker_gcc
config_gcc_x86: &config_gcc_x86
<<: *docker_i686
config_clang_amd64: &config_clang_amd64
<<: *docker_clang
config_clang_x86: &config_clang_x86
Expand All @@ -74,9 +59,6 @@ jobs:
<<: *config_gcc_amd64
steps:
- checkout
- run:
name: Setup dependencies
command: . .circleci/prepare.sh
- run:
name: Running Basic Tests - SSE2
command: VARIANT="sse2" OPTIONS="-O3 -msse2" . .circleci/run.sh
Expand All @@ -92,43 +74,14 @@ jobs:
- run:
name: Running Basic Tests - AVX2
command: VARIANT="avx2" OPTIONS="-O3 -mavx2" . .circleci/run.sh

gcc_x86:
<<: *config_gcc_x86
steps:
- checkout
- run:
name: Setup dependencies
command: . .circleci/prepare.sh
- run:
name: Setup cross compiler
command: . .circleci/prepare_cc.sh
- run:
name: Running Basic Tests - SSE2
command: VARIANT="sse2" OPTIONS="-O3 -msse2 -m32" . .circleci/run.sh
- run:
name: Running Basic Tests - SSE4
command: VARIANT="sse4" OPTIONS="-O3 -msse4 -m32" . .circleci/run.sh
- run:
name: Running Basic Tests - AVX
command: VARIANT="avx" OPTIONS="-O3 -mavx -m32" . .circleci/run.sh
- run:
name: Running Basic Tests - FMA3
command: VARIANT="fma" OPTIONS="-O3 -mavx -mfma -m32" . .circleci/run.sh
- run:
name: Running Basic Tests - AVX2
command: VARIANT="avx2" OPTIONS="-O3 -mavx2 -m32" . .circleci/run.sh
name: Running Basic Tests - AVX512
command: VARIANT="avx2" OPTIONS="-O3 -mavx512f" . .circleci/run.sh

clang_amd64:
<<: *config_clang_amd64
steps:
- checkout
- run:
name: Setup dependencies
command: . .circleci/prepare.sh
- run:
name: Install clang-8
command: 'apt-get update && sudo apt-get install -y clang-8'
- run:
name: Running Basic Tests - SSE2
command: VARIANT="sse2" OPTIONS="-O3 -msse2" . .circleci/run.sh
Expand All @@ -149,12 +102,6 @@ jobs:
<<: *config_aarch64
steps:
- checkout
- run:
name: Setup dependencies
command: . .circleci/prepare.sh
- run:
name: Setup cross compiler
command: . .circleci/prepare_cc.sh
- run:
name: Running Basic Tests - AARCH64 NEON
command: VARIANT="aarch64" OPTIONS="-O3 -Wno-psabi" . .circleci/run.sh
Expand All @@ -163,12 +110,6 @@ jobs:
<<: *config_gcc_ppc64
steps:
- checkout
- run:
name: Setup dependencies
command: . .circleci/prepare.sh
- run:
name: Setup cross compiler
command: . .circleci/prepare_cc.sh
- run:
name: Running Basic Tests - PPC64
command: VARIANT="vsx" OPTIONS="-O3" . .circleci/run.sh
Expand All @@ -184,7 +125,6 @@ workflows:
## All tests
##==============================================================================================
- gcc_amd64
- gcc_x86
- clang_amd64
- arm_aarch64
- ppc64
12 changes: 0 additions & 12 deletions .circleci/prepare.sh

This file was deleted.

12 changes: 0 additions & 12 deletions .circleci/prepare_cc.sh

This file was deleted.

13 changes: 1 addition & 12 deletions .circleci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,7 @@ else
fi

##==================================================================================================
## PATH Infos
##==================================================================================================
if [[ -v EXTRA_PATH ]]
then
echo "Updating path for $EXTRA_PATH/$EXTRA_NAME ..."
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$EXTRA_PATH
export LD_LIBRARY_PATH
ln -sf $EXTRA_PATH/$EXTRA_NAME /$EXTRA_LIB/$EXTRA_NAME
fi

##==================================================================================================
## Run every test up to SIMD
## Run every tests
##==================================================================================================
ninja unit -j 8
ctest -j 8
86 changes: 57 additions & 29 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<meta charset="utf-8" lang="en"><style class="fallback">body{visibility:hidden;}</style>

![The C++ Informations Broker](https://github.com/jfalcou/spy/raw/develop/logo.png)
![**The C++ Informations Broker**](https://github.com/jfalcou/spy/raw/develop/logo.png)

# Purpose
Purpose
====================================================================================================
Detection and versioning of operating systems, compilers, architecture and other element are
traditionally done using preprocessor macros. Library like
[Boost.Predef](https://www.boost.org/doc/libs/release/doc/html/predef.html) provides a sanitized
Expand All @@ -14,12 +15,17 @@

**References:**


![**Our CppCon 2019 Ligthning talk video**](https://www.youtube.com/watch?v=t406o2EhG-A)

- [Our CppCon 2019 Ligthning talk slides](https://docs.google.com/presentation/d/1nSBhU4pr5EWznni0MYsyDkMCr3O3q2XS-KQdz2_BRRI/edit?usp=sharing)
- [Our CppCon 2019 Ligthning talk video](https://www.youtube.com/watch?v=t406o2EhG-A)
- [Boost.Predef](https://www.boost.org/doc/libs/release/doc/html/predef.html)

# How to install
## Using CMake
How to install
====================================================================================================

Using CMake
----------------------------------------------------------------------------------------------------
After cloning the repository, run `CMake` with an install prefix path then run the `install` target
using `Make` or any other build system.

Expand All @@ -31,7 +37,8 @@
make install
~~~~~

## Manually
Manually
----------------------------------------------------------------------------------------------------
After cloning the repository, copy the `include` folder into the folder of your choice.

~~~~~ bash
Expand Down Expand Up @@ -62,8 +69,17 @@
Just compile this example using a C++17 compliant compiler.
Don't forget to add the path to the SPY library files to your favorite compiler's options.

# User manual
## Supported detectors
Redistribuable include
----------------------------------------------------------------------------------------------------
If you want to use SPY in your own project but want to keep a low imprint on your own source code,
one can copy the standalone `spy.hpp` file provided at the root of the include folder. This file
contains the whole SPY library ready to be used and shipped.

User manual
====================================================================================================

Supported detectors
----------------------------------------------------------------------------------------------------
SPY can detect:

- Architecture family via the `spy::architecture` object.
Expand Down Expand Up @@ -91,7 +107,8 @@
~~~~~
</script>

## Comparing vendors
Comparing vendors
----------------------------------------------------------------------------------------------------
Knowing is half the battle, we may want to compare the current compiler or OS to a given one
so you can branch off your code based on this informations. Here is the list of each detected
vendor for each SPY objects.
Expand Down Expand Up @@ -140,7 +157,8 @@

- Checking for POSIX capability via `spy::supports::posix_`

## Comparing versions
Comparing versions
----------------------------------------------------------------------------------------------------
Checking for a vendor is sometimes not enough, we need to check which version of a given
component is used. To do this, you can compare a detector to a given version value using
any comparison operators.
Expand Down Expand Up @@ -183,16 +201,17 @@
~~~~~
</script>

## Handling SIMD extensions
Handling SIMD extensions
----------------------------------------------------------------------------------------------------
SIMD extensions set detection is made so that one can ask if the current SIMD extension is exactly,
below or above a given reference instruction set. Detectable instructions sets depends on SIMD
hardware vendor

| Architecture | Supported SIMD instructions sets |
| ------------- | ------------------------------------------------------------------------ |
| X86 | `sse1_`, `sse2_`, `sse3_`, `ssse3_`, `sse41_`, `sse42_`, `avx_`, `avx2_` |
| Power PC | `vmx_`, `vsx_` |
| ARM | `neon_` |
| Architecture | Supported SIMD instructions sets |
| ------------- | ----------------------------------------------------------------------------------- |
| X86 | `sse1_`, `sse2_`, `sse3_`, `ssse3_`, `sse41_`, `sse42_`, `avx_`, `avx2_`, `avx512_` |
| Power PC | `vmx_`, `vsx_` |
| ARM | `neon_` |

Complete set of comparison operators is provided for those sets. Order of instructions sets
are built so that if an instructions set supersedes another, it is considered greater than. For
Expand Down Expand Up @@ -250,8 +269,8 @@
~~~~~
</script>

Some SIMD instructions set provides supplemental instructions on top of existing system. Those
supplemental instruction set can be checked using the `spy::supports` namespace.
Some SIMD instructions set provides supplemental instructions on top of existing system.
Those supplemental instruction set can be checked using the `spy::supports` namespace.

<script type="preformatted">
~~~~~ c++
Expand All @@ -275,6 +294,11 @@
std::cout << "This code has been compiled with XOP support.\n";
}

if constexpr( spy::supports::avx512::vnni_ )
{
std::cout << "This code has been compiled with AV512-VNNI support.\n";
}

if constexpr( spy::supports::aarch64_ )
{
std::cout << "This code has been compiled with AARCH64 support.\n";
Expand All @@ -283,8 +307,16 @@
~~~~~
</script>

The complete list of supplemental instruction sets si given in the following table.

| Architecture | Supported SIMD instructions sets |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| X86 AVX | `xop_`, `fma_`, `fma4_` |
| X86 AVX512 | `avx512::bw_`, `avx512::cd_`, `avx512::dq_`, `avx512::er_`, `avx512::ifma_`, `avx512::pf_`, `avx512::vl_`, `avx512::popcntdq_`, `avx512::_4fmaps_`, `avx512::vnniw_`, `avx512::vbmi_`, `avx512::bf16_`, `avx512::bitalg_`, `avx512::vbmi2_`, `avx512::vnni_`, `avx512::vpintersect_` |
| ARM | `spy::supports::aarch64_` |

## Caveat with `if constexpr`
Caveat with `if constexpr`
----------------------------------------------------------------------------------------------------
The detection and comparisons of versions using SPY detectors are subject to some
caveats that stem from the way `if constexpr` behaves. As both branch of the `if constexpr`
are ODR_checked, all functions and type names must be defined even if not used. This means
Expand All @@ -296,11 +328,11 @@

template<typename T> auto f(T t)
{
if constexpr( spy::clang )
if constexpr( spy::clang_ )
{
return __builtin_bitreverse32(t);
}
else if constexpr( spy::gcc )
else if constexpr( spy::gcc_ )
{
return __builtin_bswap32(t);
}
Expand All @@ -314,24 +346,20 @@
~~~~~ c++
#include <spy/spy.hpp>

template<typename T> auto f(T t) requires( spy::clang )
template<typename T> auto f(T t) requires( spy::clang_ )
{
return __builtin_bitreverse32(t);
}

template<typename T> auto f(T t) requires( spy::gcc )
template<typename T> auto f(T t) requires( spy::gcc_ )
{
return __builtin_bswap32(t);
}
~~~~~
</script>

## Redistribuable include
If you want to use SPY in your own project but want to keep a low imprint on your own source code,
one can copy the standalone `spy.hpp` file provided at the root of the include folder. This file
contains the whole SPY library ready to be used and shipped.

# License
License
====================================================================================================
This library is licensed under the MIT License as specified in the LICENSE.md file.
If you use SPY in your project or product, feel free to send us an email so we can
advertise it here.
Expand Down
Loading

0 comments on commit 8ab8e86

Please sign in to comment.