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 /**\brief Tool for debugging binary IO 11 * 12 * Track which ranges of a table of data have been read/written, 13 * watching for overlapping IO requests and ranges of unaccessed 14 * data. 15 * 16 * Notes: This class assumes MPI_COMM_WORLD is the communicator 17 * for parallel. 18 */ 19 class IODebugTrack { 20 private: 21 struct DRange { 22 unsigned long begin; 23 unsigned long end; 24 unsigned long rank; 25 }; 26 27 bool enableOutput; 28 std::string tableName; 29 std::list<DRange> dataSet; 30 std::ostream& ostr; 31 unsigned long maxSize; 32 int mpiRank; 33 bool haveMPI; 34 35 void record_io( DRange data ); 36 37 public: 38 39 /**\brief Constuctor requires stream to which to log errors 40 *\param table_name Used to tag output 41 *\param output_stream Stream to which to print error messages 42 *\param table_size Max table size. No limit if unspecified 43 */ 44 IODebugTrack( bool enable, 45 const std::string& table_name, 46 std::ostream& output_stream, 47 unsigned long table_size = 0 ) ; 48 49 /**\brief Constuctor requires stream to which to log errors 50 *\param table_name Used to tag output 51 *\param table_size Max table size. No limit if unspecified 52 */ 53 IODebugTrack( bool enable, 54 const std::string& table_name, 55 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 74 } // namespace moab 75 76 #endif 77