first_aligned.cpp File Reference
#include "main.h"

Classes

struct  some_non_vectorizable_type
 

Functions

template<typename Scalar >
void test_first_aligned_helper (Scalar *array, int size)
 
template<typename Scalar >
void test_none_aligned_helper (Scalar *array, int size)
 
 EIGEN_DECLARE_TEST (first_aligned)
 

Function Documentation

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( first_aligned  )
29  {
30  EIGEN_ALIGN16 float array_float[100];
31  test_first_aligned_helper(array_float, 50);
32  test_first_aligned_helper(array_float + 1, 50);
33  test_first_aligned_helper(array_float + 2, 50);
34  test_first_aligned_helper(array_float + 3, 50);
35  test_first_aligned_helper(array_float + 4, 50);
36  test_first_aligned_helper(array_float + 5, 50);
37 
38  EIGEN_ALIGN16 double array_double[100];
39  test_first_aligned_helper(array_double, 50);
40  test_first_aligned_helper(array_double + 1, 50);
41  test_first_aligned_helper(array_double + 2, 50);
42 
43  double *array_double_plus_4_bytes = (double *)(std::uintptr_t(array_double) + 4);
44  test_none_aligned_helper(array_double_plus_4_bytes, 50);
45  test_none_aligned_helper(array_double_plus_4_bytes + 1, 50);
46 
47  some_non_vectorizable_type array_nonvec[100];
48  test_first_aligned_helper(array_nonvec, 100);
49  test_none_aligned_helper(array_nonvec, 100);
50 }
#define EIGEN_ALIGN16
Definition: ConfigureVectorization.h:142
void test_none_aligned_helper(Scalar *array, int size)
Definition: first_aligned.cpp:19
void test_first_aligned_helper(Scalar *array, int size)
Definition: first_aligned.cpp:13
Definition: first_aligned.cpp:25

References EIGEN_ALIGN16, test_first_aligned_helper(), and test_none_aligned_helper().

◆ test_first_aligned_helper()

template<typename Scalar >
void test_first_aligned_helper ( Scalar array,
int  size 
)
13  {
14  const int packet_size = sizeof(Scalar) * internal::packet_traits<Scalar>::size;
15  VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_default_aligned(array, size)) % packet_size) == 0);
16 }
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
#define VERIFY(a)
Definition: main.h:362
static Index first_default_aligned(const DenseBase< Derived > &m)
Definition: DenseCoeffsBase.h:539
std::array< T, N > array
Definition: EmulateArray.h:231

References Eigen::internal::first_default_aligned(), size, and VERIFY.

Referenced by EIGEN_DECLARE_TEST().

◆ test_none_aligned_helper()

template<typename Scalar >
void test_none_aligned_helper ( Scalar array,
int  size 
)