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

◆ compress_store

auto eve::compress_store = detail::compress_callable_no_density<compress_store_core> {}
inlineconstexpr

Defined in Header

#include <eve/module/core.hpp>

This function behaves like eve::compress_copy[dense] but as input it takes loaded register.

See also
eve::compres_copy for explained behavour.
Warning
you should use eve::compress_copy if possible, it has more opportunities for optimizations.

Callable Signatures

namespace eve
{
typename O>
[safe/unsafe]
[C1 ignore_in][C2 ignore_out]
(T x, L m, O o) -> unaligned_t<O> // (1)
}
Specify that a type represents a logical SIMD value. The concept logical_simd_value<T> is satisfied i...
Definition simd.hpp:46
Specifies that a type is a Conditional Expression using relative mask.
Definition conditional.hpp:52
Specifies that a type is a SIMD type. The concept simd_value<T> is satisfied if and only if T satisfi...
Definition vectorized.hpp:34
constexpr auto compress_store
A function that stores selected elements from an eve::simd_value to an eve::simd_compatible_ptr,...
Definition compress_store.hpp:116
decltype(unalign(std::declval< T >())) unaligned_t
Compute the unaligned pointer type associated to a given type.
Definition unalign.hpp:113
EVE Main Namespace.
Definition abi.hpp:18

Parameters

  • safe/unsafe - mode of the operation - required
  • ignore_in - optional, ignored elements considered not selected.
  • ignore_out - optional, defaults to ignore_in. controls part of the output where the data will be written.
  • x: simd_value to compress
  • m: mask indicating selected elements
  • o: pointer-like where to write the elements

Return value

  • o after the last selected element written

Example

#include <eve/module/core.hpp>
#include <tts/tts.hpp>
using n = eve::fixed<4>;
using w_t = eve::wide<int, n>;
using l_t = eve::logical<eve::wide<std::uint8_t, n>>; // Note the type mismatch
int main()
{
w_t in { 1, 2, 3, 4 };
l_t m { false, true, true, false };
{
// We have to have 4 elements in the output, even if only 2 are selected.
std::array<int, 4> out {};
int* o = eve::compress_store[eve::unsafe](in, m, out.data());
TTS_EQUAL(2, o - out.data()); // 2 elements are selected and written
// We don't know what elements are after
out[2] = -1;
out[3] = -1;
TTS_EQUAL((std::array{2, 3, -1, -1}), out);
}
{
// Here we know we won't write more than selected,
// at the price of it being more expensive
std::array<int, 2> out {};
int* o = eve::compress_store[eve::safe](in, m, out.data());
TTS_EQUAL(o - out.data(), 2);
TTS_EQUAL((std::array{2, 3}), out);
}
{
// Ignore output defaults to the input ignore.
std::array<int, 3> out {-1, 0, 0};
int* o = eve::compress_store[eve::unsafe][eve::keep_between(1, 3)](in, m, out.data());
TTS_EQUAL(o - out.data(), 3);
TTS_EQUAL((std::array{-1, 2, 3}), out);
}
{
// But can be separate
std::array<int, 3> out {0, -1, -1};
int* o = eve::compress_store[eve::unsafe][eve::ignore_none][eve::keep_first(1)](in, m, out.data());
TTS_EQUAL(o - out.data(), 1);
TTS_EQUAL((std::array{2, -1, -1}), out);
}
}
constexpr ignore_none_ ignore_none
Object representing the eve::ignore_none_ conditional expression.
Definition conditional.hpp:258
SIMD register cardinal type.
Definition cardinal.hpp:15
Conditional expression keeping all lanes between two position.
Definition conditional.hpp:523
Conditional expression selecting the k first lanes from a eve::simd_value.
Definition conditional.hpp:268
Wrapper for SIMD registers.
Definition wide.hpp:86