int main ( void )

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

    MAIN is the main program for PRIME_SERIAL_PRB.

  Discussion:

    PRIME_SERIAL_PRB tests the PRIME_SERIAL library.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    06 August 2009

  Author:

    John Burkardt
*/
{
  int n_factor;
  int n_hi;
  int n_lo;

  timestamp ( );
  printf ( "\n" );
  printf ( "PRIME_SERIAL_PRB\n" );
  printf ( "  C version\n" );
  printf ( "  Test the PRIME_SERIAL library.\n" );

  n_lo = 1;
  n_hi = 131072;
  n_factor = 2;

  prime_number_sweep ( n_lo, n_hi, n_factor );

  n_lo = 5;
  n_hi = 500000;
  n_factor = 10;

  prime_number_sweep ( n_lo, n_hi, n_factor );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "PRIME_SERIAL_PRB\n" );
  printf ( "  Normal end of execution.\n" );
  printf ( "\n" );
  timestamp ( );

  return 0;
}
/******************************************************************************
 *   This program calls a version of PRIME_NUMBER that includes
 *   cilk plus directives for parallel processing.
 */
int main ( int argc, char *argv[] )
{
  int n_factor;
  int n_hi;
  int n_lo;

  printf ( "\n\nPRIME_cilklus\n" );
  printf ( "  C/Cilk Plus version\n" );

	if(argc != 3) {
		fprintf(stderr, "Usage: ./executablename <int> num available processors "
						"<int> num threads to run\n\n");
		exit(13);
	}
	
	printf ( "\n" );
	printf ( "  Number of processors available = %i\n", atoi(argv[1]) );
	printf ( "  Number of threads =              %i\n", atoi(argv[2]) );;

	//Set the number of cilk threads to use for this program
	if (0!= __cilkrts_set_param("nworkers", argv[2]))
	{
		printf("Failed to set worker count\n");
		return 1;
	}

  n_lo = 1;
  n_hi = 131072;
  n_factor = 2;
  prime_number_sweep ( n_lo, n_hi, n_factor );

  n_lo = 5;
  n_hi = 500000;
  n_factor = 10;
  prime_number_sweep ( n_lo, n_hi, n_factor );

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

  return 0;
}
Example #3
0
int main ( int argc, char *argv[] )

/******************************************************************************/

{
  int n_factor;
  int n_hi;
  int n_lo;

  printf ( "\n" );
  printf ( "PRIME_OPENMP\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 ( ) );

  n_lo = 1;
  n_hi = 1310720;
  n_factor = 2;

  prime_number_sweep ( n_lo, n_hi, n_factor );

  n_lo = 5;
  n_hi = 500000;
  n_factor = 100;

  prime_number_sweep ( n_lo, n_hi, n_factor );
/*
  Terminate.
*/
  printf ( "\n" );
  printf ( "PRIME_OPENMP\n" );
  printf ( "  Normal end of execution.\n" );

  return 0;
}