Exemplo n.º 1
0
int main ( int argc, char *argv[] )

/******************************************************************************/
/*
  Purpose:

    MAIN is the main program for COMPUTE_PI.

  Discussion:

    COMPUTE_PI estimates the value of PI.

    This program uses Open MP parallelization directives.  

    It should run properly whether parallelization is used or not.

    However, the parallel version computes the sum in a different
    order than the serial version; some of the quantities added are
    quite small, and so this will affect the accuracy of the results.

    The single precision code is noticeably less accurate than the
    double code.  Again, the amount of difference depends
    on whether the computation is done in parallel or not.

  Licensing:

    This code is distributed under the GNU LGPL license. 

  Modified:

    18 April 2009

  Author:

    John Burkardt
*/
{
  int r8_logn_max = 10;

  printf ( "\n" );
  printf ( "COMPUTE_PI\n" );
  printf ( "  C/OpenMP version\n" );
  printf ( "\n" );
  printf ( "  Estimate the value of PI by summing a series.\n" );

  printf ( "\n" );
  printf ( "  Number of processors available = %d\n", omp_get_num_procs ( ) );
  printf ( "  Number of threads =              %d\n", omp_get_max_threads ( ) );

  r8_test ( r8_logn_max );

  printf ( "\n" );
  printf ( "COMPUTE_PI\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}
Exemplo n.º 2
0
int main ( int argc, char *argv[] ) {
  int r8_logn_max = 10;
 
  printf ( "\n" );
  printf ( "COMPUTE_PI\n" );
  printf ( "  C/OpenMP version\n" );
  printf ( "\n" );
  printf ( "  Estimate the value of PI by summing a series.\n" );
 
  printf ( "\n" );
  printf ( "  Number of processors available = %d\n", omp_get_num_procs ( ) );
  printf ( "  Number of threads =              %d\n", omp_get_max_threads ( ) );
 
  r8_test ( r8_logn_max );
 
  printf ( "\n" );
  printf ( "COMPUTE_PI\n" );
  printf ( "  Normal end of execution.\n" );
 
  return 0;
}