Using OpenMP

Barbara Chapman, Gabriele Jost, Ruud van der Pas

Mentioned 4

A comprehensive overview of OpenMP, the standard application programming interface for shared memory parallel computing--a reference for students and professionals.

More on

Mentioned in questions and answers.

I am working to become a scientific programmer. I have enough background in Math and Stat but rather lacking on programming background. I found it very hard to learn how to use a language for scientific programming because most of the reference for SP are close to trivial.

My work involves statistical/financial modelling and none with physics model. Currently, I use Python extensively with numpy and scipy. Done R/Mathematica. I know enough C/C++ to read code. No experience in Fortran.

I dont know if this is a good list of language for a scientific programmer. If this is, what is a good reading list for learning the syntax and design pattern of these languages in scientific settings.

this might be useful: the nature of mathematical modeling

Writing Scientific Software: A Guide to Good Style is a good book with overall advice for modern scientific programming.

I'm a scientific programmer who just entered the field in the past 2 years. I'm into more biology and physics modeling, but I bet what you're looking for is pretty similar. While I was applying to jobs and internships there were two things that I didn't think would be that important to know, but caused me to end up missing out on opportunities. One was MATLAB, which has already been mentioned. The other was database design -- no matter what area of SP you're in, there's probably going to be a lot of data that has to be managed somehow.

The book Database Design for Mere Mortals by Michael Hernandez was recommended to me as being a good start and helped me out a lot in my preparation. I would also make sure you at least understand some basic SQL if you don't already.

One issue scientific programmers face is maintaining a repository of code (and data) that others can use to reproduce your experiments. In my experience this is a skill not required in commercial development.

Here are some readings on this:

These are in the context of computational biology but I assume it applies to most scientific programming.

Also, look at Python Scripting for Computational Science.

I have a fair hang of programming in various languages. I have been implementing my codes for research using MATLAB (during the past few months) and for the first time really noticed the difference in execution speed of MATLAB v$ C. (As much as I love the blazingly fast prototyping capabilities).

I am looking to pickup C++ and start using it in my research. I am aware of OOP and have programmed fair bit of Java (relatively long back) and C++ (even longer back). I would like to really get deep into C++ now and hence need suggestions for resources on the same:

  • What C++ things I need to pick up (STLs and. ) to really make good use of C++?
  • What is a good tutorial/manual to get started with?
  • What are the numerical/scientific libraries for C++? GSL? Is there a equivalent (features) of Scipy/Numpy for C++?

I shall be programming on Linux, so I shall be using g++ .

Any pointers to previous SO questions also appreciated.

You'll want to get to grips with parallel programming as quickly as possible. For message-passing I like this book by Karniadakis and Kirby. Of the books on OpenMP, for distributed-memory programming, this one is the best.

If you can get access to them, then Intel's Threading Building Blocks, Maths Kernel Library, and Integrated Performance Primitives are good to have. If not, there are plenty of open source alternatives, start looking at Netlib.

Oh, I almost forgot BOOST, which is a must.

I've been programming with C and FORTRAN for the past 6 years, but I have only done serial programming until now. I would now like to switch to parallel program design, but I haven't really found a book that would help me make this jump. I have looked at Chandra's book on Parallel programming in OpenMP and Michael J. Quinn's book on programming in C with Open Mp and MPI, but I was wondering if there was a better alternative to these two. Thanks in advance!


I can recommend Using OpenMP by Chapman, Jost and Van de Pas. It's a really good introduction to OpenMP and includes plenty of details on using the language and getting best performance.

This tutorial might also be a useful introduction if you have never experienced parallel programming, it's a good entry to the general concepts and ideas.

I have C/C++ source files written with OMP instrumentation. For example, in a C++ class file:

#pragma omp parallel sections
    #pragma omp section
        cp = ModularSquareRoot(cp, m_p);
    #pragma omp section
        cq = ModularSquareRoot(cq, m_q);

For benchmarking and testing, I want to build the library with -fopenmp but disable it on this particular class file. I hope I can add something like #pragma omp disable or similar in the class's header file to disable it for the translation unit. But #pragma omp disable was silently ignored.

I've looked through Using OpenMP: Portable Shared Memory Parallel Programming, but I have not seen how to do it. (I could well be missing it because I have not read it completely).

I'm trying to avoid modifying CXXFLAGS, makefile recipes and Visual Studio project settings.

Is there a way to disable OMP in a particular translation unit at the source file?