Jump to content
  • Advertisement
Sign in to follow this  
_Sigma

MultiThreading, parallel computing questions

This topic is 3770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking into writing some scientific research models that take advantage of multiple cores by being highly threaded / potentiall distributed. However I'm a little lost and overwhelmed (in regards to the multithreaded part), so if anyone can help me out, it would be much appreciated! I've been doing some research, and it appears that there are 3 main threading libraries: Boost threads OpenMP Intel TBB I'm a little confused as to the exact differences as well as the pros and cons between the three... I plan on developing primarily on Windows, however, being able to be platform independent is a necessity. As well, since this is academic, open source + free/cheap is also needed. So if anyone could recommend one of the three (and tell me why!)(or something else) it would be great. I'm currently leaning toward Intel's, only because I kinda get what is going on with it. As well, can anyone recommend any good books to learn about multithreading, and parallel computing, including how to break down traditional algorithms into threaded ones. Thanks all! [Edited by - _Sigma on February 20, 2008 2:26:39 PM]

Share this post


Link to post
Share on other sites
Advertisement
They don't do the same things. OpenMP is an API that can help in achieving task-level parallelism. It's fairly high-level, a lot of it is automated, and it requires compiler support. But from what I've seen, it isn't particularly effective when applied to games.

Boost threads, for all that it is, is just a cross-platform wrapper around the conventional idea of a thread. Using boost::thread you can spawn threads of execution in a platform agnostic manner. It also gives you some basic syncronisation primitives to handle inter-thread communication. It doesn't get much more low-level than that.

I've never heard of or used Intel TBB, so I can't really comment on it.

Share this post


Link to post
Share on other sites
Boost threads are just a cross-platform wrapper for different OS's threading implementations (See also pthreads for a portable threading solution).

OpenMP is a language/compiler extension that allows you to use threads automagically, such as writing a for-loop and telling the compiler that it can execute iterations concurrently. It does all the threading behind the scenes for you. I've seen some people recommend this as a prototyping tool to use in conjunction with profiling to find areas of your program that will benefit from concurrency.

Intel TBB is only free for non-commercial use, so if you're only doing research it should be ok.

I haven't actually used any of these 3 tools, so someone please correct me if I'm wrong ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by _Sigma
I'm looking into writing some scientific research models that take advantage of multiple cores by being highly threaded / potentiall distributed.


Look at MPI for distributed parallelism. I think Boost has a C++ MPI wrapper, but I don't know what it's like to use. Probably nicer than the native C interface, I expect.

The other alternative, which you should seriously consider/investigate if possible, is to use a language other than C++. C++ doesn't even have a multithreaded memory model (yet).

There have been a bunch of threads recently on reading recommendations. You might want to have a look for those.

Share this post


Link to post
Share on other sites
Quote:
There have been a bunch of threads recently on reading recommendations. You might want to have a look for those.

Do you know of any off the top of your hat?

Thanks for all the replys. Does anyone see anything wrong with using intel's TBB then?

Share this post


Link to post
Share on other sites
Found this one.

There are others.

Quote:
Thanks for all the replys. Does anyone see anything wrong with using intel's TBB then?


It doesn't have any mechanism to handle exceptions, which I find bothersome. You have to be very careful that each chunk of work does not throw.

Share this post


Link to post
Share on other sites
OpenMP is pretty cool, for what you're doing it could be a good option. I wrote an article on it here.

However you need to decide early on if you want to pursue multithreaded or distributed solutions. I think there is an OMP-like distributed library somewhere.

Share this post


Link to post
Share on other sites
Quote:
Original post by d000hg
However you need to decide early on if you want to pursue multithreaded or distributed solutions. I think there is an OMP-like distributed library somewhere.


Why? They're essentially the same thing. Is it because OpenMP only works with threads?

Share this post


Link to post
Share on other sites
Quote:
Original post by Hodgman
Intel TBB is only free for non-commercial use, so if you're only doing research it should be ok.


An open source version of TBB is available here. This can be used commercially.

Share this post


Link to post
Share on other sites
Quote:
Original post by _Sigma
I'm looking into writing some scientific research models that take advantage of multiple cores by being highly threaded / potentiall distributed. However I'm a little lost and overwhelmed, so if anyone can help me out, it would be much appreciated!

[caution] Generally, writing about this type of thing is done by topical experts who have already written them, or under the direction of someone who has already written in a related field (such as a graduate-school professor). It can take significant research on your part before you become expert enough on a topic to write such models. Also, part of 'scientific' involves peer review, which left undone can completely shred the reputation of a novice or upcoming professional who lacks the required experience and expertise.

Feeling lost and overwhelmed is probably a good sign that you are not expert enough to write them. For their first real research projects, graduate students generally feel capable and knowledgeable about the topic yet slightly wary of actually putting it out for public consumption.

Your choices for that list of "3 main threading libraries" shows just how little you know about the field. Most parallel scientific computing models involve networks of machines. A single PC isn't going to do serious weather forecasting, analyze sea floor sonar scans for oil beds, review your medical scans searching for cancer, render next year's new animated movies, or perform most other serious real-world tasks.

Consequently, relatively few real-world scientific parallel computing models take advantage of those specific technologies except to help performance on the individual machine rather than the core algorithm. The main libraries for C and C++ based applications are PVM and MPI, with some other message passing libraries thrown in for flavor.

Fairly new topics include GPGPU programming for relatively small data-parallel programs on a single computer, but those are not really used in industry at present. Note that even GPGPU is being seen as an optimization for the individual machines in a cluster, not a replacement of the cluster.

Quote:
Original post by _Sigma
As well, can anyone recommend any good books to learn about multithreading, and parallel computing, including how to break down traditional algorithms into threaded ones.

A good (although slightly out of date) book is "Designing and Building Parallel Programs", available in dead-tree edition, and also generously made freely available by the author here. The book covers the major method of breaking down algorithms and rebuilding them in parallel ways.

Many other good books (I'm not going to list them, do some research on your own!) are available in dead-tree form.

Quote:
Original post by the_edd
The other alternative, which you should seriously consider/investigate if possible, is to use a language other than C++.

Here is a 10-year-old list of parallel languages. That list doesn't pretend to be complete back then, and many new languages have cropped up. It does cover the major languages. New languages are based on those.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!