[MOAB-dev] r4255 - in MOAB/trunk/src/parallel: . moab

hongjun at mcs.anl.gov hongjun at mcs.anl.gov
Mon Nov 8 11:20:37 CST 2010


Author: hongjun
Date: 2010-11-08 11:20:37 -0600 (Mon, 08 Nov 2010)
New Revision: 4255

Modified:
   MOAB/trunk/src/parallel/ParallelComm.cpp
   MOAB/trunk/src/parallel/moab/ParallelComm.hpp
Log:
o scatter_entities, send_entities, recv_entities added
  - "store_remote_handles" is not supported for "send/recv entities"
o recv_messages are added
  - receviev messages from other processor in while loop
  - used in recv_entities function
  - can be used only to get "ack" messages in sending processor
o send/recv request arrays are added
o "reset_all_buffers" function is changed to public


Modified: MOAB/trunk/src/parallel/ParallelComm.cpp
===================================================================
--- MOAB/trunk/src/parallel/ParallelComm.cpp	2010-11-05 16:13:04 UTC (rev 4254)
+++ MOAB/trunk/src/parallel/ParallelComm.cpp	2010-11-08 17:20:37 UTC (rev 4255)
@@ -581,6 +581,209 @@
 #endif
 }
 
+ErrorCode ParallelComm::scatter_entities( const int from_proc,
+					  std::vector<Range> &entities,
+					  const bool adjacencies,
+					  const bool tags)
+{
+#ifndef USE_MPI
+  return MB_FAILURE;
+#else
+  ErrorCode result = MB_SUCCESS;
+  int i, success, buff_size, prev_size;
+  int nProcs = (int)procConfig.proc_size();
+  int* sendCounts = new int[nProcs];
+  int* displacements = new int[nProcs];
+  sendCounts[0] = sizeof(int);
+  displacements[0] = 0;
+  Buffer buff(INITIAL_BUFF_SIZE);
+  buff.reset_ptr(sizeof(int));
+  buff.set_stored_size();
+  unsigned int my_proc = procConfig.proc_rank();
+
+  // get buffer size array for each remote processor
+  if (my_proc == (unsigned int) from_proc) {
+    for (i = 1; i < nProcs; i++) {
+      prev_size = buff.buff_ptr - buff.mem_ptr;
+      buff.reset_ptr(prev_size + sizeof(int));
+      result = add_verts(entities[i]);
+      
+      result = pack_buffer(entities[i], adjacencies, tags, 
+			   false, -1, &buff); 
+      RRA("Failed to compute buffer size in scatter_entities.");
+
+      buff_size = buff.buff_ptr - buff.mem_ptr - prev_size;
+      *((int*)(buff.mem_ptr + prev_size)) = buff_size;
+      sendCounts[i] = buff_size;
+    }
+  }
+  
+  // broadcast buffer size array
+  success = MPI_Bcast(sendCounts, nProcs, MPI_INT, from_proc, procConfig.proc_comm());
+  if (MPI_SUCCESS != success) {
+    result = MB_FAILURE;
+    RRA("MPI_Bcast of buffer size failed.");
+  }


More information about the moab-dev mailing list