Horde3D

Next-Generation Graphics Engine
It is currently 25.11.2024, 07:01

All times are UTC + 1 hour




Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: 30.10.2008, 02:24 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
DarkAngel wrote:
probably a good idea to put a comment in there with my justification of why it's ok, otherwise other people might not trust it either ;)

Yes, would be better.

Quote:
If we can't put thread-creation in the util library, then I'd be up for writing some a sample program for GLFW and one for Boost that show how to create the threads (perhaps license the sample code as BSD so people can use it directly with their own code?).

The samples are public domain / "do whatever you want". Having a good sample which shows the benefits of threads would be great.


Top
 Profile  
Reply with quote  
PostPosted: 03.11.2008, 23:11 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
This is a very interesting thread...

Codepoet, my first try would also have been to generate a list of nodes that need to be updated. But just going over the direct children of the root node sounds like a clever idea and should be reasonable for most cases (except when someone puts an additional group-node to the root which contains all of his scene). I also like DarkAngel's idea very much to outsource the threading to an external layer and hence keep the engine core slim and free from additional dependencies.

Another interesting thing could be OpenMP. Did you already consider using it? This would have been my first test. It offers in general a very convenient way to parallelize for-loops and could fit quite nicely to the idea of just treating the root's children (which are handled in a for-loop anyway) as parallel.


Top
 Profile  
Reply with quote  
PostPosted: 04.11.2008, 00:59 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
marciano wrote:
(except when someone puts an additional group-node to the root which contains all of his scene)
I'm actually doing this in my engine :oops:

I have a RootNode class of my own (to allow multiple root nodes / scenes) -- in it's constructor it creates a Horde group node with the Horde root node as the parent.


Top
 Profile  
Reply with quote  
PostPosted: 04.11.2008, 14:45 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
DarkAngel wrote:
marciano wrote:
(except when someone puts an additional group-node to the root which contains all of his scene)
I'm actually doing this in my engine :oops:
I have a RootNode class of my own (to allow multiple root nodes / scenes) -- in it's constructor it creates a Horde group node with the Horde root node as the parent.
I am using a quick hack, which gives each camera a RootNode parameter. It saves all the visibility setup between rendering scenes, but it would also let you handle this case efficiently.

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 04.11.2008, 14:49 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
Quote:
Another interesting thing could be OpenMP. Did you already consider using it? This would have been my first test. It offers in general a very convenient way to parallelize for-loops and could fit quite nicely to the idea of just treating the root's children (which are handled in a for-loop anyway) as parallel.

I have never worked with OpenMP so far. But replacing my thread pool with OpenMP pragmas should be straight forward.
The advantage of it would be that we don't need a thread API. But then applications that already use threads can't as easily control it like with DarkAngel's idea.

Quote:
(except when someone puts an additional group-node to the root which contains all of his scene)

The general solution is to use a list of all nodes, but that comes with a huge overhead. But with sufficiently large scenes and enough available cores that would probably be the way to go.
When the root scene node has exactly one child node, we can treat that as a special case.

Quote:
I am using a quick hack, which gives each camera a RootNode parameter. It saves all the visibility setup between rendering scenes, but it would also let you handle this case efficiently.

I really like that idea, way better than making it a special case.


Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 13:06 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Codepoet wrote:
Quote:
Another interesting thing could be OpenMP. Did you already consider using it? This would have been my first test. It offers in general a very convenient way to parallelize for-loops and could fit quite nicely to the idea of just treating the root's children (which are handled in a for-loop anyway) as parallel.

I have never worked with OpenMP so far. But replacing my thread pool with OpenMP pragmas should be straight forward.
The advantage of it would be that we don't need a thread API. But then applications that already use threads can't as easily control it like with DarkAngel's idea.

With OpenMP it is very easy to control the maximum number of threads used for a parallel section. That variable could just be exposed as an engine option.


Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 17:50 
Offline

Joined: 26.03.2008, 02:58
Posts: 160
I am trying to see if i can understand what you guys are trying to design. Basically you want to implement a producer/consumer pattern that uses a thread pool pattern (dynamic number of threads) to process each branch of the graph tree, using statistical run-time data to optimize the size of the thread pool. Is this the general idea of the design?

