Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
IODebugTrack.hpp
Go to the documentation of this file.
1 #ifndef moab_IO_DEBUG_TRACK_HPP
2 #define moab_IO_DEBUG_TRACK_HPP
3 
4 #include <list>
5 #include <iosfwd>
6 #include <string>
7 
8 namespace moab
9 {
10 
11 /**\brief Tool for debugging binary IO
12  *
13  * Track which ranges of a table of data have been read/written,
14  * watching for overlapping IO requests and ranges of unaccessed
15  * data.
16  *
17  * Notes: This class assumes MPI_COMM_WORLD is the communicator
18  * for parallel.
19  */
21 {
22  private:
23  struct DRange
24  {
25  unsigned long begin;
26  unsigned long end;
27  unsigned long rank;
28  };
29 
31  std::string tableName;
32  std::list< DRange > dataSet;
33  std::ostream& ostr;
34  unsigned long maxSize;
35  int mpiRank;
36  bool haveMPI;
37 
38  void record_io( DRange data );
39 
40  public:
41  /**\brief Constuctor requires stream to which to log errors
42  *\param table_name Used to tag output
43  *\param output_stream Stream to which to print error messages
44  *\param table_size Max table size. No limit if unspecified
45  */
46  IODebugTrack( bool enable,
47  const std::string& table_name,
48  std::ostream& output_stream,
49  unsigned long table_size = 0 );
50 
51  /**\brief Constuctor requires stream to which to log errors
52  *\param table_name Used to tag output
53  *\param table_size Max table size. No limit if unspecified
54  */
55  IODebugTrack( bool enable, const std::string& table_name, unsigned long table_size = 0 );
56 
57  /**\brief Destructor prints errors about unaccessed ranges */
58  ~IODebugTrack();
59 
60  /**\brief Notify of IO request
61  *\param begin First table row being read/written
62  *\param count Num consecutive table rows being read/written
63  */
64  void record_io( unsigned long begin, unsigned long count );
65 
66  /**\brief Push all data to root process
67  *
68  * Does nothing if MPI support is not enabled
69  */
70  void all_reduce();
71 };
72 
73 } // namespace moab
74 
75 #endif