Re: CPU multithreading is working!
Posted: Thu Nov 03, 2016 7:21 pm
Really glad to see the merge, thank you!
One thing that I'd like to mention for anyone trying to integrate multithreaded bullet into their own project:
There's a "gotcha" that happens if the pool allocator is called from a translation unit (.cpp file) outside of Bullet (like in the collision dispatcher derived class). If that external file is compiled without BT_THREADSAFE=1, then the pool allocator inline functions won't use the mutex, and you'll have a race condition.
There is a simple fix, just add this line:
At the top of any cpp file that calls the pool allocator in your project. Must be BEFORE any bullet includes.
This could be fixed in bullet by moving those pool allocator methods into a .cpp file in bullet, but then the functions can't be inlined and that could have a potential performance hit for single threaded bullet. I tried very hard to avoid compromising single-threaded bullet with my changes. Erwin, do you have a sense of how performance sensitive those pool allocator functions are?
On the graph coloring constraint solver, I may take a crack at that. I'd really like to see that too.
One thing that I'd like to mention for anyone trying to integrate multithreaded bullet into their own project:
There's a "gotcha" that happens if the pool allocator is called from a translation unit (.cpp file) outside of Bullet (like in the collision dispatcher derived class). If that external file is compiled without BT_THREADSAFE=1, then the pool allocator inline functions won't use the mutex, and you'll have a race condition.
There is a simple fix, just add this line:
Code: Select all
#define BT_THREADSAFE 1
This could be fixed in bullet by moving those pool allocator methods into a .cpp file in bullet, but then the functions can't be inlined and that could have a potential performance hit for single threaded bullet. I tried very hard to avoid compromising single-threaded bullet with my changes. Erwin, do you have a sense of how performance sensitive those pool allocator functions are?
On the graph coloring constraint solver, I may take a crack at that. I'd really like to see that too.