first_aligned.cpp
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #include "main.h"
11 
12 template<typename Scalar>
14 {
15  const int packet_size = sizeof(Scalar) * internal::packet_traits<Scalar>::size;
16  VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_default_aligned(array, size)) % packet_size) == 0);
17 }
18 
19 template<typename Scalar>
21 {
22  EIGEN_UNUSED_VARIABLE(array);
25 }
26 
27 struct some_non_vectorizable_type { float x; };
28 
30 {
31  EIGEN_ALIGN16 float array_float[100];
32  test_first_aligned_helper(array_float, 50);
33  test_first_aligned_helper(array_float+1, 50);
34  test_first_aligned_helper(array_float+2, 50);
35  test_first_aligned_helper(array_float+3, 50);
36  test_first_aligned_helper(array_float+4, 50);
37  test_first_aligned_helper(array_float+5, 50);
38 
39  EIGEN_ALIGN16 double array_double[100];
40  test_first_aligned_helper(array_double, 50);
41  test_first_aligned_helper(array_double+1, 50);
42  test_first_aligned_helper(array_double+2, 50);
43 
44  double *array_double_plus_4_bytes = (double*)(internal::UIntPtr(array_double)+4);
45  test_none_aligned_helper(array_double_plus_4_bytes, 50);
46  test_none_aligned_helper(array_double_plus_4_bytes+1, 50);
47 
48  some_non_vectorizable_type array_nonvec[100];
49  test_first_aligned_helper(array_nonvec, 100);
50  test_none_aligned_helper(array_nonvec, 100);
51 }
SCALAR Scalar
Definition: bench_gemm.cpp:33
std::size_t UIntPtr
Definition: Meta.h:51
static Index first_default_aligned(const DenseBase< Derived > &m)
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
#define EIGEN_ALIGN16
Definition: Macros.h:753
void test_first_aligned()
#define VERIFY(a)
Definition: main.h:325
void test_first_aligned_helper(Scalar *array, int size)
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:618
void test_none_aligned_helper(Scalar *array, int size)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:04