Runtime error on IBM POWER
Howdy -
The HPX/Phylanx project found a bug in blaze/util/Memory.h when allocating a DynamicVector
. In the call to allocate_backend()
from line 160 of allocate()
, posix_memalign()
is called with alignment of 4 and size of 4028. However, sizeof(void*)
on this platform is 8. The posix_memalign()
call fails, because according to the posix_memalign man page, alignment must be a multiple of sizeof(void*)
.
If I add this line before the posix_memalign()
call, the code works:
alignment = (alignment < sizeof(void*) ? sizeof(void*) : alignment);
I am not sure why this would work on x86_64 platforms, though - it should fail there, too!
With this test program, I get the following output on POWER with the Clang 7 compiler and the same output on x86_64 with g++7:
#include<iostream>
int main (int argc, char** argv) {
std::cout << "Size of void* : " << sizeof(void*) << std::endl;
std::cout << "Size of int : " << sizeof(int) << std::endl;
std::cout << "Size of std::alignment_of<int>::value : " << std::alignment_of<int>::value << std::endl;
std::cout << "Size of std::alignment_of<int>() : " << std::alignment_of<int>() << std::endl;
}
output:
Size of void* : 8
Size of int : 4
Size of std::alignment_of<int>::value : 4
Size of std::alignment_of<int>() : 4
For a longer discussion, see https://github.com/STEllAR-GROUP/phylanx/issues/796
Thanks!
Comments (4)
-
-
-
assigned issue to
-
assigned issue to
-
- changed status to open
-
- changed status to resolved
Commit 954950b fixes the minimum alignment for calls to the
posix_memalign()
function. The fix is immediately available via cloning the Blaze repository and will be officially released in Blaze 3.5. - Log in to comment
Hi!
Thanks for reporting this issue and thanks for providing a fix. I will integrate it as quickly as possible.
Best regards,
Klaus!