unalignedcount.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 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 EIGEN_DECLARE_TEST(unalignedcount)
32 {
33  #if defined(EIGEN_VECTORIZE_AVX512)
34  VectorXf a(48), b(48);
35  VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 6, 0, 3, 0);
36  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) += b.segment(0,48), 3, 3, 3, 0);
37  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) -= b.segment(0,48), 3, 3, 3, 0);
38  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) *= 3.5, 3, 0, 3, 0);
39  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) /= 3.5, 3, 0, 3, 0);
40  #elif defined(EIGEN_VECTORIZE_AVX)
41  VectorXf a(40), b(40);
42  VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 10, 0, 5, 0);
43  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 5, 5, 5, 0);
44  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 5, 5, 5, 0);
45  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 5, 0, 5, 0);
46  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 5, 0, 5, 0);
47  #elif defined(EIGEN_VECTORIZE_SSE)
48  VectorXf a(40), b(40);
49  VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 20, 0, 10, 0);
50  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 10, 10, 10, 0);
51  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 10, 10, 10, 0);
52  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 10, 0, 10, 0);
53  VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 10, 0, 10, 0);
54  #else
55  // The following line is to eliminate "variable not used" warnings
57  int a(0), b(0);
58  VERIFY(a==b);
59  #endif
60 }
Scalar * b
Definition: benchVecAdd.cpp:17
EIGEN_DECLARE_TEST(unalignedcount)
#define VERIFY_ALIGNED_UNALIGNED_COUNT(XPR, AL, UL, AS, US)
static int nb_store
#define VERIFY(a)
Definition: main.h:380
static int nb_storeu
static int nb_loadu
static int nb_load


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:41