50 lines · plain
1.. title:: clang-tidy - portability-simd-intrinsics2 3portability-simd-intrinsics4===========================5 6Finds SIMD intrinsics calls and suggests ``std::experimental::simd`` (`P0214`_)7alternatives.8 9If the option :option:`Suggest` is set to `true`, for10 11.. code-block:: c++12 13 _mm_add_epi32(a, b); // x8614 vec_add(a, b); // Power15 16the check suggests an alternative: ``operator+`` on ``std::experimental::simd``17objects.18 19Otherwise, it just complains the intrinsics are non-portable (and there are20`P0214`_ alternatives).21 22Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power23AltiVec/VSX, ARM NEON). It is common that SIMD code implementing the same24algorithm, is written in multiple target-dispatching pieces to optimize for25different architectures or micro-architectures.26 27The C++ standard proposal `P0214`_ and its extensions cover many common SIMD28operations. By migrating from target-dependent intrinsics to `P0214`_29operations, the SIMD code can be simplified and pieces for different targets30can be unified.31 32Refer to `P0214`_ for introduction and motivation for the data-parallel33standard library.34 35Options36-------37 38.. option:: Suggest39 40 If this option is set to `true` (default is `false`), the check will suggest41 `P0214`_ alternatives, otherwise it only points out the intrinsic function is42 non-portable.43 44.. option:: Std45 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/p021450