E.V.E
v2023.02.15
 
Loading...
Searching...
No Matches

◆ scatter

auto eve::scatter = functor<scatter_t>
inlineconstexpr

Store each element of a given SIMD value vin different memory address computed form a base SIMD compatible iterator ptr and a SIMD integral value idx used as indexes.

A call to eve::scatter(v,ptr,idx) is semantically equivalent to:

for(std::size_t i=0;i<v.size();++i)
ptr[idx.get(i)] = v.get(i);

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<simd_value T, integral_simd_value Idx, simd_compatible_ptr<T> Ptr>
requires(T::size() == Idx::size())
void scatter(T const& v, Ptr ptr, Idx const& idx) noexcept;
}
constexpr auto scatter
Store a SIMD register to memory using scattered indexes.
Definition scatter.hpp:90
EVE Main Namespace.
Definition abi.hpp:18

Parameters

Semantic Modifiers

  • Masked Call

eve::scatter can be masked using Relative conditionals to skip scattering of certain elements.

The call eve::scatter[cond](v,p,i) is semantically equivalent to:

auto m = cond.mask( as<as_logical_t<T>>{} );
for(std::size_t n=0;n<v.size();++n)
{
if(m.get(n)) write(v.get(n),p+idx.get(n));
}
constexpr auto write
Callable object writing a scalar value to memory.
Definition write.hpp:78
Lightweight type-wrapper.
Definition as.hpp:29

Example

#include <eve/module/core.hpp>
#include <iostream>
int main()
{
float data[2*eve::wide<float>::size()] = {};
eve::wide<int> indexes = [](auto i, auto) { return 2*i; };
eve::wide<float> values = [](auto i, auto) { return 1.5f * (1+i); };
eve::scatter(values, data, indexes);
for(auto e : data)
std::cout << e << " ";
std::cout << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:86
static constexpr size_type size() noexcept
Size of the wide in number of lanes.
Definition wide.hpp:394