You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.6 KiB

  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. static int nb_load;
  10. static int nb_loadu;
  11. static int nb_store;
  12. static int nb_storeu;
  13. #define EIGEN_DEBUG_ALIGNED_LOAD { nb_load++; }
  14. #define EIGEN_DEBUG_UNALIGNED_LOAD { nb_loadu++; }
  15. #define EIGEN_DEBUG_ALIGNED_STORE { nb_store++; }
  16. #define EIGEN_DEBUG_UNALIGNED_STORE { nb_storeu++; }
  17. #define VERIFY_ALIGNED_UNALIGNED_COUNT(XPR,AL,UL,AS,US) {\
  18. nb_load = nb_loadu = nb_store = nb_storeu = 0; \
  19. XPR; \
  20. if(!(nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US)) \
  21. std::cerr << " >> " << nb_load << ", " << nb_loadu << ", " << nb_store << ", " << nb_storeu << "\n"; \
  22. VERIFY( (#XPR) && nb_load==AL && nb_loadu==UL && nb_store==AS && nb_storeu==US ); \
  23. }
  24. #include "main.h"
  25. void test_unalignedcount()
  26. {
  27. #ifdef EIGEN_VECTORIZE_SSE
  28. VectorXf a(40), b(40);
  29. VERIFY_ALIGNED_UNALIGNED_COUNT(a += b, 20, 0, 10, 0);
  30. VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) += b.segment(0,40), 10, 10, 10, 0);
  31. VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) -= b.segment(0,40), 10, 10, 10, 0);
  32. VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) *= 3.5, 10, 0, 10, 0);
  33. VERIFY_ALIGNED_UNALIGNED_COUNT(a.segment(0,40) /= 3.5, 10, 0, 10, 0);
  34. #else
  35. // The following line is to eliminate "variable not used" warnings
  36. nb_load = nb_loadu = nb_store = nb_storeu = 0;
  37. #endif
  38. }