[MOAB-dev] r1994 - in MOAB/trunk: . parallel

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Tue Jul 8 11:27:58 CDT 2008


Author: kraftche
Date: 2008-07-08 11:27:58 -0500 (Tue, 08 Jul 2008)
New Revision: 1994

Modified:
   MOAB/trunk/WriteHDF5.cpp
   MOAB/trunk/WriteHDF5.hpp
   MOAB/trunk/parallel/WriteHDF5Parallel.cpp
   MOAB/trunk/parallel/WriteHDF5Parallel.hpp
Log:
Get rid of MPI calls w/out MPI_Init in debug output of WriteHDF5Parallel.  The
assumption that calling functions that are overriden by WriteHDF5Parallel 
during a serial write would be no-ops because there was noting to communicate
was mostly correct, except that debug output functions call MPI_Comm_rank.
Clean up this code such that handling of the serial vs. parallel condition
is handled in WriteHDF5 rather than WriteHDF5Parallel, and no function in
WriteHDF5Parallel is ever called during a serial write.



Modified: MOAB/trunk/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/WriteHDF5.cpp	2008-07-08 15:42:04 UTC (rev 1993)
+++ MOAB/trunk/WriteHDF5.cpp	2008-07-08 16:27:58 UTC (rev 1994)
@@ -386,7 +386,6 @@
   std::list<SparseTag>::const_iterator t_itor;
   std::list<ExportSet>::iterator ex_itor;
   MBEntityHandle elem_count, max_id;
-  bool parallel = false;
   
   if (MB_SUCCESS != init())
     return MB_FAILURE;
@@ -438,11 +437,15 @@
   
     // Create the file layout, including all tables (zero-ed) and
     // all structure and meta information.
-  parallel = (MB_SUCCESS == opts.match_option( "PARALLEL", "FORMAT" ));
-  int pcomm_no = 0;
-  opts.get_int_option("PARALLEL_COMM", pcomm_no);
-  result = create_file( filename, overwrite, qa_records, user_dimension, 
-                        parallel, pcomm_no );
+  parallelWrite = (MB_SUCCESS == opts.match_option( "PARALLEL", "FORMAT" ));
+  if (parallelWrite) {
+    int pcomm_no = 0;
+    opts.get_int_option("PARALLEL_COMM", pcomm_no);
+    result = parallel_create_file( filename, overwrite, qa_records, user_dimension, pcomm_no );
+  }
+  else {
+    result = serial_create_file( filename, overwrite, qa_records, user_dimension );
+  }
   if (MB_SUCCESS != result)
     return result;
 
@@ -909,16 +912,17 @@
     set_offset += count;
   }
   
-  rval = write_shared_set_descriptions( set_table );
-  CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+  if (parallelWrite) {
+    rval = write_shared_set_descriptions( set_table );
+    CHK_MB_ERR_2C(rval, set_table, writeSetContents, content_table, status);
+  }
   mhdf_closeData( filePtr, set_table, &status );
   
+  if (writeSetContents && parallelWrite) 
+    rval = write_shared_set_contents( content_table );
   if (writeSetContents)
-  {
-    rval = write_shared_set_contents( content_table );
     mhdf_closeData( filePtr, content_table, &status );
-    CHK_MB_ERR_0( rval );
-  }
+  CHK_MB_ERR_0( rval );
   
     /* Write set children */
   if (writeSetChildren)
@@ -952,7 +956,8 @@
       child_offset += id_list.size();
     }
 
-    rval = write_shared_set_children( child_table );
+    if (parallelWrite)
+      rval = write_shared_set_children( child_table );
     mhdf_closeData( filePtr, child_table, &status );
     CHK_MB_ERR_0(rval);
   }
@@ -989,7 +994,8 @@
       parent_offset += id_list.size();
     }
 
-    rval = write_shared_set_parents( parent_table );
+    if (parallelWrite)
+      rval = write_shared_set_parents( parent_table );
     mhdf_closeData( filePtr, parent_table, &status );
     CHK_MB_ERR_0(rval);
   }
@@ -1991,12 +1997,23 @@
   return MB_SUCCESS;
 }
 
