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_first_aligned_helper(Scalar *array, int size)
00029 {
00030 const int packet_size = sizeof(Scalar) * internal::packet_traits<Scalar>::size;
00031 VERIFY(((size_t(array) + sizeof(Scalar) * internal::first_aligned(array, size)) % packet_size) == 0);
00032 }
00033
00034 template<typename Scalar>
00035 void test_none_aligned_helper(Scalar *array, int size)
00036 {
00037 EIGEN_UNUSED_VARIABLE(array);
00038 EIGEN_UNUSED_VARIABLE(size);
00039 VERIFY(internal::packet_traits<Scalar>::size == 1 || internal::first_aligned(array, size) == size);
00040 }
00041
00042 struct some_non_vectorizable_type { float x; };
00043
00044 void test_first_aligned()
00045 {
00046 EIGEN_ALIGN16 float array_float[100];
00047 test_first_aligned_helper(array_float, 50);
00048 test_first_aligned_helper(array_float+1, 50);
00049 test_first_aligned_helper(array_float+2, 50);
00050 test_first_aligned_helper(array_float+3, 50);
00051 test_first_aligned_helper(array_float+4, 50);
00052 test_first_aligned_helper(array_float+5, 50);
00053
00054 EIGEN_ALIGN16 double array_double[100];
00055 test_first_aligned_helper(array_double, 50);
00056 test_first_aligned_helper(array_double+1, 50);
00057 test_first_aligned_helper(array_double+2, 50);
00058
00059 double *array_double_plus_4_bytes = (double*)(size_t(array_double)+4);
00060 test_none_aligned_helper(array_double_plus_4_bytes, 50);
00061 test_none_aligned_helper(array_double_plus_4_bytes+1, 50);
00062
00063 some_non_vectorizable_type array_nonvec[100];
00064 test_first_aligned_helper(array_nonvec, 100);
00065 test_none_aligned_helper(array_nonvec, 100);
00066 }