1 | // This file is part of Eigen, a lightweight C++ template library
|
---|
2 | // for linear algebra.
|
---|
3 | //
|
---|
4 | // Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
---|
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 | static int nb_load;
|
---|
11 | static int nb_loadu;
|
---|
12 | static int nb_store;
|
---|
13 | static int nb_storeu;
|
---|
14 |
|
---|
15 | #define EIGEN_DEBUG_ALIGNED_LOAD { nb_load++; }
|
---|
16 | #define EIGEN_DEBUG_UNALIGNED_LOAD { nb_loadu++; }
|
---|
17 | #define EIGEN_DEBUG_ALIGNED_STORE { nb_store++; }
|
---|
18 | #define EIGEN_DEBUG_UNALIGNED_STORE { nb_storeu++; }
|
---|
19 |
|
---|
20 | #define VERIFY_ALIGNED_UNALIGNED_COUNT(XPR,AL,UL,AS,US) {\
|
---|
21 | nb_load = nb_loadu = nb_store = nb_storeu = 0; \
|
---|
22 | XPR; \
|
---|
23 | if(!(nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US)) \
|
---|
24 | std::cerr << " >> " << nb_load << ", " << nb_loadu << ", " << nb_store << ", " << nb_storeu << "\n"; \
|
---|
25 | VERIFY( (#XPR) && nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US ); \
|
---|
26 | }
|
---|
27 |
|
---|
28 |
|
---|
29 | #include "main.h"
|
---|
30 |
|
---|
31 | void test_unalignedcount()
|
---|
32 | {
|
---|
33 | #ifdef EIGEN_VECTORIZE_SSE
|
---|
34 | VectorXf a(40), b(40);
|
---|
35 | VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 20, 0, 10, 0);
|
---|
36 | VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 10, 10, 10, 0);
|
---|
37 | VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 10, 10, 10, 0);
|
---|
38 | VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 10, 0, 10, 0);
|
---|
39 | VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 10, 0, 10, 0);
|
---|
40 | #else
|
---|
41 | // The following line is to eliminate "variable not used" warnings
|
---|
42 | nb_load = nb_loadu = nb_store = nb_storeu = 0;
|
---|
43 | int a(0), b(0);
|
---|
44 | VERIFY(a==b);
|
---|
45 | #endif
|
---|
46 | }
|
---|