-MBErrorCode WriteHDF5::create_file( const char* filename,
+  // If we support paralle, then this function will have been
+  // overridden with an alternate version in WriteHDF5Parallel
+  // that supports parallel I/O.  If we're here 
+  // then MOAB was not built with support for parallel HDF5 I/O.
+MBErrorCode WriteHDF5::parallel_create_file( const char* ,
+                                    bool ,
+                                    std::vector<std::string>& ,
+                                    int ,
+                                    int  )
+{
+  return MB_NOT_IMPLEMENTED;
+}
+
+MBErrorCode WriteHDF5::serial_create_file( const char* filename,
                                     bool overwrite,
                                     std::vector<std::string>& qa_records,
-                                    int dimension,
-                                    bool parallel,
-                                    int pcomm_no)
+                                    int dimension )
 {
   long first_id;
   mhdf_Status status;
@@ -2004,13 +2021,6 @@
   std::list<ExportSet>::iterator ex_itor;
   MBErrorCode rval;
   
-  // If we support paralle, then this function will have been
-  // overridden with an alternate version in WriteHDF5Parallel
-  // that supports parallel I/O.  If we're here and parallel == true,
-  // then MOAB was not built with support for parallel HDF5 I/O.
-  if (parallel || pcomm_no)
-    return MB_NOT_IMPLEMENTED;
-  
   const char* type_names[MBMAXTYPE];
   memset( type_names, 0, MBMAXTYPE * sizeof(char*) );
   for (MBEntityType i = MBEDGE; i < MBENTITYSET; ++i)

Modified: MOAB/trunk/WriteHDF5.hpp
===================================================================
--- MOAB/trunk/WriteHDF5.hpp	2008-07-08 15:42:04 UTC (rev 1993)
+++ MOAB/trunk/WriteHDF5.hpp	2008-07-08 16:27:58 UTC (rev 1994)
@@ -75,15 +75,19 @@
 
 protected:
   
+  MBErrorCode serial_create_file( const char* filename,
+                                  bool overwrite,
+                                  std::vector<std::string>& qa_records,
+                                  int dimension = 3 );
+
   /** Function to create the file.  Virtual to allow override
    *  for parallel version.
    */
-  virtual MBErrorCode create_file( const char* filename,
-                                   bool overwrite,
-                                   std::vector<std::string>& qa_records,
-                                   int dimension = 3,
-                                   bool parallel = false,
-                                   int pcomm_no = 0);
+  virtual MBErrorCode parallel_create_file( const char* filename,
+                                            bool overwrite,
+                                            std::vector<std::string>& qa_records,
+                                            int dimension = 3,
+                                            int pcomm_no = 0 );
 
 
   /** Functions that the parallel version overrides*/
@@ -236,6 +240,9 @@
   //! The list of tags to export
   std::list<SparseTag> tagList;
 
+  //! True if doing parallel write
+  bool parallelWrite;
+
 private:
 
   //! Do the actual work of write_file.  Separated from write_file

Modified: MOAB/trunk/parallel/WriteHDF5Parallel.cpp
===================================================================
--- MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2008-07-08 15:42:04 UTC (rev 1993)
+++ MOAB/trunk/parallel/WriteHDF5Parallel.cpp	2008-07-08 16:27:58 UTC (rev 1994)
@@ -351,16 +351,12 @@
   return MB_SUCCESS;
 }
 
-MBErrorCode WriteHDF5Parallel::create_file( const char* filename,
+MBErrorCode WriteHDF5Parallel::parallel_create_file( const char* filename,
                                             bool overwrite,
                                             std::vector<std::string>& qa_records,
                                             int dimension,
-                                            bool parallel,
                                             int pcomm_no)
 {
-  if (!parallel)
-    return WriteHDF5::create_file(filename, overwrite, qa_records, dimension, false );
-
   MBErrorCode rval;
   int result;
   mhdf_Status status;

Modified: MOAB/trunk/parallel/WriteHDF5Parallel.hpp
===================================================================
--- MOAB/trunk/parallel/WriteHDF5Parallel.hpp	2008-07-08 15:42:04 UTC (rev 1993)
+++ MOAB/trunk/parallel/WriteHDF5Parallel.hpp	2008-07-08 16:27:58 UTC (rev 1994)
@@ -99,11 +99,10 @@
   
       //! Called by normal (non-parallel) writer.  Sets up
       //! necessary data for parallel write.
-    virtual MBErrorCode create_file( const char* filename,
+    virtual MBErrorCode parallel_create_file( const char* filename,
                                      bool overwrite,
                                      std::vector<std::string>& qa_records,
                                      int dimension = 3,
-                                     bool parallel = false,
                                      int pcomm_no = 0);
     
       //! Figure out which mesh local mesh is duplicated on




More information about the moab-dev mailing list