Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make custom malloc & realloc return aligned pointers #138

Merged
merged 1 commit into from
Jul 30, 2021

Conversation

3rror
Copy link
Contributor

@3rror 3rror commented Jul 6, 2021

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.

Fix issue embench#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.

Reported-by: Edward Jones
Signed-off-by: Gianluca Andreotti <[email protected]>
@jeremybennett
Copy link
Collaborator

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

@jeremybennett jeremybennett merged commit 4d15e4e into embench:master Jul 30, 2021
hirooih added a commit to hirooih/embench-iot that referenced this pull request Oct 16, 2021
The change on embench#138 make malloc() fail without this fix.
jeremybennett pushed a commit that referenced this pull request Oct 17, 2021
* tarfind: wraparound the size heap

The change on #138 make malloc() fail without this fix.

* assert heap_size is a mutiple of the pointer size
@jeremybennett
Copy link
Collaborator

This fix only works if -flto is used. See #203

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants