moab
|
ParallelComm data about shared entity sets. More...
#include <SharedSetData.hpp>
Classes | |
struct | less_vect |
struct | SharedSetTagData |
per-set tag data More... | |
Public Member Functions | |
SharedSetData (Interface &moab, unsigned rank) | |
~SharedSetData () | |
ErrorCode | get_owning_procs (std::vector< unsigned > &ranks_out) const |
Get ranks of sharing procs. | |
ErrorCode | get_sharing_procs (EntityHandle entity_set, std::vector< unsigned > &ranks_out) const |
Get ranks of sharing procs. | |
ErrorCode | get_shared_sets (Range &sets_out) const |
Get handles for all shared sets. | |
ErrorCode | get_shared_sets (unsigned rank, Range &sets_out) const |
Get handles for all sets shared with specified process. | |
ErrorCode | get_owner (EntityHandle set, unsigned &rank_out, EntityHandle &remote_handle_out) const |
Get owner and owner's handle for shared set. | |
ErrorCode | get_owner (EntityHandle set, unsigned &rank_out) const |
Get owner of shared set. | |
ErrorCode | get_owner_handle (EntityHandle set, EntityHandle &handle_out) const |
Get owner's handle for shared set. | |
ErrorCode | get_local_handle (unsigned owner_rank, EntityHandle remote_handle, EntityHandle &local_handle_out) const |
Get local handle for shared set. | |
ErrorCode | set_owner (EntityHandle set, unsigned owner_rank, EntityHandle owner_handle) |
ErrorCode | set_sharing_procs (EntityHandle set_handle, std::vector< unsigned > &ranks) |
set/update sharing list for a set | |
Private Types | |
typedef RangeMap< EntityHandle, EntityHandle > | ProcHandleMapType |
typedef std::map< unsigned, ProcHandleMapType > | RHMap |
typedef std::set< std::vector < unsigned >, less_vect > | RProcMap |
Static Private Member Functions | |
static void | append_local_handles (const ProcHandleMapType &map, Range &append_to_this) |
Private Attributes | |
Interface & | mb |
unsigned | myRank |
Tag | sharedSetTag |
RHMap | handleMap |
RProcMap | procListMap |
ParallelComm data about shared entity sets.
Definition at line 29 of file SharedSetData.hpp.
typedef RangeMap<EntityHandle,EntityHandle> moab::SharedSetData::ProcHandleMapType [private] |
Map type for lookup of local handle given remote handle
Definition at line 101 of file SharedSetData.hpp.
typedef std::map<unsigned,ProcHandleMapType> moab::SharedSetData::RHMap [private] |
Definition at line 135 of file SharedSetData.hpp.
typedef std::set<std::vector<unsigned>,less_vect> moab::SharedSetData::RProcMap [private] |
Definition at line 136 of file SharedSetData.hpp.
moab::SharedSetData::SharedSetData | ( | Interface & | moab, |
unsigned | rank | ||
) |
Definition at line 13 of file SharedSetData.cpp.
: mb(moab), myRank(rank), sharedSetTag(0) { SharedSetTagData zero = { 0, rank, 0 }; ErrorCode rval = mb.tag_get_handle( "__sharedSetTag", sizeof(SharedSetTagData), MB_TYPE_OPAQUE, sharedSetTag, MB_TAG_CREAT|MB_TAG_SPARSE, &zero ); assert(MB_SUCCESS == rval); if (MB_SUCCESS != rval) abort(); }
Definition at line 24 of file SharedSetData.cpp.
{ mb.tag_delete( sharedSetTag ); }
void moab::SharedSetData::append_local_handles | ( | const ProcHandleMapType & | map, |
Range & | append_to_this | ||
) | [static, private] |
Definition at line 172 of file SharedSetData.cpp.
{ Range::iterator hint = range.begin(); for (ProcHandleMapType::const_iterator i = map.begin(); i != map.end(); ++i) hint = range.insert( hint, i->value, i->value + i->count-1 ); }
ErrorCode moab::SharedSetData::get_local_handle | ( | unsigned | owner_rank, |
EntityHandle | remote_handle, | ||
EntityHandle & | local_handle_out | ||
) | const |
Get local handle for shared set.
Definition at line 104 of file SharedSetData.cpp.
{ RHMap::const_iterator i = handleMap.find( owner_rank ); assert(i != handleMap.end()); if (i == handleMap.end()) { local_handle = ~(EntityHandle)0; return MB_FAILURE; } if (!i->second.find( remote_handle, local_handle )) { assert(false); local_handle = ~(EntityHandle)0; return MB_FAILURE; } return MB_SUCCESS; }
ErrorCode moab::SharedSetData::get_owner | ( | EntityHandle | set, |
unsigned & | rank_out, | ||
EntityHandle & | remote_handle_out | ||
) | const |
Get owner and owner's handle for shared set.
Definition at line 84 of file SharedSetData.cpp.
{ ErrorCode rval; SharedSetTagData data; rval = mb.tag_get_data( sharedSetTag, &entity_set, 1, &data ); if (MB_SUCCESS != rval) return rval; if (!data.ownerHandle) { // not shared assert(!data.sharingProcs); // really not shared data.ownerHandle = entity_set; } rank_out = data.ownerRank; remote_handle_out = data.ownerHandle; return MB_SUCCESS; }
ErrorCode moab::SharedSetData::get_owner | ( | EntityHandle | set, |
unsigned & | rank_out | ||
) | const [inline] |
Get owner of shared set.
Definition at line 63 of file SharedSetData.hpp.
{ EntityHandle h; return get_owner( set, rank_out, h ); }
ErrorCode moab::SharedSetData::get_owner_handle | ( | EntityHandle | set, |
EntityHandle & | handle_out | ||
) | const [inline] |
Get owner's handle for shared set.
Definition at line 67 of file SharedSetData.hpp.
{ unsigned rank; return get_owner( set, rank, handle_out); }
ErrorCode moab::SharedSetData::get_owning_procs | ( | std::vector< unsigned > & | ranks_out | ) | const |
Get ranks of sharing procs.
Get list of all process ranks that own at least one set that is shared with this process.
Definition at line 30 of file SharedSetData.cpp.
{ ranks_out.clear(); ranks_out.reserve( handleMap.size() ); for (RHMap::const_iterator i = handleMap.begin(); i != handleMap.end(); ++i) ranks_out.push_back( i->first ); return MB_SUCCESS; }
ErrorCode moab::SharedSetData::get_shared_sets | ( | Range & | sets_out | ) | const |
Get handles for all shared sets.
Definition at line 55 of file SharedSetData.cpp.
{ // sets_out.clear(); // return mb.get_entities_by_type_and_tag( 0, MBENTITYSET, &sharedSetTag, 1, 0, sets_out ); sets_out.clear(); for (RHMap::const_iterator i = handleMap.begin(); i != handleMap.end(); ++i) append_local_handles( i->second, sets_out ); return MB_SUCCESS; }
ErrorCode moab::SharedSetData::get_shared_sets | ( | unsigned | rank, |
Range & | sets_out | ||
) | const |
Get handles for all sets shared with specified process.
Definition at line 68 of file SharedSetData.cpp.
{ sets_out.clear(); // if (rank == myRank) { // return mb.get_entities_by_type_and_tag( 0, MBENTITYSET, // } // else { RHMap::const_iterator i = handleMap.find( rank ); if (i != handleMap.end()) append_local_handles( i->second, sets_out ); return MB_SUCCESS; // } }
ErrorCode moab::SharedSetData::get_sharing_procs | ( | EntityHandle | entity_set, |
std::vector< unsigned > & | ranks_out | ||
) | const |
Get ranks of sharing procs.
Get list of all process ranks with which this process the passed set. Returns an empty list for non-shared sets.
Definition at line 40 of file SharedSetData.cpp.
{ ErrorCode rval; SharedSetTagData data; rval = mb.tag_get_data( sharedSetTag, &entity_set, 1, &data ); if (MB_SUCCESS != rval) return rval; ranks_out.clear(); if (data.sharingProcs) ranks_out = *data.sharingProcs; return MB_SUCCESS; }
ErrorCode moab::SharedSetData::set_owner | ( | EntityHandle | set, |
unsigned | owner_rank, | ||
EntityHandle | owner_handle | ||
) |
Definition at line 125 of file SharedSetData.cpp.
{ ErrorCode rval; SharedSetTagData data; rval = mb.tag_get_data( sharedSetTag, &set, 1, &data ); if (MB_SUCCESS != rval) return rval; if (data.ownerHandle) { RHMap::iterator i = handleMap.find( data.ownerRank ); if (i != handleMap.end()) { i->second.erase( data.ownerHandle, 1 ); } } data.ownerRank = owner_rank; data.ownerHandle = owner_handle; rval = mb.tag_set_data( sharedSetTag, &set, 1, &data ); if (MB_SUCCESS != rval) return rval; if (!handleMap[owner_rank].insert( owner_handle, set, 1 ).second) { assert(false); return MB_FAILURE; } return MB_SUCCESS; }
ErrorCode moab::SharedSetData::set_sharing_procs | ( | EntityHandle | set_handle, |
std::vector< unsigned > & | ranks | ||
) |
set/update sharing list for a set
sorts ranks
vector
Definition at line 153 of file SharedSetData.cpp.
{ std::sort( ranks.begin(), ranks.end() ); RProcMap::iterator it = procListMap.insert( ranks ).first; ErrorCode rval; SharedSetTagData data; rval = mb.tag_get_data( sharedSetTag, &entity_set, 1, &data ); if (MB_SUCCESS != rval) return rval; data.sharingProcs = &*it; rval = mb.tag_set_data( sharedSetTag, &entity_set, 1, &data ); if (MB_SUCCESS != rval) return rval; return MB_SUCCESS; }
RHMap moab::SharedSetData::handleMap [private] |
Map for lookup of ProcHandleMapType instance by rank
Definition at line 140 of file SharedSetData.hpp.
Interface& moab::SharedSetData::mb [private] |
Definition at line 86 of file SharedSetData.hpp.
unsigned moab::SharedSetData::myRank [private] |
Definition at line 87 of file SharedSetData.hpp.
RProcMap moab::SharedSetData::procListMap [private] |
Storage of sharing lists
Definition at line 143 of file SharedSetData.hpp.
Tag moab::SharedSetData::sharedSetTag [private] |
Shared set data: opaque tag containing struct SharedSetTagData
Definition at line 98 of file SharedSetData.hpp.