std::experi...:resize_simd(3)
π NAME π
okay so this page is std::experi...:resize_simd(3) β that's the header title, ellipsis and all, bestie β from the C++ Standard Libary manual (yes, βLibaryβ, not a typo from me π). The NAME line is literally:
std::experimental::rebind_simd,std::experimental::resize_simd β std::experimental::rebind_simd,std::experimental::resize_simd
It's giving template-alias realness for the parallelism TS v2 girlies π β¨
β¨ Synopsis β¨
Defined in header <experimental/simd>:
template< class T, class V > (1) (parallelism TS v2)
struct rebind_simd;
template< int N, class V > (2) (parallelism TS v2)
struct resize_simd;
These bad boys create a simd or simd_mask type with a different element type or size. The new type likely uses an ABI tag type different from V::abi_type β yes, βlikelyβ is literally the word on the page π.
- (1) Changes the element type to
Tand keeps the size unchanged. - (2) Changes the size to
Nand keeps the element type unchanged.
π§ Template parameters π§
Tβ the new element type; an arithmetic type other thanboolNβ the new number of elementsVβ asimdorsimd_masktype
π Member types π
Name β Definition tea β: type is a simd or simd_mask type with a different element type (1) or size (2).
π¦ Helper types π¦
The helper aliases are here and they are iconic:
template< class T, class V > (parallelism TS v2)
using rebind_simd_t = typename rebind_simd<T, V>::type;
template< int N, class V > (parallelism TS v2)
using resize_simd_t = typename resize_simd<N, V>::type;
π Example π
The original says // Run this code β so run it, bestie π:
#include <experimental/simd>
#include <iostream>
namespace stdx = std::experimental;
using floatv = stdx::native_simd<float>;
// use double precision internally
floatv dp(floatv x)
{
using doublev = stdx::rebind_simd_t<double, floatv>;
return stdx::static_simd_cast<floatv>(stdx::simd_cast<doublev>(x) - 1.234);
}
template<class T>
stdx::resize_simd_t<T::size() / 2, T> partial_reduction(T x)
{
auto [lo, hi] = stdx::split<stdx::resize_simd_t<T::size() / 2, T>>(x);
return lo + hi;
}
int main()
{
floatv x([](auto i) { return 1.234f + std::numeric_limits<float>::epsilon() * i; });
x = dp(x);
const auto y = partial_reduction(x);
for (unsigned i = 0; i < y.size(); ++i)
std::cout << y[i] << ' ';
std::cout << '\n';
}
β Possible output β
1.73569e-07 4.11987e-07
π See also π
See also is serving these entries:
deduceβ obtains an ABI type for given element type and number of elementsdeduce_tβ obtains an ABI type for given element type and number of elements; tagged(parallelism TS v2)(class template)
source/version + date tea β: this page comes from http://cppreference.com, dated 2024.06.10, with footer title std::experi...:resize_simd(3). bye bestie, go rebind/resize those simd types π
β¨π«Ά
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms