# include # include # include int main ( int argc, char *argv[] ); /******************************************************************************/ int main ( int argc, char *argv[] ) /******************************************************************************/ /* Purpose: HELLO has each thread print out its ID. Discussion: HELLO is a "Hello, World" program for OpenMP. Licensing: This code is distributed under the GNU LGPL license. Modified: 18 April 2009 Author: John Burkardt */ { int id; double wtime; printf ( "\n" ); printf ( "HELLO\n" ); printf ( " C/OpenMP version\n" ); printf ( "\n" ); printf ( " Number of processors available = %d\n", omp_get_num_procs ( ) ); printf ( " Number of threads = %d\n", omp_get_max_threads ( ) ); wtime = omp_get_wtime ( ); # pragma omp parallel \ private ( id ) { id = omp_get_thread_num ( ); printf (" This is process %d\n", id ); } /* Finish up by measuring the elapsed time. */ wtime = omp_get_wtime ( ) - wtime; printf ( "\n" ); printf ( "HELLO\n" ); printf ( " Normal end of execution.\n" ); printf ( "\n" ); printf ( " Elapsed wall clock time = %f\n", wtime ); return 0; }