| 1 |
.. title:: clang-tidy - portability-simd-intrinsics |
| 2 |
|
| 3 |
portability-simd-intrinsics |
| 4 |
=========================== |
| 5 |
|
| 6 |
Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_) |
| 7 |
alternatives. |
| 8 |
|
| 9 |
If the option :option:`Suggest` is set to `true`, for |
| 10 |
|
| 11 |
.. code-block:: c++ |
| 12 |
|
| 13 |
_mm_add_epi32(a, b); // x86 |
| 14 |
vec_add(a, b); // Power |
| 15 |
|
| 16 |
the check suggests an alternative: ``operator+`` on ``std::experimental::simd`` |
| 17 |
objects. |
| 18 |
|
| 19 |
Otherwise, it just complains the intrinsics are non-portable (and there are |
| 20 |
`P0214`_ alternatives). |
| 21 |
|
| 22 |
Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX, |
| 23 |
ARM NEON). It is common that SIMD code implementing the same algorithm, is |
| 24 |
written in multiple target-dispatching pieces to optimize for different |
| 25 |
architectures or micro-architectures. |
| 26 |
|
| 27 |
The C++ standard proposal `P0214`_ and its extensions cover many common SIMD |
| 28 |
operations. By migrating from target-dependent intrinsics to `P0214`_ |
| 29 |
operations, the SIMD code can be simplified and pieces for different targets can |
| 30 |
be unified. |
| 31 |
|
| 32 |
Refer to `P0214`_ for introduction and motivation for the data-parallel standard |
| 33 |
library. |
| 34 |
|
| 35 |
Options |
| 36 |
------- |
| 37 |
|
| 38 |
.. option:: Suggest |
| 39 |
|
| 40 |
If this option is set to `true` (default is `false`), the check will suggest |
| 41 |
`P0214`_ alternatives, otherwise it only points out the intrinsic function is |
| 42 |
non-portable. |
| 43 |
|
| 44 |
.. option:: Std |
| 45 |
|
| 46 |
The namespace used to suggest `P0214`_ alternatives. If not specified, `std::` |
| 47 |
for `-std=c++20` and `std::experimental::` for `-std=c++11`. |
| 48 |
|
| 49 |
.. _P0214: https://wg21.link/p0214 |