BTW, this online event: Jon Olick on Parallelism and Engine Architecture, November 9th - http://forums.aigamedev.com/showthread.php?t=1535 may be of interest.


Last edited by DDd on 09.11.2008, 18:35, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 18:32 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
I wonder if it makes sense to optimize Horde3D for more than one core if one would intend to create a GameEngine. If you are using Horde3D only for visualization issues, I guess it might perform better. But for a gameengine you have physics, ai, sound, etc. that could use the remaining CPU cores as well. I tried to do that in the GameEngine published to the Community SVN. In this approach all entities contain several components. Each type of component has a component manager and all component managers will be updated in parallel. After all calculations are finished the state of the entities' components are synchronized using an event system. In small application examples the result was not that impressive, because most CPU power was taken by the physics, while all other component managers did their calculations much faster and had to wait for the bullet physics engine.

Sorry if that comment was a bit off topic :-) Generally I really appreciate the work done by codepoet and just wanted to focus a little bit on the usage of Horde3d in an application.


Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 18:58 
Offline

Joined: 26.03.2008, 02:58
Posts: 160
Volker wrote:
After all calculations are finished the state of the entities' components are synchronized using an event system. In small application examples the result was not that impressive, because most CPU power was taken by the physics, while all other component managers did their calculations much faster and had to wait for the bullet physics engine.


It's an interesting research topic nonetheless, personally i am following your idea Volker, and using the cores for game engine processing, this appears to be the trend on 1st order game parallel systems. Targeting quad cores, i have divided the cores into: Rendering (Video and Audio), Data (De)compression, Logic/Animation/AI and Physics.

BTW, did you ever play around with the idea of dividing each of the components into smaller tasks/chunks, and use dynamic scheduling so that the system did not have to wait for a specific thread (in this case the physics thread). This to me looks like the hardest thing to do. Create a division of tasks and data chunks that works well, for the time being i am using a tolerant rendering algorithm, so it uses the correct available data not the most current (though hopefully in most cases the data will be the same (best+current))...


Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 19:50 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Maybe one could use bullet's integrated multithreading support to improve performance.


Top
 Profile  
Reply with quote  
PostPosted: 09.11.2008, 23:07 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Here is a quite interesting presentation:

http://www.lrr.in.tum.de/~klug/events/G ... DGames.pdf

For a game engine that has a similar design as the Smoke framework (using a job pool for modules and smaller subtasks) it makes really sense to use callback functions as DarkAngel proposes.


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 23:30 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
Volker: I don't know if it's a good idea to add the dependency on bullet if the program which uses Horde3D does not use it other than for threading.
Regarding physics, AI, etc. you are right: These tasks can use the CPU more efficiently, especially if they don't need to do complicated scatter / gather operations.

So I wont do further work on this patch, but it was a nice experiment. If anybody is interested in trying it out and adapting the code, it should be easy enough to follow what I did.


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 23:43 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Codepoet wrote:
Volker: I don't know if it's a good idea to add the dependency on bullet if the program which uses Horde3D does not use it other than for threading.

No no, I didn't want to use bullets multi threading system for Horde3D. I just wanted to mention that one could use Bullet's multi-threading system within bullet. If I remember correctly, it is not active by default and so all physic calculations will be done in one thread.


Top
 Profile  
Reply with quote  
PostPosted: 16.11.2008, 23:44 
Offline

Joined: 14.04.2008, 15:06
Posts: 183
Location: Germany
ok ;)


Top
 Profile  
Reply with quote  
PostPosted: 17.11.2008, 20:56 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
Codepoet wrote:
So I wont do further work on this patch, but it was a nice experiment. If anybody is interested in trying it out and adapting the code, it should be easy enough to follow what I did.

It definitely was, thanks a lot! I think such experiments are very valuable even if they don't result in a new feature immediately.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


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:  
cron
Powered by phpBB® Forum Software © phpBB Group