2009-11-20 22:39:38 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
// for linear algebra.
|
|
|
|
//
|
2010-06-25 05:21:58 +08:00
|
|
|
// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
|
2009-11-20 22:39:38 +08:00
|
|
|
//
|
2012-07-14 02:42:47 +08:00
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2009-11-20 22:39:38 +08:00
|
|
|
|
|
|
|
static int nb_load;
|
|
|
|
static int nb_loadu;
|
|
|
|
static int nb_store;
|
|
|
|
static int nb_storeu;
|
|
|
|
|
|
|
|
#define EIGEN_DEBUG_ALIGNED_LOAD { nb_load++; }
|
|
|
|
#define EIGEN_DEBUG_UNALIGNED_LOAD { nb_loadu++; }
|
|
|
|
#define EIGEN_DEBUG_ALIGNED_STORE { nb_store++; }
|
|
|
|
#define EIGEN_DEBUG_UNALIGNED_STORE { nb_storeu++; }
|
|
|
|
|
|
|
|
#define VERIFY_ALIGNED_UNALIGNED_COUNT(XPR,AL,UL,AS,US) {\
|
|
|
|
nb_load = nb_loadu = nb_store = nb_storeu = 0; \
|
|
|
|
XPR; \
|
|
|
|
if(!(nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US)) \
|
|
|
|
std::cerr << " >> " << nb_load << ", " << nb_loadu << ", " << nb_store << ", " << nb_storeu << "\n"; \
|
|
|
|
VERIFY( (#XPR) && nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US ); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
2018-07-17 20:46:15 +08:00
|
|
|
EIGEN_DECLARE_TEST(unalignedcount)
|
2009-11-20 22:39:38 +08:00
|
|
|
{
|
2018-09-21 20:40:26 +08:00
|
|
|
#if defined(EIGEN_VECTORIZE_AVX512)
|
|
|
|
VectorXf a(48), b(48);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 6, 0, 3, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) += b.segment(0,48), 3, 3, 3, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) -= b.segment(0,48), 3, 3, 3, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) *= 3.5, 3, 0, 3, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,48) /= 3.5, 3, 0, 3, 0);
|
|
|
|
#elif defined(EIGEN_VECTORIZE_AVX)
|
2014-01-30 03:43:05 +08:00
|
|
|
VectorXf a(40), b(40);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 10, 0, 5, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 5, 5, 5, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 5, 5, 5, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 5, 0, 5, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 5, 0, 5, 0);
|
|
|
|
#elif defined(EIGEN_VECTORIZE_SSE)
|
2009-11-20 22:39:38 +08:00
|
|
|
VectorXf a(40), b(40);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 20, 0, 10, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 10, 10, 10, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 10, 10, 10, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 10, 0, 10, 0);
|
|
|
|
VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 10, 0, 10, 0);
|
2010-06-11 04:26:23 +08:00
|
|
|
#else
|
|
|
|
// The following line is to eliminate "variable not used" warnings
|
|
|
|
nb_load = nb_loadu = nb_store = nb_storeu = 0;
|
2013-02-15 21:05:37 +08:00
|
|
|
int a(0), b(0);
|
|
|
|
VERIFY(a==b);
|
2009-11-20 22:39:38 +08:00
|
|
|
#endif
|
|
|
|
}
|