annotate DEPENDENCIES/generic/include/boost/mpi/timer.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>
Chris@16 2
Chris@16 3 // Use, modification and distribution is subject to the Boost Software
Chris@16 4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 /** @file timer.hpp
Chris@16 8 *
Chris@16 9 * This header provides the @c timer class, which provides access to
Chris@16 10 * the MPI timers.
Chris@16 11 */
Chris@16 12 #ifndef BOOST_MPI_TIMER_HPP
Chris@16 13 #define BOOST_MPI_TIMER_HPP
Chris@16 14
Chris@16 15 #include <boost/mpi/config.hpp>
Chris@16 16 #include <boost/limits.hpp>
Chris@16 17
Chris@16 18 namespace boost { namespace mpi {
Chris@16 19
Chris@16 20 /** @brief A simple timer that provides access to the MPI timing
Chris@16 21 * facilities.
Chris@16 22 *
Chris@16 23 * The @c timer class is a simple wrapper around the MPI timing
Chris@16 24 * facilities that mimics the interface of the Boost Timer library.
Chris@16 25 */
Chris@16 26 class BOOST_MPI_DECL timer {
Chris@16 27 public:
Chris@16 28 /** Initializes the timer
Chris@16 29 *
Chris@16 30 * @post @c elapsed() == 0
Chris@16 31 */
Chris@16 32 timer();
Chris@16 33
Chris@16 34 /** Restart the timer.
Chris@16 35 *
Chris@16 36 * @post @c elapsed() == 0
Chris@16 37 */
Chris@16 38 void restart();
Chris@16 39
Chris@16 40 /** Return the amount of time that has elapsed since the last
Chris@16 41 * construction or reset, in seconds.
Chris@16 42 */
Chris@16 43 double elapsed() const;
Chris@16 44
Chris@16 45 /** Return an estimate of the maximum possible value of
Chris@16 46 * elapsed(). Note that this routine may return too high a value on
Chris@16 47 * some systems.
Chris@16 48 */
Chris@16 49 double elapsed_max() const;
Chris@16 50
Chris@16 51 /** Returns the minimum non-zero value that @c elapsed() may
Chris@16 52 * return. This is the resolution of the timer.
Chris@16 53 */
Chris@16 54 double elapsed_min() const;
Chris@16 55
Chris@16 56 /** Determines whether the elapsed time values are global times or
Chris@16 57 local processor times. */
Chris@16 58 static bool time_is_global();
Chris@16 59
Chris@16 60 private:
Chris@16 61 double start_time;
Chris@16 62 }; // timer
Chris@16 63
Chris@16 64 inline timer::timer()
Chris@16 65 {
Chris@16 66 restart();
Chris@16 67 }
Chris@16 68
Chris@16 69 inline void timer::restart()
Chris@16 70 {
Chris@16 71 start_time = MPI_Wtime();
Chris@16 72 }
Chris@16 73
Chris@16 74 inline double timer::elapsed() const
Chris@16 75 {
Chris@16 76 return MPI_Wtime() - start_time;
Chris@16 77 }
Chris@16 78
Chris@16 79 inline double timer::elapsed_max() const
Chris@16 80 {
Chris@16 81 return (std::numeric_limits<double>::max)();
Chris@16 82 }
Chris@16 83
Chris@16 84 inline double timer::elapsed_min() const
Chris@16 85 {
Chris@16 86 return MPI_Wtick();
Chris@16 87 }
Chris@16 88
Chris@16 89 } } // end namespace boost::mpi
Chris@16 90
Chris@16 91 #endif // BOOST_MPI_TIMER_HPP