34 long long g1[2], g2[2];
36 int done = 0, n,
myid, numprocs;
37 double PI25DT = 3.141592653589793238462643;
38 double mypi,
pi, h, sum,
x;
39 double startwtime = 0.0, endwtime;
41 char processor_name[MPI_MAX_PROCESSOR_NAME];
97 MPI_Init( &argc, &argv );
99 MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
100 MPI_Comm_rank( MPI_COMM_WORLD, &
myid );
101 MPI_Get_processor_name( processor_name, &namelen );
103 fprintf( stdout,
"Process %d of %d on %s\n",
104 myid, numprocs, processor_name );
121 startwtime = MPI_Wtime( );
123 MPI_Bcast( &n, 1, MPI_INT, 0, MPI_COMM_WORLD );
127 h = 1.0 / ( double ) n;
130 for (
i =
myid + 1;
i <= n;
i += numprocs ) {
131 x = h * ( ( double )
i - 0.5 );
136 MPI_Reduce( &mypi, &
pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD );
139 printf(
"pi is approximately %.16f, Error is %.16f\n",
140 pi, fabs(
pi - PI25DT ) );
141 endwtime = MPI_Wtime( );
142 printf(
"wall clock time = %f\n", endwtime - startwtime );
157 printf(
"ETH0_RX_BYTES: %lld ETH0_TX_BYTES: %lld\n", g2[0], g2[1] );
159 printf(
"PAPI_TOT_CYC : %lld\n", g1[0] );
160 }
else if ( ins == 1 ) {
161 printf(
"PAPI_FP_INS : %lld PAPI_TOT_CYC : %lld\n", g1[0], g1[1] );
162 }
else if ( ins == 2 ) {
163 printf(
"PAPI_FP_OPS : %lld PAPI_TOT_CYC : %lld\n", g1[0], g1[1] );
int PAPI_stop(int EventSet, long long *values)
void test_pass(const char *filename)
int PAPI_add_event(int EventSet, int EventCode)
int PAPI_event_name_to_code(const char *in, int *out)
int PAPI_library_init(int version)
int PAPI_create_eventset(int *EventSet)
int PAPI_query_event(int EventCode)
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
int PAPI_start(int EventSet)