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

Detailed Description

Realigns integral value over a given power-of-2 alignment constraint.

Realigns a pointer under a given power-of-2 alignment constraint.

Realigns a pointer over a given power-of-2 alignment constraint.

Realigns integral value under a given power-of-2 alignment constraint.

EVE provides various elements to simplify the management of SIMD-compatible memory like functions and allocators for requesting SIMD-compatible block of memory, pointer wrappers to discriminate aligned memory from regular one, and alignment computation functions.

Convenience header:

#include <eve/memory.hpp>
Parameters
vIntegral value to realign
alignmentAlignment constraint to apply. Behavior is undefined if this constraint is not a power of 2.
Returns
An integer value greater or equal to v which is a multiple of alignment
See also
align(T v, under alignment)
align(T* v, over alignment)
align(T* v, under alignment)
Parameters
vIntegral value to realign
alignmentAlignment constraint to apply. Behavior is undefined if this constraint is not a power of 2.
Returns
An integer value lesser or equal to v which is a multiple of alignment
See also
align(T v, over alignment)
align(T* v, over alignment)
align(T* v, under alignment)
Parameters
ptrPointer to realign
alignmentAlignment constraint to apply. Behavior is undefined if this constraint is not a power of 2.
Returns
A pointer to T which address is greater or equal to ptr and which value is a multiple of alignment.
See also
align(T v, over alignment)
align(T v, under alignment)
align(T* v, under alignment)
Parameters
ptrPointer to realign
alignmentAlignment constraint to apply. Behavior is undefined if this constraint is not a power of 2.
Returns
A pointer to T which address is lesser or equal to ptr and which value is a multiple of alignment.
See also
align(T v, over alignment)
align(T v, under alignment)
align(T* v, over alignment)

Classes

struct  eve::aligned_allocator< T, Lanes >
 Standard-compliant allocator handling the allocation and deallocation of segment of aligned memory. More...
struct  eve::aligned_ptr< Type, Lanes >
 Wrapper for non-owning aligned pointers. More...
struct  eve::stack_buffer< T >
 A stack buffer for a simd-value. More...
struct  eve::soa_ptr< Ptrs >
 a low level abstraction that is like a tuple of pointers to parallel arrays. We think that in code one should use views::zip_iterator instead, it can do everything soa_ptr can and more. We are still trying to figure out how/where these abstractions should live. More...
class  eve::algo::soa_vector< Type, Allocator >
 SIMD-aware container for product types. More...

Concepts

concept  eve::has_store_equivalent
 tests if store_equivalent has a non-default definition for a value and a pointer.

Typedefs

template<typename T>
using eve::unaligned_t = decltype(unalign(std::declval<T>()))
 Compute the unaligned pointer type associated to a given type.

Enumerations

enum class  eve::over : std::size_t
 Strong integral type that represents the notion of over-alignment constraints. More...
enum class  eve::under : std::size_t
 Strong integral type that represents the notion of under-alignment constraints. More...

Functions

template<std::size_t A, typename T, typename Other>
constexpr bool eve::is_aligned (aligned_ptr< T, Other > const &ptr) noexcept
 Checks if an aligned_ptr is aligned on a given alignment.
template<std::size_t Alignment, std::integral T>
constexpr bool eve::is_aligned (T v) noexcept
 Checks if a pointer satisfies an alignment constraint.
template<std::size_t Alignment, typename T>
constexpr bool eve::is_aligned (T *ptr) noexcept
 Checks if a pointer satisfies an alignment constraint.
template<typename T, typename Lanes>
constexpr bool eve::is_aligned (T *ptr, Lanes lanes) noexcept
 Checks if a pointer satisfies an alignment constraint.

Variables

constexpr auto eve::read = functor<read_t>
 Callable object reading single value from memory.
constexpr auto eve::store = functor<store_t>
 Store the elements of a SIMD value into the given memory location.
constexpr auto eve::unalign = functor<unalign_t>
 Callable object for computing an unaligned version of a relaxed iterator.
constexpr auto eve::write = functor<write_t>
 Callable object writing a scalar value to memory.
constexpr callable_store_equivalent_ eve::store_equivalent = {}
 Callable object, customisation point. If an iterator's store operation can be done as a store to some other iterator/pointer - this is a transformation to customize.

Typedef Documentation

◆ unaligned_t

