-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
change GLOBAL_ALIGNMENT to 8 bytes #316
base: develop
Are you sure you want to change the base?
Conversation
@@ -324,7 +324,7 @@ void HeapAllocator::reserve(size_t sizeToAllocate) { | |||
void* memory = mBaseAllocator.allocate(sizeToAllocate + sizeof(MemoryUnitHeader)); | |||
assert(memory != nullptr); | |||
|
|||
// Check that allocated memory is 16-bytes aligned | |||
// Check that allocated memory is 8-bytes aligned | |||
assert(reinterpret_cast<uintptr_t>(memory) % GLOBAL_ALIGNMENT == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the assertion that was failing. The memory address was aligned to 8 not 16 (when GLOBAL_ALIGNMENT was 16)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please provide a document/link or something saying that 8 bytes memory alignment is required on Android? I want to make sure this is not a bug or something else that is wrong. I don't want to change this value just because it solves an issue on your side.
Can you please tell me what asserts where failing exactly with 16 bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find any documents or links that says 8 bytes memory alignment is required on Android. However I just know from experience getting my Android NDK app up and running that 8 bytes is optimal.
The assertion that was failing was HeapAllocator.cpp:328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this assert was failing when GLOBAL_ALIGMNENT =16, this could be a bug. It means that the previous call:
reactphysics3d/src/memory/HeapAllocator.cpp
Line 324 in 3da2a2c
void* memory = mBaseAllocator.allocate(sizeToAllocate + sizeof(MemoryUnitHeader)); |
failed to allocated 16 bytes aligned memory. That's strange because this statement should call the following line:
return std::aligned_alloc(GLOBAL_ALIGNMENT, size); |
Can you check if this line with the call to std::aligned_alloc() really returns memory that is not 16 bytes aligned when GLOBAL_ALIGNMENT=16? This mean that there is something wrong with this standard library method on Android or maybe there is another method that should be used on Android to get aligned memory but the solution is probably not to change GLOBAL_ALIGNMENT to 8 bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have another debugging session later on today and get back to you (:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello. I know when spoke about this last year but do you have any news regarding this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't sadly. I have gone through various Physics Engines in the last year, currently settling on Bullet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks for your feedback.
While debugging Android I found that some assertions for byte alignment were failing.
Changing to 8 bytes alignment fixed the issue and I now have my build working on Android