OpenMP - Start

Shared memory programming.

OpenMP: Quick reference (3.1, 4.0, 4.5, 5.0), home page, tutorial (LLNL).

Tools

How to OpenMP-parallelize the inner product:

Original code for inner product:
double scalar(const int N, const double x[], const double y[])
{
 double sum = 0.0;
 for (int i=0; i<N; ++i)
 {
    sum += x[i]*y[i];
 }
 return sum;
}

int main()
{
...
double s = scalar(n,a,b);
...
}


OpenMP code for inner product:
double scalar(const unsigned int N, const double x[], const double y[])
{
    double sum = 0.0;
    unsigned int i;
    #pragma omp parallel for private(i) shared(x,y) schedule(static) reduction(+:sum)
    for (i = 0; i < N; ++i) {
        sum += x[i] * y[i];
    }
    return sum;
}


int main(int argc, char **argv) {
... {
 double s = scalar(N, x, y);
}
...
}

and  compile the code with one of the available compilers