template<typename T>
using eve::unaligned_t = decltype(unalign(std::declval<T>()))

Compute the unaligned pointer type associated to a given type.

Template Parameters
TType to process

Required header: #include <eve/module/core.hpp>

template <typename T>
using unaligned_t = decltype(unalign(std::declval<T>()));
decltype(unalign(std::declval< T >())) unaligned_t
Compute the unaligned pointer type associated to a given type.
Definition unalign.hpp:113
constexpr auto unalign
Callable object for computing an unaligned version of a relaxed iterator.
Definition unalign.hpp:93

Enumeration Type Documentation

◆ over

enum class eve::over : std::size_t
strong

Strong integral type that represents the notion of over-alignment constraints.

Required header:

#include <eve/memory/align.hpp>
enum class over : std::size_t {};
over
Strong integral type that represents the notion of over-alignment constraints.
Definition align.hpp:44


Strong integral type that represents the notion of over-alignment constraints.

Non-Member Function

constexpr inline std::size_t to_integer(over n) noexcept;

Equivalent to: return std::size_t(n);

See also
under

◆ under

enum class eve::under : std::size_t
strong

Strong integral type that represents the notion of under-alignment constraints.

Required header:

#include <eve/memory/align.hpp>
enum class under : std::size_t {};
under
Strong integral type that represents the notion of under-alignment constraints.
Definition align.hpp:77


Strong integral type that represents the notion of under-alignment constraints.

Non-Member Function

constexpr inline std::size_t to_integer(under n) noexcept;

Equivalent to: return std::size_t(n);

See also
over

Function Documentation

◆ is_aligned() [1/4]

template<std::size_t A, typename T, typename Other>
bool eve::is_aligned ( aligned_ptr< T, Other > const & ptr)
constexprnoexcept

Checks if an aligned_ptr is aligned on a given alignment.

Parameters
ptraligned_ptr to checks
Template Parameters
AAlignment constraint to verify
Returns
A boolean indicating if ptr is compatible with the Other alignment.

◆ is_aligned() [2/4]

template<std::size_t Alignment, typename T>
bool eve::is_aligned ( T * ptr)
constexprnoexcept

Checks if a pointer satisfies an alignment constraint.

Parameters
ptrPointer to check
Template Parameters
AlignmentAlignment constraint to verify. Behavior is undefined if this constraint is not a power of 2.
Returns
true if ptr is aligned over Alignment, false otherwise.

◆ is_aligned() [3/4]

template<typename T, typename Lanes>
bool eve::is_aligned ( T * ptr,
Lanes lanes )
constexprnoexcept

Checks if a pointer satisfies an alignment constraint.

Parameters
ptrPointer to check
lanesAlignment constraint to verify expressed as a SIMD register number of lanes.
Returns
true if ptr is aligned over the alignment implied by lanes, false otherwise.

◆ is_aligned() [4/4]

template<std::size_t Alignment, std::integral T>
bool eve::is_aligned ( T v)
constexprnoexcept

Checks if a pointer satisfies an alignment constraint.

Parameters
vIntegral value to check.
Template Parameters
AlignmentAlignment constraint to verify. Behavior is undefined if this constraint is not a power of 2.
Returns
true if ptr is aligned over Alignment, false otherwise.

Variable Documentation

◆ read

auto eve::read = functor<read_t>
inlineconstexpr

Callable object reading single value from memory.

Required header: #include <eve/module/core.hpp>

operator* based interface used in the standard has notorious issues with proxy references. To prevent those issues when dealing with complex, potentially SIMD-aware iterators, eve::read is to be used.

Members Functions

Member Effect
operator() Performs a single read from memory

template<typename Ptr> auto operator()(Ptr p) const noexcept

Parameters

ptr: Memory to read from.

Return value

Returns a single value read at the memory location specified by ptr. If ptr is equivalent to nullptr, the behavior is undefined.

◆ store

auto eve::store = functor<store_t>
inlineconstexpr

Store the elements of a SIMD value into the given memory location.

