Lecture 6 - OpenMP


Agenda

Announcements

OpenMP

We started to discuss OpenMP last week.

Please read this OpenMP Tutorial from Lawrence Livermore National Labs.

The official OpenMP web site is http://www.openmp.org.

Functionally, OpenMP programming is similar to pthreads programming, but OpenMP puts some more of the burden on the compiler.

A few things to mention (or recap):

Last time, we looked at an example of an OpenMP matrix-matrix multiply, where we used a #pragma omp parallel for directive to let OpenMP parallelize our for loop.

We can also take more control, similar to the way we did with pthreads:

More clauses to parallel directives

A parallel directive can take a number of clauses to define how variables are to be treated.

Other parallel directives

There are several other directives worth looking at a bit:

Yet another matrix-matrix multiply example that uses some of these:

matmult_omp_explicit3.tgz Also available in /home/faculty/terescoj/shared/cs338/lect06.

OpenMP Locks

OpenMP has lock variable type and associated functions to operate on them that work a lot like pthread mutex. Often, the critical directive can be used, but these are more general.