Defined in Header
#include <eve/module/core.hpp>
- Note
- this is very low level function, most likely you are looking for eve::compress_copy or eve::compress_store.
-
- FIX-1647: eve::compress doesn't support
wide<tuple> yet.
- the mask type can be any logical with the same cardinal.
Compression in simd is moving selected elements to the front of the simd_value. Unfortunately, not for all simd_value, not for all plaftorms that can be done efficiently. So the operation splits the input into chunks for which it's possible.
The function perfoms the following steps: 1) splits the simd_value and mask into chunks, that can be processed in one go. This depends on what instructions are availiable. 2) Each chunk, gets shuffled in a way that moves selected elements (mask == true) to the front. The tail of the resulting value is unspecified. [a, b, c, d], (false, true, false, true) -> [b, d, _, _] 3) For each chunk we also compute how many elements are selected. (in the example - 2). 4) Both shuffled chunk and a number are put in a kumi::tuple<simd_value, std::ptrdiff_t> TODO: there is a bug where sometimes it's an int and not std::ptrdiff_t. 5) Those chunks are combined together in another tuple.
List of people who's work was instrumental for building this:
@aqrit user on Stack Overflow
- Peter Cordes
Throughout the code of compress there are references to what was taken from where as well as explanations.
{
template <simd_value T, logical_simd_value L>
}
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 callable_compress_ compress
A low level function to compress one simd value based on a mask.
Definition compress.hpp:89
typename decltype(detail::as_translated_type(as< T >{}))::type translate_t
Returns the final translated type of T.
Definition translation.hpp:107
EVE Main Namespace.
Definition abi.hpp:19
Parameters
- x - simd_value to compress
- m - mask which markes selected elements as true
- ignore - optional eve::relative_conditional_expr, passed in
[]. Ignored elements are treated as not selected.
Return value
kumi::tuple<kumi::tuple<simd_value, std::ptrdiff_t>, ...> - tuple of compressed chunks, constructed as described earlier.
- The operation is performed conditionnaly.
#include <eve/module/core.hpp>
#include <tts/tts.hpp>
template <typename T>
{
if constexpr (std::same_as<T, std::int8_t> && eve::current_api == eve::sse4_2)
{
1, 2, 0, 4,
5, 0, 6, 7,
8, 9, 10, 11,
12, 0, 14, 15,
};
using chunk = kumi::tuple<i8x8, int>;
}
}
{
return out;
}
{
std::array<int, N>
in = {};
for (std::size_t i = 0; i != N; ++i) {
if (i % 4 == 0)
in[i] = 0;
else
{
}
}
std::copy_if(
in.begin(),
in.end(),
expected.begin(), [](
int x) { return x != 0; });
std::array<int, N> out = {};
auto* o = f(
in.data(), out.data());
std::fill(o, out.data() + out.size(), 0);
}
{
}
constexpr auto hi
elementwise_callable computing the most significant half of each lane.
Definition hi.hpp:71
constexpr auto lo
Computes the least significant half of each lane.
Definition lo.hpp:73
constexpr auto all
Computes a bool value which is true if and only if every elements of x evaluates to true.
Definition all.hpp:95
constexpr auto store
Store the elements of a SIMD value into the given memory location.
Definition store.hpp:78
constexpr auto load
Loads data from a pointer or a pair of iterators into a SIMD value.
Definition load.hpp:71
Conditional expression ignoring the k first lanes from a eve::simd_value.
Definition conditional.hpp:459
static constexpr size_type size() noexcept
Size of the wide in number of lanes.
Definition wide.hpp:443