Re: [eigen] Struct padding with the nvcc compiler. |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
Hello again,Both suggestions fixed the problem. They both work on their own, and also together. Thanks!On Wed, Jun 1, 2016 at 9:55 PM, Gael Guennebaud <gael..guennebaud@xxxxxxxxx> wrote:Hi,there are two possibilities: either Eigen don't request alignment when compiled with nvcc, or nvcc does not comply with our alignment request. To investigate the issue, you can try to #define EIGEN_MAX_STATIC_ALIGN_BYTES=16 before any Eigen's header (or pass it to nvcc compiler). You can also try to add EIGEN_ALIGN_TO_BOUNDARY(16) before any Eigen's member required alignment, e.g.:struct bar {Vector4f v1;float x, y;EIGEN_ALIGN_TO_BOUNDARY(16) Matrix4f m1;};Finally, you might also consider re-ordering your members to put the largest object first so that no padding (and thus waste of memory) will be required.Let us know about the outcome!gaelOn Tue, May 31, 2016 at 2:56 PM, Jon E. A. Lund <jonealund@xxxxxxxxx> wrote:Hi,I'm using Eigen in a Cuda program, and want to use a Struct containing multiple Eigen members. The problem I am having is that the nvcc compiler apparently doesn't understand how the struct is supposed to be padded. As far as I have understood, Eigen pads the struct such that every Eigen member starts on a 16 byte boundary. My c++ compiler (g++-4.9) does this correctly, but it seems nvcc doesn't pad correctly.The symptoms i observe are that sizeof() and offsetof() return different values when run the .cpp file compared to when run in the .cu file. In the ..cpp file i get padding to 16 byte boundaries, while in the .cu file I get no padding at all.The problem is independent of whether I am using the EIGEN_MAKE_ALIGNED_OPERATOR_NEW macro or not.I am using an Eigen 3.3 dev snapshot taken May 30th.For now I am padding my structs manually to ensure correct behavior, but I am curious if this is a known issue or something that will be fixed.Best,Jon E. A. Lund
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |