[MOAB-dev] r1258 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Mon Aug 27 16:06:13 CDT 2007


Author: kraftche
Date: 2007-08-27 16:06:13 -0500 (Mon, 27 Aug 2007)
New Revision: 1258

Modified:
   MOAB/trunk/MBParallelComm.cpp
   MOAB/trunk/MBParallelComm.hpp
Log:
Add MBParallelComm::broadcast_entities

Modified: MOAB/trunk/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/MBParallelComm.cpp	2007-08-27 16:01:06 UTC (rev 1257)
+++ MOAB/trunk/MBParallelComm.cpp	2007-08-27 21:06:13 UTC (rev 1258)
@@ -206,6 +206,59 @@
 #endif
 }
 
+MBErrorCode MBParallelComm::broadcast_entities( const int from_proc,
+                                                MBRange &entities,
+                                                const bool adjacencies,
+                                                const bool tags) 
+{
+#ifndef USE_MPI
+  return MB_FAILURE;
+#else
+  
+  MBErrorCode result = MB_SUCCESS;
+  int success;
+  MBRange whole_range;
+  int buff_size;
+  
+  allRanges.clear();
+  vertsPerEntity.clear();
+  setRange.clear();
+  setRanges.clear();
+  allTags.clear();
+  setSizes.clear();
+  optionsVec.clear();
+  setPcs.clear();
+
+  if ((int)procInfo.rank() == from_proc) {
+    result = pack_buffer( entities, adjacencies, tags, true, whole_range, buff_size ); RR;
+  }
+
+  success = MPI_Bcast( &buff_size, 1, MPI_INT, from_proc, MPI_COMM_WORLD );
+  if (MPI_SUCCESS != success)
+    return MB_FAILURE;
+  
+  if (!buff_size) // no data
+    return MB_SUCCESS;
+  
+  myBuffer.reserve( buff_size );
+  
+  if ((int)procInfo.rank() == from_proc) {
+    int actual_buffer_size;
+    result = pack_buffer( entities, adjacencies, tags, false, whole_range, actual_buffer_size ); RR;
+  }
+
+  success = MPI_Bcast( &myBuffer[0], buff_size, MPI_UNSIGNED_CHAR, from_proc, MPI_COMM_WORLD );
+  if (MPI_SUCCESS != success)
+    return MB_FAILURE;
+  
+  if ((int)procInfo.rank() != from_proc) {
+    result = unpack_buffer( entities ); RR;
+  }
+
+  return MB_SUCCESS;
+#endif
+}
+
 MBErrorCode MBParallelComm::pack_buffer(MBRange &entities, 
                                         const bool adjacencies,
                                         const bool tags,

Modified: MOAB/trunk/MBParallelComm.hpp
===================================================================
--- MOAB/trunk/MBParallelComm.hpp	2007-08-27 16:01:06 UTC (rev 1257)
+++ MOAB/trunk/MBParallelComm.hpp	2007-08-27 21:06:13 UTC (rev 1258)
@@ -57,6 +57,11 @@
                                    const bool adjacencies = false,
                                    const bool tags = true);
   
+  MBErrorCode broadcast_entities( const int from_proc,
+                                  MBRange& entities,
+                                  const bool adjacencies = false,
+                                  const bool tags = true );
+  
     //! pack a buffer (stored in this class instance) with ALL data for these entities
   MBErrorCode pack_buffer(MBRange &entities, 
                           const bool adjacencies,




More information about the moab-dev mailing list