embench / embench-iot

The main Embench repository
https://www.embench.org/
GNU General Public License v3.0
254 stars 104 forks source link

Make custom malloc & realloc return aligned pointers #138

Closed 3rror closed 3 years ago

3rror commented 3 years ago

Fix issue #116.

Until now, malloc_beebs and realloc_beebs returned non-aligned pointer and this behaviour could result in a performance penalty in some tests that use the heap, especially when executed on some architectures.

This commit makes malloc_beebs return pointers aligned to multiples of sizeof(void *), and also updates realloc_beebs to make use of that.

To avoid breaking changes, the padding is added to heap_requested.

This commit also makes the static array used as a heap in sglib-combined and huffbench aligned. This is obtained through the __attribute__((aligned)) directive as it seems to be well supported across compilers.

jeremybennett commented 3 years ago

Thanks for this. @PaoloS02 has checked it, and it works with GCC and Clang. Good to merge.

jeremybennett commented 3 months ago

This fix only works if -flto is used. See https://github.com/embench/embench-iot/issues/203