简体   繁体   English

如何将Eigen :: Matrix放置到共享内存(或堆)?

[英]How to do placement allocation Eigen::Matrix to Shared Memory (or Heap)?

I just tried to allocate an instance which contains Eigen::Matrix to Xenomai's shared memory. 我只是尝试将包含Eigen :: Matrix的实例分配给Xenomai的共享内存。

unsigned char * mem; //shared memory pointer
Robot * robot = new ((void *)(mem+ROBOT_ADDR)) Robot();

The Robot class contains several Eigen::Matrix. Robot类包含几个Eigen :: Matrix。 However, I can't allocate robot object in my shared memory. 但是,我无法在共享内存中分配机器人对象。

But the basic allocation was working well lke below. 但基本配置在下面工作得很好。

Robot * robot = new Robot(); //work well!

The Assertion log is: 断言日志是:

Eigen::internal::plain_array::plain_array() [with T = double; Eigen :: internal :: plain_array :: plain_array()[T = double; int Size = 36; int size = 36; int MatrixOrArrayOptions = 0]: Assertion `(reinterpret_cast(eigen_unaligned_array_assert_workaround_gcc47(array)) & 0xf) == 0 && "this assertion is explained here: " " http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html " " **** READ THIS WEB PAGE !!! ****"' failed. int MatrixOrArrayOptions = 0]:断言`(reinterpret_cast(eigen_unaligned_array_assert_workaround_gcc47(array))&0xf)== 0 &&“这个断言在这里解释:”“ http://eigen.tuxfamily.org/dox-devel/group__TopicUnalignedArrayAssert.html ” “****阅读本网页!!! ****”'失败了。

I already checked the web page in the log. 我已经在日志中检查了网页。 But there is no solution for my case. 但我的案子没有解决办法。

How to do placement allocation Eigen::Matrix to Shared Memory (or user-defined specific heap)? 如何将Eigen :: Matrix放置到共享内存(或用户定义的特定堆)?

As per the linked webpage: 根据链接的网页:

fixed-size vectorizable Eigen objects must absolutely be created at 16-byte-aligned locations, otherwise SIMD instructions addressing them will crash. 固定大小的可矢量化的特征对象必须绝对在16字节对齐的位置创建,否则解决它们的SIMD指令将崩溃。

So the problem is that mem+ROBOT_ADDR is not 16-byte aligned. 所以问题是mem+ROBOT_ADDR不是16字节对齐的。 You need to ensure that it is. 你需要确保它是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM