/usr/include/rheolef/dis_time.h is in librheolef-dev 6.7-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | #ifndef _RHEO_DIS_TIME_H
#define _RHEO_DIS_TIME_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
#include "rheolef/distributed.h"
#include "rheolef/the_clock.h"
namespace rheolef {
/*D:dis_time
NAME: @code{dis_time}, @code{seq_time} -- Time in seconds since an arbitrary time in the past.
SYNOPSIS:
@noindent
@example
double dis_time();
double seq_time();
@end example
EXAMPLE:
@noindent
@example
double t_start = dis_time();
//.... stuff to be timed ...
double t_end = dis_time();
derr << "That took " << t_end - t_start << " seconds" << endl
@end example
DESCRIPTION:
@noindent
@code{dis_time} returns a floating-point number of seconds,
representing elapsed wall-clock time since some time in the past.
The @emph{time in the past} is guaranteed not to change during the life of the process.
The user is responsible for converting large numbers of seconds to other units if they are preferred.
This function is portable (it returns seconds, not @emph{ticks}), it allows high resolution,
and carries no unnecessary baggage.
In a distributed environment,
@code{dis_time} clocks are synchronized: different nodes return the same time
value at the same instant.
@code{seq_time} is similar but the time returned is local to the node that called them
and clocks are not synchronized: in a distributed environment,
different nodes can return diferent local times,
at different instant when the call to @code{seq_time} is reached.
AUTHOR:
Pierre Saramito
Pierre.Saramito@imag.fr
LJK-IMAG, 38041 Grenoble cedex 9, France
DATE:
5 november 2013
METHODS: @puzawa
End:
*/
inline double seq_time() { return the_clock(); }
# ifndef _RHEOLEF_HAVE_MPI
inline double dis_time() { return the_clock(); }
# else // _RHEOLEF_HAVE_MPI
inline double dis_time() {
if (! (mpi::environment::initialized() && !mpi::environment::finalized())) {
return the_clock();
}
double t = 0;
communicator comm;
comm.barrier();
typedef std::size_t size_type;
size_type io_proc = idiststream::io_proc();
size_type my_proc = comm.rank();
if (my_proc == io_proc) {
t = the_clock();
}
mpi::broadcast (comm, t, io_proc);
return t;
}
# endif // _RHEOLEF_HAVE_MPI
} // namespace rheolef
#endif // _RHEO_DIS_TIME_H
|