IODebugTrack.hpp 2.01 KB
Newer Older
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
#ifndef moab_IO_DEBUG_TRACK_HPP
#define moab_IO_DEBUG_TRACK_HPP

#include <list>
#include <iosfwd>
#include <string>

namespace moab {

/**\brief Tool for debugging binary IO
 *
 * Track which ranges of a table of data have been read/written,
 * watching for overlapping IO requests and ranges of unaccessed
 * data.
 *
 * Notes:  This class assumes MPI_COMM_WORLD is the communicator
 *         for parallel.
 */
class IODebugTrack {
  private:
    struct DRange {
      unsigned long begin;
      unsigned long end;
      unsigned long rank;
    };
  
    bool enableOutput;
    std::string tableName;
    std::list<DRange> dataSet;
    std::ostream& ostr;
    unsigned long maxSize;
    int mpiRank;
33
    bool haveMPI;
34
35
36
37
38
39
40
41
42
43
44
    
    void record_io( DRange data );

  public:
  
      /**\brief Constuctor requires stream to which to log errors 
       *\param table_name    Used to tag output
       *\param output_stream Stream to which to print error messages
       *\param table_size Max table size.  No limit if unspecified 
       */
    IODebugTrack( bool enable,
45
                  const std::string& table_name,
46
                  std::ostream& output_stream,
47
48
49
50
51
52
53
                  unsigned long table_size = 0 ) ;
  
      /**\brief Constuctor requires stream to which to log errors 
       *\param table_name    Used to tag output
       *\param table_size Max table size.  No limit if unspecified 
       */
    IODebugTrack( bool enable,
54
                  const std::string& table_name,
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
                  unsigned long table_size = 0 ) ;
    
      /**\brief Destructor prints errors about unaccessed ranges */
    ~IODebugTrack();
    
      /**\brief Notify of IO request
       *\param begin  First table row being read/written
       *\param count  Num consecutive table rows being read/written
       */
    void record_io( unsigned long begin, unsigned long count );
    
      /**\brief Push all data to root process
       *
       * Does nothing if MPI support is not enabled
       */
    void all_reduce();
};


} // namespace moab

#endif