Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dividing workload on several threads

I was wondering if anyone knows about a good article which describes dividing workload on to several Threads? Preferebly it would be written for C# but it's really the concept I'm after, so it's not an issue if it's written for a different, similar, language.

I have a problem where I would have to divide a large amount of computing into several threads and then Sum the generated data after one iteration completes (so I would need to know that all threads have finished) and then start a new iteration, supplying all the threads with the data generated in the last iteration (the data would be modified before the end of each iteration).

I hope this makes sense, and is possible. Either way I would appreciate some advice on how to tackle the problem of computing large amounts of data divided on to several threads (so I can use more than one processor's core).

Thank you for your answers!

like image 733
David Božjak Avatar asked Jan 16 '09 07:01

David Božjak


2 Answers

You should look at Parallel FX (PFX), you can find the blog here and the download link here (Thanks Marc).

Unfortunately I don't know if this will be released for .NET 2.0/3.5 as it is currently slated for .NET 4.0.

If you're looking at implementing it yourself, look into Work Stealing Algorithms.

There is also a library named Power Threading, by Jeffrey Richter from Wintellect which has some rather good classes available for you.

like image 126
Lasse V. Karlsen Avatar answered Oct 08 '22 20:10

Lasse V. Karlsen


Lasse and Marc have already spoken about Parallel Extensions. I have a couple of blog articles (with code) about using and benchmarking it:

  • Conway's Game of Life
  • Visualising the Mandelbrot set

These might be helpful to show various different ways that work can be broken up.

like image 24
Jon Skeet Avatar answered Oct 08 '22 21:10

Jon Skeet