Re: [eigen] Clean aligned memory allocation

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Thanks a lot for getting this data! Very interesting, as I expected the overhead of handmade_ to be larger. Also, you make a good point about the lack of a realloc equivalent for posix_memalign.

So I understand that this makes handmade_ a compelling solution.

On the other hand, I am still concern about the dangerousness of MALLOC_ALREADY_ALIGNED. But it seems that the C++11 rule that you found, could make it safe at least when compiling in C++11 mode, which these days is probably the majority of users (data point: both Google and Mozilla build all their C++ in C++11 mode these days).

So is this the plan that you have in mind?
1. Restrict MALLOC_ALREADY_ALIGNED to C++11 when actually guaranteed to be safe per standard.
2. Fall back to handmade_ only, drop use of any non malloc/realloc allocator entry points?

Benoit

2016-02-04 6:01 GMT-05:00 Gael Guennebaud <gael.guennebaud@xxxxxxxxx>:

Maybe I should precise that the previous numbers have been obtained on OSX. On Linux I observe nearly no overhead at all for our handmade version.

For completeness, I attached some interesting plots comparing posix_memalign vs handmade_aligned_alloc, on both linux and osx, for allocating 100 buffers of sizes going from 4 to 16000 Bytes with an increment of 4 Bytes.

Despite the overhead on OSX for some particular buffer size, I'm still in favor of keeping the std::malloc based variants only, mainly because of the huge performance impact of reallocating a buffer allocated with posix_memalign.

gael



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/