[MOAB-dev] commit/MOAB: danwu: For GATHER_SET=<gatherSetRank> read option, allow ParallelComm::gather_data() to specify a root processor to gather data. Also, changed new/delete to malloc/free for the temp buffer.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Nov 7 12:02:27 CST 2013
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/8c3d9712faec/
Changeset: 8c3d9712faec
Branch: master
User: danwu
Date: 2013-11-07 19:02:15
Summary: For GATHER_SET=<gatherSetRank> read option, allow ParallelComm::gather_data() to specify a root processor to gather data. Also, changed new/delete to malloc/free for the temp buffer.
Affected #: 2 files
diff --git a/src/parallel/ParallelComm.cpp b/src/parallel/ParallelComm.cpp
index 7c3f5c7..8efc777 100644
--- a/src/parallel/ParallelComm.cpp
+++ b/src/parallel/ParallelComm.cpp
@@ -8728,7 +8728,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
ErrorCode ParallelComm::gather_data(Range &gather_ents, Tag &tag_handle,
- Tag id_tag, EntityHandle gather_set)
+ Tag id_tag, EntityHandle gather_set, int root_proc_rank)
{
int dim = mbImpl->dimension_from_handle(*gather_ents.begin());
int bytes_per_tag = 0;
@@ -8743,7 +8743,7 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
ptr_int = (int*)(senddata) + 1 + gather_ents.size();
rval = mbImpl->tag_get_data(tag_handle, gather_ents, (void*)ptr_int);
std::vector<int> displs(proc_config().proc_size(), 0);
- MPI_Gather(&sz_buffer, 1, MPI_INT, &displs[0], 1, MPI_INT, 0, comm());
+ MPI_Gather(&sz_buffer, 1, MPI_INT, &displs[0], 1, MPI_INT, root_proc_rank, comm());
std::vector<int> recvcnts(proc_config().proc_size(), 0);
std::copy(displs.begin(), displs.end(), recvcnts.begin());
std::partial_sum(displs.begin(), displs.end(), displs.begin());
@@ -8752,14 +8752,14 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
//std::copy_backward(displs.begin(), --displs.end(), displs.end());
displs[0] = 0;
- if (rank() != 0)
- MPI_Gatherv(senddata, sz_buffer, MPI_BYTE, NULL, NULL, NULL, MPI_BYTE, 0, comm());
+ if ((int)rank() != root_proc_rank)
+ MPI_Gatherv(senddata, sz_buffer, MPI_BYTE, NULL, NULL, NULL, MPI_BYTE, root_proc_rank, comm());
else {
Range gents;
mbImpl->get_entities_by_dimension(gather_set, dim, gents);
int recvbuffsz = gents.size() * (bytes_per_tag + sizeof(int)) + proc_config().proc_size() * sizeof(int);
void* recvbuf = malloc(recvbuffsz);
- MPI_Gatherv(senddata, sz_buffer, MPI_BYTE, recvbuf, &recvcnts[0], &displs[0], MPI_BYTE, 0, comm());
+ MPI_Gatherv(senddata, sz_buffer, MPI_BYTE, recvbuf, &recvcnts[0], &displs[0], MPI_BYTE, root_proc_rank, comm());
void* gvals = NULL;
@@ -8772,13 +8772,15 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
rval = mbImpl->tag_iterate(tag_handle, gents.begin(), gents.end(), count, gvals);
assert(NULL != gvals);
assert(count > 0);
- if ((size_t)count != gents.size())
+ if ((size_t)count != gents.size()) {
multiple_sequences = true;
+ gvals = NULL;
+ }
}
// If gents has multiple sequences, create a temp buffer for gathered values
if (multiple_sequences) {
- gvals = new (std::nothrow) char[gents.size() * bytes_per_tag];
+ gvals = malloc(gents.size() * bytes_per_tag);
assert(NULL != gvals);
}
@@ -8809,8 +8811,8 @@ ErrorCode ParallelComm::post_irecv(std::vector<unsigned int>& shared_procs,
}
assert(start_idx == gents.size());
- // Delete the temp buffer
- delete[] (char*)gvals;
+ // Free the temp buffer
+ free(gvals);
}
}
diff --git a/src/parallel/moab/ParallelComm.hpp b/src/parallel/moab/ParallelComm.hpp
index e02d4b3..e4217ce 100644
--- a/src/parallel/moab/ParallelComm.hpp
+++ b/src/parallel/moab/ParallelComm.hpp
@@ -899,7 +899,7 @@ namespace moab {
//! get the verbosity level of output from this pcomm
int get_debug_verbosity();
- /* \brief Gather tag value from entities down to root proc
+ /* \brief Gather tag value from entities down to a specified root proc
* This function gathers data from a domain-decomposed mesh onto a global mesh
* represented on the root processor. On the root, this gather mesh is distinct from
* the root's domain-decomposed subdomain. Entities are matched by global id, or by
@@ -910,9 +910,10 @@ namespace moab {
* \param tag_handle Tag whose values are being gathered
* \param id_tag Tag to use for matching entities (global id used by default)
* \param gather_set On root, set containing global mesh onto which to put data
+ * \param root_proc_rank Rank of the specified root processor (default rank is 0)
*/
ErrorCode gather_data(Range &gather_ents, Tag &tag_handle,
- Tag id_tag = 0, EntityHandle gather_set = 0);
+ Tag id_tag = 0, EntityHandle gather_set = 0, int root_proc_rank = 0);
/* \brief communicate extra points positions on boundary
* This function is called after intersection of 2 meshes, to settle the
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list