Posix Thread Support - Patch & small benchmark
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Posix Thread Support - Patch & small benchmark
Hi everybody,
this is the fourth incarnation of my multi-threading support for Bullet and it is by far the best one
First things first: Patch Download (19KiB) - for Bullet 2.66
This patch will add PosixThreadSupport.[cpp|h] to Extras/BulletMultithreaded/. I modified the MultiThreadedDemo to use the Posix Thread support. So far I have seen no errors or problems
To verify it works, I made some benchmarks on my 2.8Ghz Core 2 Duo with the MultiThreadedDemo (click for bigger image):
These numbers are just meant to give an estimation, there are some details missing for a "real" benchmark
The work dispatcher seems to have a (very) high overhead. When I add the parallel solver, frame time increases ca. 20ms.
Code's license is Public Domain, however it would be nice if you add my name as author and leave the name in the code =)
Erwin, did you know, that BulletMultiThreaded does not compile under AMD64 Linux?
So the patch works (and is tested) only on x86.
Best regards,
Enrico
this is the fourth incarnation of my multi-threading support for Bullet and it is by far the best one
First things first: Patch Download (19KiB) - for Bullet 2.66
This patch will add PosixThreadSupport.[cpp|h] to Extras/BulletMultithreaded/. I modified the MultiThreadedDemo to use the Posix Thread support. So far I have seen no errors or problems
To verify it works, I made some benchmarks on my 2.8Ghz Core 2 Duo with the MultiThreadedDemo (click for bigger image):
These numbers are just meant to give an estimation, there are some details missing for a "real" benchmark
The work dispatcher seems to have a (very) high overhead. When I add the parallel solver, frame time increases ca. 20ms.
Code's license is Public Domain, however it would be nice if you add my name as author and leave the name in the code =)
Erwin, did you know, that BulletMultiThreaded does not compile under AMD64 Linux?
So the patch works (and is tested) only on x86.
Best regards,
Enrico
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
Erwin (or some of the other bullet developers), not interested?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Posix Thread Support - Patch & small benchmark
hi Enrico,
Thanks a lot for your contribution. We are crunching on Game Developers Conference preparations, so your posting slipped our attention.
We definately check it out. Note that BulletMultiThreaded was designed for Cell SPU, with massive speedup there. PC multicore version (and other platdorms) will be optimized, in collaboration with hardware manufacturers, and game developers who use it.
The parallel solver currently lacks several optimizations, that are present in the serial version, and overhead on non-Cell platforms needs improvement. How does the parallel collision detector perform multi-core?
We check out your patch, and it could go either in 2.67 or next.
Thanks!
Erwin
Thanks a lot for your contribution. We are crunching on Game Developers Conference preparations, so your posting slipped our attention.
We definately check it out. Note that BulletMultiThreaded was designed for Cell SPU, with massive speedup there. PC multicore version (and other platdorms) will be optimized, in collaboration with hardware manufacturers, and game developers who use it.
The parallel solver currently lacks several optimizations, that are present in the serial version, and overhead on non-Cell platforms needs improvement. How does the parallel collision detector perform multi-core?
We check out your patch, and it could go either in 2.67 or next.
Thanks!
Erwin
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
I did not meant to be a pain in the neck and I completely forgot about GDCErwin Coumans wrote:Thanks a lot for your contribution. We are crunching on Game Developers Conference preparations, so your posting slipped our attention. We definately check it out.
I just expected any feedback, like you gave now
I use it. Is this enough?Note that BulletMultiThreaded was designed for Cell SPU, with massive speedup there. PC multicore version (and other platdorms) will be optimized, in collaboration with hardware manufacturers, and game developers who use it.
Or do you require some Big Player to spend effort there?
The diagrams above are made with the parallel collision detector (if this is the "USE_PARALLEL_DISPATCHER" from the multithreaded demo). The "experimental parallel solver" (USE_PARALLEL_SOLVER) adds another constant cost of 20ms per frame. I never saw any result where the parallel solver matches the timings from the serial solver, so I removed it from the diagrams.The parallel solver currently lacks several optimizations, that are present in the serial version, and overhead on non-Cell platforms needs improvement. How about the parallel collision detector?
Ok, so I am anxiously awaiting your review results
Best regards,
Enrico
PS: Any plans to fix the 64Bit build under Linux? I can look into this too
-
- Posts: 5
- Joined: Mon Feb 25, 2008 6:32 am
Re: Posix Thread Support - Patch & small benchmark
I'm on AMD64 Linux, but just getting started with Bullet. Right now I'm still getting my bearings, but I will try to spend some time with this patch and the multithreaded stuff. Subscribing to this thread, so please post if there's any updates.
Cheers.
EDIT:
Took a closer look at some of the build errors.
In SpuParallelSolver.cpp, line 11:
#include "LinearMath/btQuickProf.h
Should be:
#include "LinearMath/btQuickprof.h"
After that, there's a bunch of casting errors. For a couple it seems like changing (uint32_t) to (uint64_t) resolves the error. The rest are casts to ppu_address_t. If you look in /Extras/BulletMultiThreaded/PpuAddressSpace.h, you'll note that if you define USE_ADDR64 then it will use the correct typedef for ppu_address_t.
Now that I found that, I realize -- should the (uint32_t) casts in SpuParallelSolver.cpp be using the ppu_address_t instead?
Still 4 errors, but much closer... I'll poke around some more later this week!
Cheers.
EDIT:
Took a closer look at some of the build errors.
In SpuParallelSolver.cpp, line 11:
#include "LinearMath/btQuickProf.h
Should be:
#include "LinearMath/btQuickprof.h"
After that, there's a bunch of casting errors. For a couple it seems like changing (uint32_t) to (uint64_t) resolves the error. The rest are casts to ppu_address_t. If you look in /Extras/BulletMultiThreaded/PpuAddressSpace.h, you'll note that if you define USE_ADDR64 then it will use the correct typedef for ppu_address_t.
Now that I found that, I realize -- should the (uint32_t) casts in SpuParallelSolver.cpp be using the ppu_address_t instead?
Still 4 errors, but much closer... I'll poke around some more later this week!
-
- Posts: 5
- Joined: Mon Feb 25, 2008 6:32 am
Re: Posix Thread Support - Patch & small benchmark
amd64threads.patch
Here's a small patch to svn 1051 that fixes the remaining build errors. It now builds successfully on Ubuntu 7.10 AMD64 with the definition of USE_ADDR64.
I haven't been able to test Enrico's patch because his site seems to be down for maintenance.
Here's a small patch to svn 1051 that fixes the remaining build errors. It now builds successfully on Ubuntu 7.10 AMD64 with the definition of USE_ADDR64.
I haven't been able to test Enrico's patch because his site seems to be down for maintenance.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Posix Thread Support - Patch & small benchmark
We will accept and apply those patches for Bullet 2.68 (Bullet 2.67 is to be released today)
See issue to track the status:
http://code.google.com/p/bullet/issues/detail?id=26
Thanks a lot for the patches.
See issue to track the status:
http://code.google.com/p/bullet/issues/detail?id=26
Thanks a lot for the patches.
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
Thanks for your helpmb108 wrote:amd64threads.patch
Here's a small patch to svn 1051 that fixes the remaining build errors. It now builds successfully on Ubuntu 7.10 AMD64 with the definition of USE_ADDR64.
I haven't been able to test Enrico's patch because his site seems to be down for maintenance.
My site should be back this week, so you can test the patch
Erwin, great news. Thanks
-
- Posts: 5
- Joined: Mon Feb 25, 2008 6:32 am
Re: Posix Thread Support - Patch & small benchmark
I've applied this to a fresh 2.66 on Ubuntu amd64. I had to fix up BulletMultiThreaded to use ppu_address_t instead of uint32_t, define USE_ADDR64, and add pthread to the CMakeLists.txt LINK_LIBRARIES for MultiThreadedDemo and AllBulletDemos.
Here's the output:
any ideas?
(I've got a busy week coming up, but I'll come back to this.)
Here's the output:
Code: Select all
startThreads creating 4 threads.
starting thread 0
started thread 0
starting thread 1
started thread 1
starting thread 2
started thread 2
starting thread 3
started thread 3
sizeof SpuGatherAndProcessWorkUnitInput: 16
Segmentation fault (core dumped)
any ideas?
(I've got a busy week coming up, but I'll come back to this.)
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
Oh
Maybe on 64Bit something is different?!? I tested this patch intensely on several x86 machines and never had any crashes or something. What machine are you using?
I will try tonight on my box, now that it works in amd64?
Maybe on 64Bit something is different?!? I tested this patch intensely on several x86 machines and never had any crashes or something. What machine are you using?
I will try tonight on my box, now that it works in amd64?
-
- Posts: 133
- Joined: Wed Jul 27, 2005 1:05 pm
- Location: Berkeley, CA
Re: Posix Thread Support - Patch & small benchmark
Enrico, have you been able to reproduce this crash on x86-64?
I would like to get this into bullet for the 2.68 release.
I would like to get this into bullet for the 2.68 release.
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
Unfortunately I was able to reproduce this crash. Good for me (and my patch ) it is a problem with the multithreaded demo on any x86_64 system and it is not caused by the Posix thread dispatcher!John McCutchan wrote:Enrico, have you been able to reproduce this crash on x86-64?
I would like to get this into bullet for the 2.68 release.
For debugging I used the Sequential Thread Dispatcher and this causes the same segmentation fault as with the Posix thread dispatcher
I tried on Debian testing with GCC 4.2.3 on a Core 2 Duo and AMD X2.
Maybe it is due to the many warnings when compiling BulletMultihreaded. I only had one hour for debugging and fixing compile errors. I will try to look into this problem more on Wednesday...
-
- Posts: 133
- Joined: Wed Jul 27, 2005 1:05 pm
- Location: Berkeley, CA
Re: Posix Thread Support - Patch & small benchmark
I have committed your posix threads patch. Thanks for contributing to Bullet!
I have not committed the x86-64 patch because it appears not to work.
I have not committed the x86-64 patch because it appears not to work.
-
- Posts: 169
- Joined: Sun Jan 14, 2007 7:56 pm
- Location: Norway
Re: Posix Thread Support - Patch & small benchmark
Hi everyone,
I just checked out the last svn version 1127. I'm running Linux on a Intel centrino duo laptop.
Just thought I'd report that the MultiThreadedDemo segfaults in double precision mode, but works fine in single precision.
Best regards,
Ola
I just checked out the last svn version 1127. I'm running Linux on a Intel centrino duo laptop.
Just thought I'd report that the MultiThreadedDemo segfaults in double precision mode, but works fine in single precision.
Best regards,
Ola
-
- Posts: 42
- Joined: Thu May 17, 2007 9:34 am
- Location: Stuttgart, Germany
Re: Posix Thread Support - Patch & small benchmark
Hi,
does it crash with the Posix Thread stuff or Sequential Thread Dispatcher?
I assume you use a x86 (32 Bit) Linux? Which one and which compiler?
I will check both problems within the next days, it is on my TODO...
does it crash with the Posix Thread stuff or Sequential Thread Dispatcher?
I assume you use a x86 (32 Bit) Linux? Which one and which compiler?
I will check both problems within the next days, it is on my TODO...