MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 #ifndef moab_IO_DEBUG_TRACK_HPP 00002 #define moab_IO_DEBUG_TRACK_HPP 00003 00004 #include <list> 00005 #include <iosfwd> 00006 #include <string> 00007 00008 namespace moab 00009 { 00010 00011 /**\brief Tool for debugging binary IO 00012 * 00013 * Track which ranges of a table of data have been read/written, 00014 * watching for overlapping IO requests and ranges of unaccessed 00015 * data. 00016 * 00017 * Notes: This class assumes MPI_COMM_WORLD is the communicator 00018 * for parallel. 00019 */ 00020 class IODebugTrack 00021 { 00022 private: 00023 struct DRange 00024 { 00025 unsigned long begin; 00026 unsigned long end; 00027 unsigned long rank; 00028 }; 00029 00030 bool enableOutput; 00031 std::string tableName; 00032 std::list< DRange > dataSet; 00033 std::ostream& ostr; 00034 unsigned long maxSize; 00035 int mpiRank; 00036 bool haveMPI; 00037 00038 void record_io( DRange data ); 00039 00040 public: 00041 /**\brief Constuctor requires stream to which to log errors 00042 *\param table_name Used to tag output 00043 *\param output_stream Stream to which to print error messages 00044 *\param table_size Max table size. No limit if unspecified 00045 */ 00046 IODebugTrack( bool enable, 00047 const std::string& table_name, 00048 std::ostream& output_stream, 00049 unsigned long table_size = 0 ); 00050 00051 /**\brief Constuctor requires stream to which to log errors 00052 *\param table_name Used to tag output 00053 *\param table_size Max table size. No limit if unspecified 00054 */ 00055 IODebugTrack( bool enable, const std::string& table_name, unsigned long table_size = 0 ); 00056 00057 /**\brief Destructor prints errors about unaccessed ranges */ 00058 ~IODebugTrack(); 00059 00060 /**\brief Notify of IO request 00061 *\param begin First table row being read/written 00062 *\param count Num consecutive table rows being read/written 00063 */ 00064 void record_io( unsigned long begin, unsigned long count ); 00065 00066 /**\brief Push all data to root process 00067 * 00068 * Does nothing if MPI support is not enabled 00069 */ 00070 void all_reduce(); 00071 }; 00072 00073 } // namespace moab 00074 00075 #endif