MIC: OpenMP 4.5 - Start

Shared memory programming on Intel Xeon Phi, best practice.

Quick reference (Fortran), home page, tutorial.
Specific for MIC (Programming Environment,)
Specific for KNL (Tutorial)

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 4.0 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) {
...
#pragma omp target map(to:y[0:N],x[0:N]) {
 double s = scalar(N, x, y);
}
...
}

and  compile the code with one of the available compilers

Hint: Phi Programming for CUDA developers,