Multiprocessing in C++

Jul 28, 2010 at 5:22pm
Hey guys. Now that I've got my program to a point I like, I've been told to make it able to work on multiple processors. My professor gave me a book called "Parallel programming in OpenMP". However, I don't really understand what OpenMP's role is (the concept of an API has always seemed like the vaguest thing in the world to me).

I assume they did parallel processing before OpenMP. Should I use learn how to use OpenMP or could I do it without it without too much extra trouble?

Thanks!
Jul 28, 2010 at 5:30pm
Please see www.opentbb.org
I prefer it in order to implement multithreading.
Jul 28, 2010 at 5:51pm
You can find usage example here
http://cplusplus.com/articles/preview/22/
Jul 28, 2010 at 8:35pm
Do you really need one of these API's though? Can you not do it manually?

Also, I'm reading in the book right now about Shared vs Distributed memory. I'm guessing I should first try making it work on something with shared memory?
Jul 29, 2010 at 12:54am
OpenMP lets you easily parallelize code without doing a lot of refactoring. For example, you don't need to move a loop into a function to parallelize it, you just wrap it in OpenMP directives and let the compiler do its magic. It also abstracts away system details, making the program portable.

It's not accurate to call it an API, though. An API involves functions calls. That's not what OpenMP is. An OpenMP implementation is an integral part of the compiler, just like the preprocessor. You don't make any function calls in particular; instead, you give the compiler instructions that it will use to generate code for you.

Do you really need one of these API's though? Can you not do it manually?
Depends on what you mean by "manually". If you mean "call system functions to start threads", then yes, you can, but you lose portability. If you mean "start threads without using any API at all", then no and yes. No, you can't start real threads without interacting at some level with the OS (without involves using an API, at the very least the system's), but yes, you can do something very roundabout, complicated, and rather ineffective that will make a program believe it's running in a threaded environment without providing any of the benefits.
Jul 29, 2010 at 2:39pm
Hmmm, ok, that helps. Is OpenMP a good one to use? It's the one that has been suggested to me, so I guess I'll be using it.
Aug 1, 2010 at 10:14pm
Full information about OpenMP is at http://openmp.org, including the complete OpenMP 3.0 specs and a forum where you can ask questions of the OpenMP experts.

The best book for learning OpenMP is "Using OpenMP" -- more info is at the website.
Topic archived. No new replies allowed.