-
Notifications
You must be signed in to change notification settings - Fork 105
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
malloc_beebs does not ensure correct alignment of allocated objects #116
Comments
3rror
added a commit
to 3rror/embench-iot
that referenced
this issue
Jul 6, 2021
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]>
I think I managed to fix this issue, but someone should review the code and maybe test it on other architectures. |
3rror
added a commit
to 3rror/embench-iot
that referenced
this issue
Jul 19, 2021
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
pushed a commit
that referenced
this issue
Jul 30, 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. Reported-by: Edward Jones Signed-off-by: Gianluca Andreotti <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The custom malloc in embench does not ensure that allocated objects are correctly aligned. For architectures where unaligned accesses are not valid this will cause incorrect behaviour in the benchmarks which rely on the heap, on architectures where unaligned accesses are slow this could cause inconsistent benchmark performance.
There is also a secondary problem that the pointer passed to
init_heap_beebs
from the benchmarks needs to be aligned to the maximum alignment of any object for the target architecture. This is a problem in sglib-combined where the heap is a simple char array.The text was updated successfully, but these errors were encountered: