All pastes #963761 Raw Edit

Untitled

public text v1 · immutable
#963761 ·published 2008-03-30 20:09 UTC
rendered paste body
#include <omp.h>
#include <stdlib.h>
#include <stdio.h>

main ()  {

int nthreads, tid;

/* Fork a team of threads giving them their own copies of variables */
#pragma omp parallel private(tid)
  {

  /* Obtain and print thread id */
  tid = omp_get_thread_num();
  printf("Hello World from thread = %d\n", tid);

  /* Only master thread does this */
  if (tid == 0)
    {
    nthreads = omp_get_num_threads();
    printf("Number of threads = %d\n", nthreads);
    }

  }  /* All threads join master thread and terminate */

}