Commit bc7e5a32 authored by Thomas Ponweiser's avatar Thomas Ponweiser
Browse files

refined statistics calculation

parent fa468098
......@@ -16,6 +16,8 @@ void read_input(const conf_t *c, world_t *world);
void iterate(const conf_t *c, world_t *world);
void print_avg_timings(const conf_t *c, double total_time, double sim_time, double io_time);
int main(int argc, char* argv[])
{
conf_t config;
......@@ -140,12 +142,41 @@ void iterate(const conf_t *c, world_t *world)
}
total_time += MPI_Wtime();
if(info_enabled(c)) printf(
"\nStatistics:\n"
" * Generations per second: %.0f\n"
" * Net simulation time (s): %f\n"
" * Net I/O time (s): %f\n"
" * Total time (s): %f\n\n",
g / sim_time, sim_time, io_time, total_time
print_avg_timings(c, total_time, sim_time, io_time);
}
void print_avg_timings(const conf_t *c, double total_time, double sim_time, double io_time)
{
const int root = 0;
const size_t total_generations = c->n_iterations * c->n_generations_per_iteration;
int rank, nprocs;
double times[] = {total_time, sim_time, io_time};
void *sendbuf, *recvbuf;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
sendbuf = rank == root ? MPI_IN_PLACE : times;
recvbuf = rank == root ? times : NULL;
MPI_Reduce(
sendbuf, recvbuf, 3, MPI_DOUBLE,
MPI_SUM, root, MPI_COMM_WORLD
);
if(info_enabled(c)) {
total_time = times[0] / nprocs;
sim_time = times[1] / nprocs;
io_time = times[2] / nprocs;
printf(
"\nStatistics:\n"
" * Generations per second: %.0f\n"
" * Net simulation time (s): %f\n"
" * Net I/O time (s): %f\n"
" * Total time (s): %f\n\n",
total_generations / sim_time, sim_time, io_time, total_time
);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment