10 #include <gtest/gtest.h> 14 #include <Eigen/Dense> 17 TEST(EigenAlignment, PrintAlignment)
22 std::cout <<
"MRPT_MAX_ALIGN_BYTES : " << MRPT_MAX_ALIGN_BYTES
24 "MRPT_MAX_STATIC_ALIGN_BYTES : " 25 << MRPT_MAX_STATIC_ALIGN_BYTES
27 "EIGEN_MAX_ALIGN_BYTES : " 28 << EIGEN_MAX_ALIGN_BYTES
30 "EIGEN_MAX_STATIC_ALIGN_BYTES : " 31 << EIGEN_MAX_STATIC_ALIGN_BYTES <<
"\n";
33 EXPECT_GE(MRPT_MAX_ALIGN_BYTES, EIGEN_MAX_ALIGN_BYTES);
34 EXPECT_GE(MRPT_MAX_STATIC_ALIGN_BYTES, EIGEN_MAX_STATIC_ALIGN_BYTES);
37 template <
unsigned int INTER_SPACE>
47 template <
unsigned int INTER_SPACE>
50 EXPECT_TRUE(mrpt::system::is_aligned<EIGEN_MAX_ALIGN_BYTES>(&d.
m1(0, 0)))
51 <<
"test: " << testName <<
"\nINTER_SPACE=" << INTER_SPACE
52 <<
"\nm1(0,0)=" <<
static_cast<const void*
>(&d.
m1(0, 0))
53 <<
"\nFailed against: EIGEN_MAX_ALIGN_BYTES=" << EIGEN_MAX_ALIGN_BYTES;
54 EXPECT_TRUE(mrpt::system::is_aligned<EIGEN_MAX_ALIGN_BYTES>(&d.
m2(0, 0)))
55 <<
"test: " << testName <<
"\nINTER_SPACE=" << INTER_SPACE
56 <<
"\nm2(0,0)=" <<
static_cast<const void*
>(&d.
m2(0, 0))
57 <<
"\nFailed against: EIGEN_MAX_ALIGN_BYTES=" << EIGEN_MAX_ALIGN_BYTES;
60 template <
unsigned int INTER_SPACE>
66 template <
unsigned int INTER_SPACE>
69 do_test_AlignedMemOnStack<INTER_SPACE>();
70 if constexpr (INTER_SPACE > 0)
74 template <
unsigned int INTER_SPACE>
77 std::map<int, Foo<INTER_SPACE>> d;
78 for (
int i = 0; i < 100; i++) d[i * 3 + i * i * 4 + 1];
82 template <
unsigned int INTER_SPACE>
85 do_test_AlignedMemInSTL<INTER_SPACE>();
86 if constexpr (INTER_SPACE > 0)
90 TEST(EigenAlignment, AlignedMemOnStack) { do_test_AlignedMemOnStackUpTo<20>(); }
92 TEST(EigenAlignment, AlignedMemInSTL) { do_test_AlignedMemInSTLUpTo<20>(); }
mrpt::math::CMatrixFixed< double, 3, 3 > m2
void do_test_AlignedMemInSTLUpTo()
std::array< uint8_t, INTER_SPACE > dummy_space
void do_test_AlignedMemOnStackUpTo()
void checkAlignedFoo(const Foo< INTER_SPACE > &d, const std::string &testName)
mrpt::math::CMatrixFixed< double, 3, 3 > m1
void do_test_AlignedMemOnStack()
TEST(EigenAlignment, PrintAlignment)
GLsizei const GLchar ** string
void do_test_AlignedMemInSTL()