tag:blogger.com,1999:blog-7523589.post3286589364494873641..comments2024-02-20T19:17:55.835+01:00Comments on TSDgeos' blog: Aligned data when doing a newAlbert Astals Cidhttp://www.blogger.com/profile/12001470108926138921noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-7523589.post-58960390263937070242008-10-18T14:21:00.000+02:002008-10-18T14:21:00.000+02:00From "man posix_memalign":The function posix_memal...From "man posix_memalign":<BR/>The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7523589.post-88094651547256335462008-10-18T12:39:00.000+02:002008-10-18T12:39:00.000+02:00@moltonel: ffmpeg wants the output buffers to be a...@moltonel: ffmpeg wants the output buffers to be aligned to 16bits boundary so he can do nice SSSE3 operationsAlbert Astals Cidhttps://www.blogger.com/profile/12001470108926138921noreply@blogger.comtag:blogger.com,1999:blog-7523589.post-47521948790573439182008-10-17T11:33:00.000+02:002008-10-17T11:33:00.000+02:00But but but... malloc() allready returns memory al...But but but... malloc() allready returns memory aligned on a word boundary (I know that, having written a malloc for a platform where "unaligned read" meant "segfault").<BR/><BR/>I'm curious : when do you need more alignment than what malloc ang gcc attributes give you ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7523589.post-85349195946826168432008-10-17T02:37:00.000+02:002008-10-17T02:37:00.000+02:00We had the same issue with Eigen, and we currently...We had the same issue with Eigen, and we currently use posix_memalign for the aligned allocation. However, we also designed some helper classes to deal with that problem:<BR/><BR/>http://eigen.tuxfamily.org/api/structEigen_1_1WithAlignedOperatorNew.html<BR/><BR/><BR/>and the respective piece of code:<BR/><BR/>http://websvn.kde.org/trunk/kdesupport/eigen2/Eigen/src/Core/util/Memory.h?revision=858770&view=markup<BR/><BR/><BR/>also don't miss the class ei_new_allocator which allows you to use your class as the value type of any STL container...Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7523589.post-13406327740149410802008-10-17T02:07:00.000+02:002008-10-17T02:07:00.000+02:00Either use a placement new with a allocator that c...Either use a placement new with a allocator that can do aligned allocating, or just allocate a little extra memory if needed, and offset the pointer a few bytes.Tomasuhttps://www.blogger.com/profile/13234855798228504346noreply@blogger.com