Header file

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
// Regular overload
template<arithmetic_simd_value T, simd_compatible_ptr<T> Ptr>
void store(T value, Ptr ptr) noexcept; // 1
template<logical_simd_value T, logical_simd_compatible_ptr<T> Ptr>
void store(T value, Ptr ptr) noexcept; // 1
// Lanes masking
auto store[conditional_expr auto c](/* any of the above overloads */) noexcept; // 2
}
Specifies that a type is a Conditional Expression.
Definition conditional.hpp:28
The concept value<T> is satisfied if and only if T satisfies either eve::scalar_value or eve::simd_va...
Definition value.hpp:34
constexpr auto store
Store the elements of a SIMD value into the given memory location.
Definition store.hpp:80
EVE Main Namespace.
Definition abi.hpp:19

Parameters

Overloads

  1. Stores the elements of value into the memory location pointed to by ptr.
  2. Same as 1. but lanes masked by the condition c will not be stored.

Example

#include <eve/eve.hpp>
#include <iostream>
int main()
{
float arr[4];
int iarr[4];
eve::logical<float> larr[4];
eve::wide<float, eve::fixed<4>> w = {3, 2, 1, 0};
eve::logical<eve::wide<float, eve::fixed<4>>> lw = {true, false, true, false};
eve::store(w, arr);
eve::store(lw, larr);
eve::store(lw, iarr);
std::cout << "arr: ";
for (auto val : arr) {
std::cout << val << " ";
}
std::cout << "\n";
std::cout << "larr: ";
for (auto val : larr) {
std::cout << val << " ";
}
std::cout << "\n";
std::cout << "iarr: ";
for (auto val : iarr) {
std::cout << val << " (" << (val ? "true" : "false") << ") ";
}
std::cout << "\n";
}
Wrapper for SIMD registers.
Definition wide.hpp:94

◆ store_equivalent

callable_store_equivalent_ eve::store_equivalent = {}
inlineconstexpr

Callable object, customisation point. If an iterator's store operation can be done as a store to some other iterator/pointer - this is a transformation to customize.

Should return new ignore/value/pointer triplet

By default returns ignore/value/pointer tuple, unchanged.

◆ unalign

auto eve::unalign = functor<unalign_t>
inlineconstexpr

Callable object for computing an unaligned version of a relaxed iterator.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<std::contiguous_iterator I>
constexpr I unalign(I p) noexcept; // 1
template<eve::relaxed_iterator Ptr>
constexpr auto unalign(Ptr p) noexcept; // 2
template<typename T, typename N>
constexpr T* unalign(aligned_ptr<T, N> p) noexcept; // 3
template<typename... Ptrs>
constexpr auto unalign(soa_ptr<Ptrs...> p) noexcept; // 4
}
Wrapper for non-owning aligned pointers.
Definition aligned_ptr.hpp:50
a low level abstraction that is like a tuple of pointers to parallel arrays. We think that in code on...
Definition soa_ptr.hpp:32

Convert the pointer or iterator passed as a parameter to a pointer without any information about its alignment.

Parameters

  • p: A pointer or relaxed iterator to convert.

Return value

  1. Return p as it is as std::iterator does not provide alignment information.
  2. Return the iterator-specific value as computed by the iterator unalign member.
  3. Return the raw pointer contained in p.
  4. Return a soa_ptr made of all unaligned pointers of p.

◆ write

auto eve::write = functor<write_t>
inlineconstexpr

Callable object writing a scalar value to memory.

operator* based interface used in the standard has notorious issues with proxy references. To prevent those issues when dealing with complex, potentially SIMD-aware iterators, eve::write is to be used.

Defined in Header

#include <eve/module/core.hpp>

Callable Signatures

namespace eve
{
template<typename Ptr, scalar_value V>
requires requires(Ptr p, V v) { *p = v; }
EVE_FORCEINLINE void operator()(V v, Ptr p) const noexcept; // 1
template<typename Writeable, scalar_value V>
requires requires(Writeable p, V v) { p.write(v); }
EVE_FORCEINLINE void operator()(V v, Writeable p) const noexcept; // 2
template<typename... Ptrs, scalar_value V>
EVE_FORCEINLINE void operator()(V v, soa_ptr<Ptrs...> p) const noexcept; // 3
}
Specify that a type represents a scalar value The concept scalar_value<T> is satisfied if and only if...
Definition scalar.hpp:138
  1. Write the scalar v into the memory pointed by p;
  2. Write the scalar v into the memory managed by the object p;
  3. Write the scalar v into the memory pointed by SoA pointer p;

Parameters

  • v: scalar to write to memory.
  • p: A pointer or rich iterator to write to.