Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Fri Feb 08, 2008 6:56 pm 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
Hi everybody,

this is the fourth incarnation of my multi-threading support for Bullet and it is by far the best one :lol:

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 :D

To verify it works, I made some benchmarks on my 2.8Ghz Core 2 Duo with the MultiThreadedDemo (click for bigger image):
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


Top
 Profile  
 
PostPosted: Thu Feb 14, 2008 12:27 pm 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
Erwin (or some of the other bullet developers), not interested? :(


Top
 Profile  
 
PostPosted: Thu Feb 14, 2008 1:22 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
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


Top
 Profile  
 
PostPosted: Thu Feb 14, 2008 3:46 pm 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
Erwin 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 did not meant to be a pain in the neck and I completely forgot about GDC :oops:
I just expected any feedback, like you gave now ;)

Quote:
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.

I use it. Is this enough? :lol:
Or do you require some Big Player to spend effort there?

Quote:
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?

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.

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 ;)


Top
 Profile  
 
PostPosted: Mon Feb 25, 2008 6:48 am 
Offline

Joined: Mon Feb 25, 2008 6:32 am
Posts: 5
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! :D


Top
 Profile  
 
PostPosted: Tue Feb 26, 2008 9:39 pm 
Offline

Joined: Mon Feb 25, 2008 6:32 am
Posts: 5
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.


Top
 Profile  
 
PostPosted: Wed Feb 27, 2008 8:42 pm 
Offline
Site Admin
User avatar

Joined: Sun Jun 26, 2005 6:43 pm
Posts: 3744
Location: California, USA
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.


Top
 Profile  
 
PostPosted: Thu Feb 28, 2008 7:47 am 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
mb108 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.

Thanks for your help :)
My site should be back this week, so you can test the patch :) :)


Erwin, great news. Thanks :)


Top
 Profile  
 
PostPosted: Mon Mar 31, 2008 4:42 am 
Offline

Joined: Mon Feb 25, 2008 6:32 am
Posts: 5
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:
Code:
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)


:mrgreen:

any ideas?

(I've got a busy week coming up, but I'll come back to this.)


Top
 Profile  
 
PostPosted: Mon Mar 31, 2008 5:50 am 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
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?


Top
 Profile  
 
PostPosted: Mon Mar 31, 2008 6:38 pm 
Offline
User avatar

Joined: Wed Jul 27, 2005 1:05 pm
Posts: 133
Location: Berkeley, CA
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.


Top
 Profile  
 
PostPosted: Mon Mar 31, 2008 8:12 pm 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
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.

Unfortunately I was able to reproduce this crash. Good for me (and my patch :-D ) it is a problem with the multithreaded demo on any x86_64 system and it is not caused by the Posix thread dispatcher!
For debugging I used the Sequential Thread Dispatcher and this causes the same segmentation fault as with the Posix thread dispatcher :cry:
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...


Top
 Profile  
 
PostPosted: Tue Apr 01, 2008 6:38 pm 
Offline
User avatar

Joined: Wed Jul 27, 2005 1:05 pm
Posts: 133
Location: Berkeley, CA
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.


Top
 Profile  
 
PostPosted: Tue Apr 08, 2008 3:47 pm 
Offline

Joined: Sun Jan 14, 2007 7:56 pm
Posts: 169
Location: Norway
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


Top
 Profile  
 
PostPosted: Tue Apr 08, 2008 3:53 pm 
Offline

Joined: Thu May 17, 2007 9:34 am
Posts: 42
Location: Stuttgart, Germany
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group