Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CodeVault
hpc-kernels
structured_grids
Commits
bc7e5a32
Commit
bc7e5a32
authored
Oct 11, 2016
by
Thomas Ponweiser
Browse files
refined statistics calculation
parent
fa468098
Changes
1
Hide whitespace changes
Inline
Side-by-side
cellular_automaton/wireworld_c/main.c
View file @
bc7e5a32
...
...
@@ -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
(
"
\n
Statistics:
\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
(
"
\n
Statistics:
\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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment