Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "main.h"
00026
00027 template<typename Scalar>
00028 void test_eigen2_first_aligned_helper(Scalar *array, int size)
00029 {
00030 const int packet_size = sizeof(Scalar) * ei_packet_traits<Scalar>::size;
00031 VERIFY(((std::size_t(array) + sizeof(Scalar) * ei_alignmentOffset(array, size)) % packet_size) == 0);
00032 }
00033
00034 template<typename Scalar>
00035 void test_eigen2_none_aligned_helper(Scalar *array, int size)
00036 {
00037 VERIFY(ei_packet_traits<Scalar>::size == 1 || ei_alignmentOffset(array, size) == size);
00038 }
00039
00040 struct some_non_vectorizable_type { float x; };
00041
00042 void test_eigen2_first_aligned()
00043 {
00044 EIGEN_ALIGN_128 float array_float[100];
00045 test_first_aligned_helper(array_float, 50);
00046 test_first_aligned_helper(array_float+1, 50);
00047 test_first_aligned_helper(array_float+2, 50);
00048 test_first_aligned_helper(array_float+3, 50);
00049 test_first_aligned_helper(array_float+4, 50);
00050 test_first_aligned_helper(array_float+5, 50);
00051
00052 EIGEN_ALIGN_128 double array_double[100];
00053 test_first_aligned_helper(array_double, 50);
00054 test_first_aligned_helper(array_double+1, 50);
00055 test_first_aligned_helper(array_double+2, 50);
00056
00057 double *array_double_plus_4_bytes = (double*)(std::size_t(array_double)+4);
00058 test_none_aligned_helper(array_double_plus_4_bytes, 50);
00059 test_none_aligned_helper(array_double_plus_4_bytes+1, 50);
00060
00061 some_non_vectorizable_type array_nonvec[100];
00062 test_first_aligned_helper(array_nonvec, 100);
00063 test_none_aligned_helper(array_nonvec, 100);
00064 }