gtsam
3rdparty
Eigen
test
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>
13
void
test_first_aligned_helper
(
Scalar
*
array
,
int
size
)
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>
20
void
test_none_aligned_helper
(
Scalar
*
array
,
int
size
)
21
{
22
EIGEN_UNUSED_VARIABLE
(
array
);
23
EIGEN_UNUSED_VARIABLE
(
size
);
24
VERIFY
(
internal::packet_traits<Scalar>::size
== 1 ||
internal::first_default_aligned
(
array
,
size
) ==
size
);
25
}
26
27
struct
some_non_vectorizable_type
{
float
x
; };
28
29
EIGEN_DECLARE_TEST
(
first_aligned
)
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
}
Eigen::internal::UIntPtr
std::size_t UIntPtr
Definition:
Meta.h:92
Eigen::array
Definition:
EmulateArray.h:21
some_non_vectorizable_type::x
float x
Definition:
first_aligned.cpp:27
size
Scalar Scalar int size
Definition:
benchVecAdd.cpp:17
EIGEN_UNUSED_VARIABLE
#define EIGEN_UNUSED_VARIABLE(var)
Definition:
Macros.h:1076
Eigen::internal::first_aligned
static Index first_aligned(const DenseBase< Derived > &m)
Definition:
DenseCoeffsBase.h:643
some_non_vectorizable_type
Definition:
first_aligned.cpp:27
main.h
test_none_aligned_helper
void test_none_aligned_helper(Scalar *array, int size)
Definition:
first_aligned.cpp:20
test_first_aligned_helper
void test_first_aligned_helper(Scalar *array, int size)
Definition:
first_aligned.cpp:13
Eigen::internal::first_default_aligned
static Index first_default_aligned(const DenseBase< Derived > &m)
Definition:
DenseCoeffsBase.h:650
EIGEN_DECLARE_TEST
EIGEN_DECLARE_TEST(first_aligned)
Definition:
first_aligned.cpp:29
EIGEN_ALIGN16
#define EIGEN_ALIGN16
Definition:
ConfigureVectorization.h:153
Scalar
SCALAR Scalar
Definition:
bench_gemm.cpp:46
VERIFY
#define VERIFY(a)
Definition:
main.h:380
gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:32