30{
32 int evtcode;
34 long long g1[2], g2[2];
35
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;
40 int namelen;
41 char processor_name[MPI_MAX_PROCESSOR_NAME];
42
44
48
51
54
59 }
63 }
64
69 }
73 }
74
77 ins = 2;
82 }
83 }
84 } else {
85 ins = 1;
89 }
90 }
91
95 }
96
97 MPI_Init( &argc, &argv );
98
99 MPI_Comm_size( MPI_COMM_WORLD, &numprocs );
100 MPI_Comm_rank( MPI_COMM_WORLD, &
myid );
101 MPI_Get_processor_name( processor_name, &namelen );
102
103 fprintf(
stdout,
"Process %d of %d on %s\n",
104 myid, numprocs, processor_name );
106
109
112
113 n = 0;
114 while ( !done ) {
116 if ( n == 0 )
117 n = 1000000;
118 else
119 n = 0;
120
121 startwtime = MPI_Wtime( );
122 }
123 MPI_Bcast( &n, 1, MPI_INT, 0, MPI_COMM_WORLD );
124 if ( n == 0 )
125 done = 1;
126 else {
127 h = 1.0 / ( double ) n;
128 sum = 0.0;
129
130 for (
i =
myid + 1;
i <= n;
i += numprocs ) {
131 x = h * ( ( double )
i - 0.5 );
133 }
134 mypi = h * sum;
135
136 MPI_Reduce( &mypi, &pi, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD );
137
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 );
144 }
145 }
146 }
147
150
153
154 MPI_Finalize( );
155
156
157 printf( "ETH0_RX_BYTES: %lld ETH0_TX_BYTES: %lld\n", g2[0], g2[1] );
158 if ( ins == 0 ) {
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] );
164 }
166 return 0;
167}
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
initialize the PAPI library.
Query if PAPI event exists.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
static pthread_t myid[NUM_THREADS]
int tests_quiet(int argc, char **argv)
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)