Running OpenMP applications on our system


Example Code

Try out my simple openMP examples, you can copy them over from here:
cp -r ~newhall/public/openMP_examples .

adding OpenMP code to C program
Include the opm.h file and then add in #pragma and other constructs. Here is a simple example:
#include <stdio.h>
#include <stdlib.h>
#ifdef _OPENMP
#include <omp.h>
#endif

int main() {
   int tid = -1;
#pragma omp parallel private(tid) // Start of parallel region: forks threads
   {
     tid = omp_get_thread_num();  // default is number of CPUs on machine
     printf("Hello from Thread %d\n",tid);
     if(tid ==0) {
        printf("Number of threads = %d\n", omp_get_num_threads());
     }
   }  // ** end of the the parallel: joins threads
   return 0;
}

Compiling and Running