// // Hello World // #include #include // #define NUM_THREADS 4 int main() { int nthreads=4, tid=10; // Fork a team of threads #pragma omp parallel private(tid,nthreads) // private(nthreads,tid) { tid=omp_get_thread_num(); // Obtain thread id printf("Hello world from OpenMP thread %d\n", tid); if (tid==0) // Only master thread does this { nthreads=omp_get_num_threads(); // Obtain the number of threads printf("Number of threads: %d\n", nthreads); } } printf("\noutside:\n"); printf("nthreads=%d, tid=%d\n", nthreads,tid); return 0; }