HavoqGT
log_step.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Lawrence Livermore National Security, LLC.
3  * Produced at the Lawrence Livermore National Laboratory.
4  * Re-written by Steven Feldman <feldman12@llnl.gov>.
5  * LLNL-CODE-644630.
6  * All rights reserved.
7  *
8  * This file is part of HavoqGT, Version 0.1.
9  * For details, see https://computation.llnl.gov/casc/dcca-pub/dcca/Downloads.html
10  *
11  * Please also read this link – Our Notice and GNU Lesser General Public License.
12  * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
13  *
14  * This program is free software; you can redistribute it and/or modify it under
15  * the terms of the GNU Lesser General Public License (as published by the Free
16  * Software Foundation) version 2.1 dated February 1999.
17  *
18  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A
20  * PARTICULAR PURPOSE. See the terms and conditions of the GNU General Public
21  * License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License along
24  * with this program; if not, write to the Free Software Foundation, Inc.,
25  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26  *
27  * OUR NOTICE AND TERMS AND CONDITIONS OF THE GNU GENERAL PUBLIC LICENSE
28  *
29  * Our Preamble Notice
30  *
31  * A. This notice is required to be provided under our contract with the
32  * U.S. Department of Energy (DOE). This work was produced at the Lawrence
33  * Livermore National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
34  *
35  * B. Neither the United States Government nor Lawrence Livermore National
36  * Security, LLC nor any of their employees, makes any warranty, express or
37  * implied, or assumes any liability or responsibility for the accuracy,
38  * completeness, or usefulness of any information, apparatus, product, or process
39  * disclosed, or represents that its use would not infringe privately-owned rights.
40  *
41  * C. Also, reference herein to any specific commercial products, process, or
42  * services by trade name, trademark, manufacturer or otherwise does not
43  * necessarily constitute or imply its endorsement, recommendation, or favoring by
44  * the United States Government or Lawrence Livermore National Security, LLC. The
45  * views and opinions of authors expressed herein do not necessarily state or
46  * reflect those of the United States Government or Lawrence Livermore National
47  * Security, LLC, and shall not be used for advertising or product endorsement
48  * purposes.
49  *
50  */
51 #ifndef __HAVOQGT_IMP_LOG_STEP_HPP__
52 #define __HAVOQGT_IMP_LOG_STEP_HPP__
53 
54 #include <havoqgt/environment.hpp>
55 
56 namespace havoqgt {
57 namespace mpi {
58 
59 class LogStep {
60  public:
61  LogStep(const std::string &stp_str, MPI_Comm mpi_comm, int mpi_rank)
62  : stp_str_(stp_str)
63  , mpi_comm_(mpi_comm)
64  , mpi_rank_(mpi_rank) {
65  MPI_Barrier(mpi_comm_);
66  if (mpi_rank_ == 0) {
67  time_ = MPI_Wtime();
68  std::cout << "Starting: " << stp_str_ << std::endl << std::flush;
69  }
70  if (mpi_rank_ % havoqgt_env()->node_local_comm().size() == 0) {
72  std::cout << "\t[" << mpi_rank_ << "] Dirty Pages: " << get_dirty_pages()
73  << "kb." << std::endl << std::flush;
74  }
75  MPI_Barrier(mpi_comm_);
76  }
77 
79  MPI_Barrier(mpi_comm_);
80 
81  if (mpi_rank_ == 0) {
82  time_ = MPI_Wtime() - time_;
83 
84  std::cout << "Finished: " << stp_str_ << " in " << time_ << " seconds."
85  << std::endl << std::flush;
86  }
87  if (mpi_rank_ % havoqgt_env()->node_local_comm().size() == 0) {
88  int read = -1;
89  int written = -1;
90  get_io_stat_info(read, written);
91 
92  std::cout
93  << "\t[" << mpi_rank_ << "]" << std::endl
94  << "\tSpace used: " << get_disk_utilization() << "gB." << std::endl
95  << "\tDirty Pages: " << get_dirty_pages() << "kB." << std::endl
96  << "\tMB Read: " << (read - mb_read_) << std::endl
97  << "\tMB Written: " << (written - mb_written_) << std::endl
98  << std::flush;
99  }
100  MPI_Barrier(mpi_comm_);
101  }
102 
103  private:
104  double time_;
105  int mb_read_;
107 
108  std::string stp_str_;
109  MPI_Comm mpi_comm_;
111 };
112 
113 
114 } // namespace mpi
115 } // namespace havoqgt
116 
117 #endif // __HAVOQGT_IMP_LOG_STEP_HPP__
std::string stp_str_
Definition: log_step.hpp:108
void get_io_stat_info(int &r, int &w)
uint32_t get_dirty_pages()
environment * havoqgt_env()
uint32_t get_disk_utilization()
LogStep(const std::string &stp_str, MPI_Comm mpi_comm, int mpi_rank)
Definition: log_step.hpp:61