MOAB: Mesh Oriented datABase
(version 5.2.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, const std::string& table_name, std::ostream& output_stream, 00047 unsigned long table_size = 0 ); 00048 00049 /**\brief Constuctor requires stream to which to log errors 00050 *\param table_name Used to tag output 00051 *\param table_size Max table size. No limit if unspecified 00052 */ 00053 IODebugTrack( bool enable, const std::string& table_name, unsigned long table_size = 0 ); 00054 00055 /**\brief Destructor prints errors about unaccessed ranges */ 00056 ~IODebugTrack(); 00057 00058 /**\brief Notify of IO request 00059 *\param begin First table row being read/written 00060 *\param count Num consecutive table rows being read/written 00061 */ 00062 void record_io( unsigned long begin, unsigned long count ); 00063 00064 /**\brief Push all data to root process 00065 * 00066 * Does nothing if MPI support is not enabled 00067 */ 00068 void all_reduce(); 00069 }; 00070 00071 } // namespace moab 00072 00073 #endif