Dual threads? Or Parallel threads?

View previous topic View next topic Go down

Dual threads? Or Parallel threads?

Post by Thraka on Fri Apr 15, 2011 11:08 pm

One of your tech posts stated single or dual threads, would these be parallel threads? I would rather take full use of multicore Smile

Thraka

Posts : 2
Join date : 2011-04-15

View user profile

Back to top Go down

Re: Dual threads? Or Parallel threads?

Post by Slaihne on Sat Apr 16, 2011 3:19 am

The way my engine works at the moment is it tries to split the 'work' (recreating chunks) into units (creating blocks, generating light, making meshes) and then these work units can be processed within the main loop or on a a single thread parallel to the gameloop.

I went down this path because on testing with a dual core machine i noticed some slowdowns occurring when the work thread basically consumed 100% of a core.

I would have liked to adopt a more multi core friendly approach but didn't want to end up with loads of locking issues which would increase the complexity of the whole thing.

There is just one interface between the gameloop and the building code and that is the meshes. The bulding code creates them and queues them up then the gameloop gets them from the queue and draws them. This is the only real area where locking or synching is done atm.
avatar
Slaihne

Posts : 264
Join date : 2011-03-17
Age : 50

View user profile

Back to top Go down

Re: Dual threads? Or Parallel threads?

Post by S33m3 on Mon Apr 18, 2011 2:47 pm

I'm using multi threading in my voxel engine.

It's quite tricky to put in place, but when it's done, it works very well.

What I do mainly in parallel :
- Creating chunk landscape from 3D & 2D simplex Noises
- Creating Vertex/Index Buffers

From my experience, I need to limit the number of "background worker" threads that can run in parallel to the number of real CPU core minus 1 (1 left for the main render Loop).
Going above this, and you begin to have an impact on the main render loop.

On my 8 cpu (4 virtual one) cores, I use "only" 3 background worker. And it works very well.

It is generating the landscape (3d and 2d simplex noises mixed up), vertex buffer and index buffer of 1156 chunks (16*16*128 blocks) in 5 secondes.

One thing : I stopped using the "default" .net threadpool mechanism for this very nice thread pool manager : http://www.codeproject.com/KB/threads/smartthreadpool.aspx

Mainly because, it can handle things that the default threadpool cannot :
- Giving priority to submitted tasks <== Most important one !!!
- Cancel queued tasks
- Can create group of tasks for synch cases
- ...


S33m3

Posts : 54
Join date : 2011-03-23

View user profile

Back to top Go down

Re: Dual threads? Or Parallel threads?

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum