[MOAB-dev] r3689 - in MOAB/trunk/src/parallel: . moab
kraftche at cae.wisc.edu
kraftche at cae.wisc.edu
Mon Mar 22 16:18:27 CDT 2010
Author: kraftche
Date: 2010-03-22 16:18:27 -0500 (Mon, 22 Mar 2010)
New Revision: 3689
Modified:
MOAB/trunk/src/parallel/ParallelComm.cpp
MOAB/trunk/src/parallel/moab/ParallelComm.hpp
Log:
o Make containers passed by reference to ParallelComm::exchange_tags
const because ParallelComm shouldn't be modifying them.
o In ParallelComm::exchange_tags, if source tag is different than
destination tag, also copy values locally on owned entities.
Modified: MOAB/trunk/src/parallel/ParallelComm.cpp
===================================================================
--- MOAB/trunk/src/parallel/ParallelComm.cpp 2010-03-22 20:40:35 UTC (rev 3688)
+++ MOAB/trunk/src/parallel/ParallelComm.cpp 2010-03-22 21:18:27 UTC (rev 3689)
@@ -4783,9 +4783,9 @@
}
-ErrorCode ParallelComm::exchange_tags(std::vector<Tag> &src_tags,
- std::vector<Tag> &dst_tags,
- Range &entities)
+ErrorCode ParallelComm::exchange_tags( const std::vector<Tag> &src_tags,
+ const std::vector<Tag> &dst_tags,
+ const Range &entities_in)
{
ErrorCode result;
int success;
@@ -4829,7 +4829,7 @@
sendReqs.resize(2*buffProcs.size(), MPI_REQUEST_NULL);
// take all shared entities if incoming list is empty
- if (entities.empty()) entities = sharedEnts;
+ const Range& entities = entities_in.empty() ? sharedEnts : entities_in;
int dum_ack_buff;
@@ -4849,7 +4849,7 @@
// pack-send; this also posts receives if store_remote_handles is true
std::vector<Range> tag_ranges;
- for (std::vector<Tag>::iterator vit = src_tags.begin(); vit != src_tags.end(); vit++) {
+ for (std::vector<Tag>::const_iterator vit = src_tags.begin(); vit != src_tags.end(); vit++) {
const void* ptr;
int size;
if (tagServer->get_default_data_ref( *vit, ptr, size ) != MB_SUCCESS) {
@@ -4924,6 +4924,42 @@
RRA("Failure in waitall in tag exchange.");
}
+ // If source tag is not equal to destination tag, then
+ // do local copy for owned entities (communicate w/ self)
+ assert(src_tags.size() == dst_tags.size());
+ if (src_tags != dst_tags) {
+ std::vector<unsigned char> data;
+ Range owned_ents(entities_in);
+ result = filter_pstatus(owned_ents, PSTATUS_NOT_OWNED, PSTATUS_NOT);
+ RRA("Failure to get subset of owned entities");
+
+ for (size_t i = 0; i < src_tags.size(); ++i) {
+ if (src_tags[i] == dst_tags[i])
+ continue;
+
+ Range tagged_ents(owned_ents);
+ result = mbImpl->get_entities_by_type_and_tag( 0, MBMAXTYPE,
+ &src_tags[0], 0, 1, tagged_ents, Interface::INTERSECT );
+ RRA("get_entities_by_type_and_tag(type == MBMAXTYPE) failed.");
+
+ int size, size2;
+ result = mbImpl->tag_get_size( src_tags[i], size );
+ RRA("tag_get_size failed.");
+ result = mbImpl->tag_get_size( dst_tags[i], size2 );
+ RRA("tag_get_size failed.");
+ if (size != size2) {
+ result = MB_FAILURE;
+ RRA("tag sizes don't match")
+ }
+
+ data.resize( size * tagged_ents.size() );
+ result = mbImpl->tag_get_data( src_tags[i], tagged_ents, &data[0] );
+ RRA("tag_get_data failed.");
+ result = mbImpl->tag_set_data( dst_tags[i], tagged_ents, &data[0] );
+ RRA("tag_set_data failed.");
+ }
+ }
+
#ifdef DEBUG_COMM
std::cerr << "Exiting exchange_tags" << std::endl; std::cerr.flush();
#endif
Modified: MOAB/trunk/src/parallel/moab/ParallelComm.hpp
===================================================================
--- MOAB/trunk/src/parallel/moab/ParallelComm.hpp 2010-03-22 20:40:35 UTC (rev 3688)
+++ MOAB/trunk/src/parallel/moab/ParallelComm.hpp 2010-03-22 21:18:27 UTC (rev 3689)
@@ -190,23 +190,23 @@
* tag (or the tag should have a default value).
* \param tags Vector of tag handles to be exchanged
*/
- ErrorCode exchange_tags(std::vector<Tag> &src_tags,
- std::vector<Tag> &dst_tags,
- Range &entities);
+ ErrorCode exchange_tags( const std::vector<Tag> &src_tags,
+ const std::vector<Tag> &dst_tags,
+ const Range &entities);
/** \brief Exchange tags for all shared and ghosted entities
* This function should be called collectively over the communicator for this ParallelComm
* \param tag_name Name of tag to be exchanged
*/
- ErrorCode exchange_tags(const char *tag_name,
- Range &entities);
+ ErrorCode exchange_tags( const char *tag_name,
+ const Range &entities);
/** \brief Exchange tags for all shared and ghosted entities
* This function should be called collectively over the communicator for this ParallelComm
* \param tagh Handle of tag to be exchanged
*/
- ErrorCode exchange_tags(Tag tagh,
- Range &entities);
+ ErrorCode exchange_tags( Tag tagh,
+ const Range &entities);
/** \brief Broadcast all entities resident on from_proc to other processors
* This function assumes remote handles are *not* being stored, since (usually)
@@ -1168,8 +1168,8 @@
return MB_SUCCESS;
}
-inline ErrorCode ParallelComm::exchange_tags(const char *tag_name,
- Range &entities)
+inline ErrorCode ParallelComm::exchange_tags( const char *tag_name,
+ const Range &entities)
{
// get the tag handle
std::vector<Tag> tags(1);
@@ -1180,8 +1180,8 @@
return exchange_tags(tags, tags, entities);
}
-inline ErrorCode ParallelComm::exchange_tags(Tag tagh,
- Range &entities)
+inline ErrorCode ParallelComm::exchange_tags( Tag tagh,
+ const Range &entities)
{
// get the tag handle
std::vector<Tag> tags;
More information about the moab-dev
mailing list