Multi-Core programming with OpenMP with GOMP


Compilation:
Within the source, type the following.
#pragma omp parallel for

Before a for loop doing number crunching.

Example from Wiki http://en.wikipedia.org/wiki/OpenMP:

int main(int argc, char *argv[]) {
    const int N = 100000;
    int i, a[N];
 
    #pragma omp parallel for
    for (i = 0; i < N; i++)
        a[i] = 2 * i;
 
    return 0;
}

Compile with -fopenmp i.e. gcc -fopenmp
Link with gomp i.e. gcc -lgomp

Comments

Popular posts from this blog

Imote2 with Camera setup IMB400 over Ubuntu 9.10/10.04

Branch and bound algorithm in C#- Article by AsiF Munir

Tensorflow - Simplest Gradient Descent using GradientDescentOptimizer