/* L-29 MCS 572 Wed 29 March 2006: our first program with OpenMP
   to use 8 threads, type "setenv OMP_NUM_THREADS 8"
   compile with "cc_r -qsmp=omp -o hello_world hello_world.c"
   and run, typing "hello_world" at the command prompt. */

#include <omp.h>
#include <stdio.h>

int main ( int argc, char *argv[] )
{
   #pragma omp parallel     /* parallel section executed by all threads */
   {
      int id = omp_get_thread_num();    /* returns thread id number */
      int nt = omp_get_num_threads();   /* returns number of threads */

                                        /* manager announces #threads */
      if(id == 0) 
         printf("Manager thread %d announces #threads = %d\n",id,nt);

                                        /* every thread says hello */

      printf("Hello world from %d out of %d.\n",id,nt);
   }

   return 0;
}
