[83] is a popular and powerful language for specifying thread-based parallelism. While OpenMP provides some tools for general threaded parallelism, one of the most common uses is to parallelize a loop. If the loop contains no MPI calls, then OpenMP may be combined with MPI. For example, in the Jacobi example, OpenMP can be used to parallelize the loop computation:
exchange_nbrs( u_local, i_start, i_end, left, right ); #pragma omp for for (i_local=1; i<=i_end-i_start+1; i++) for (j=1; j<=NY; j++) ulocal_new[i_local][j] = 0.25 * (ulocal[i_local+1][j] + ulocal[i_local-1][j] + ulocal[i_local][j+1] + ulocal[i_local][j-1] - h*h*flocal[i_local][j]);
This exploits the fact that MPI was designed to work well with other tools, leveraging improvements in compilers and threaded parallelism.