[MOAB-dev] r2143 - in MOAB/trunk: . parallel
kraftche at mcs.anl.gov
kraftche at mcs.anl.gov
Tue Oct 14 14:25:27 CDT 2008
Author: kraftche
Date: 2008-10-14 14:25:26 -0500 (Tue, 14 Oct 2008)
New Revision: 2143
Modified:
MOAB/trunk/MBParallelConventions.h
MOAB/trunk/parallel/MBParallelComm.cpp
MOAB/trunk/parallel/MBParallelComm.hpp
Log:
o Add PARALLEL_PART_TAG_NAME as alias for PARALLEL_PARTITION_TAG_NAME
o Add new PARALLEL_PARITIONING_TAG_NAME
o Move PARALLEL_COMM_TAG_NAME to MBParallelComm.cpp, as all code ouside
of MBParallelComm should use MBParallelComm::get_pcomm rather than
accessing this tag's data directly.
o Add optional argument to pass back pcomm index assigned to new
MBParallelComm instances
o Add function for associating MBParallelComm instances with mesh
paritioning set.
Modified: MOAB/trunk/MBParallelConventions.h
===================================================================
--- MOAB/trunk/MBParallelConventions.h 2008-10-14 18:05:20 UTC (rev 2142)
+++ MOAB/trunk/MBParallelConventions.h 2008-10-14 19:25:26 UTC (rev 2143)
@@ -18,10 +18,26 @@
*
* When the mesh is partitioned for use in a parallel environment,
* the each CPUs partiiton of the mesh is stored in a meshset with
- * this tag. The value of the tag is an integer containing the
- * processor ID (MPI rank).
+ * this tag. The value of the tag is an integer "part identifier".
*/
#define PARALLEL_PARTITION_TAG_NAME "PARALLEL_PARTITION"
+#define PARALLEL_PART_TAG_NAME PARALLEL_PARTITION_TAG_NAME
+
+/** \brief Tag that groups the set of parts/partitions that are
+ * a covering of the mesh.
+ *
+ * This tag labels an entity set for which the child sets are part(ition)s
+ * that together are a single partitioning of the mesh. I.e. There should
+ * be no mesh entity that is contained in more than one child part(ition)
+ * set, and typically every mesh entity of the dimenion used to partition
+ * the mesh is contained in exactly one of the child sets.
+ *
+ * The data for this tag is a single integer value. The value of
+ * the tag is undefined.
+ */
+#define PARALLEL_PARITIONING_TAG_NAME "PARALLEL_MESH_PARITIONING"
+
+/** \brief Tag designating a
/** \brief Tag storing which other processor a given entity is shared with
*
@@ -68,20 +84,5 @@
#define PSTATUS_SHARED 0x2
#define PSTATUS_INTERFACE 0x4
#define PSTATUS_GHOST 0x8
-
-/** \brief Tag storing parallel communication objects
- *
- * This tag stores pointers to MBParallelComm communication
- * objects; one of these is allocated for each different
- * communicator used to read mesh. MBParallelComm stores
- * partition and interface sets corresponding to its parallel mesh.
- * By default, a parallel read uses the first MBParallelComm object
- * on the interface instance; if instantiated with one, ReadParallel
- * adds this object to the interface instance too.
- *
- * Tag type: opaque
- * Tag size: MAX_SHARING_PROCS*sizeof(MBParallelComm*)
- */
-#define PARALLEL_COMM_TAG_NAME "__PARALLEL_COMM"
#endif
Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp 2008-10-14 18:05:20 UTC (rev 2142)
+++ MOAB/trunk/parallel/MBParallelComm.cpp 2008-10-14 19:25:26 UTC (rev 2143)
@@ -109,6 +109,25 @@
dynamic_cast<MBCore*>(mbImpl)->get_error_handler()->set_last_error(tmp_str.c_str()); \
return result;}
+/** Name of tag used to store MBParallelComm Index on mesh paritioning sets */
+const char* PARTITIONING_PCOMM_TAG_NAME = "__PRTN_PCOMM";
+
+/** \brief Tag storing parallel communication objects
+ *
+ * This tag stores pointers to MBParallelComm communication
+ * objects; one of these is allocated for each different
+ * communicator used to read mesh. MBParallelComm stores
+ * partition and interface sets corresponding to its parallel mesh.
+ * By default, a parallel read uses the first MBParallelComm object
+ * on the interface instance; if instantiated with one, ReadParallel
+ * adds this object to the interface instance too.
+ *
+ * Tag type: opaque
+ * Tag size: MAX_SHARING_PROCS*sizeof(MBParallelComm*)
+ */
+#define PARALLEL_COMM_TAG_NAME "__PARALLEL_COMM"
+
+
enum MBMessageTag {MB_MESG_ANY=MPI_ANY_TAG,
MB_MESG_SIZE,
MB_MESG_ENTS,
@@ -116,7 +135,7 @@
MB_MESG_REMOTE_HANDLES_VECTOR,
MB_MESG_TAGS,};
-MBParallelComm::MBParallelComm(MBInterface *impl, MPI_Comm comm)
+MBParallelComm::MBParallelComm(MBInterface *impl, MPI_Comm comm, int* id )
: mbImpl(impl), procConfig(comm), sharedpTag(0), sharedpsTag(0),
sharedhTag(0), sharedhsTag(0), pstatusTag(0), ifaceSetsTag(0),
partitionTag(0)
@@ -136,12 +155,15 @@
retval = MPI_Init(&argc, &argv);
}
- add_pcomm(this);
+ int myid = add_pcomm(this);
+ if (id)
+ *id = myid;
}
MBParallelComm::MBParallelComm(MBInterface *impl,
std::vector<unsigned char> &tmp_buff,
- MPI_Comm comm)
+ MPI_Comm comm,
+ int* id)
: mbImpl(impl), procConfig(comm), sharedpTag(0), sharedpsTag(0),
sharedhTag(0), sharedhsTag(0), pstatusTag(0), ifaceSetsTag(0),
partitionTag(0)
@@ -157,7 +179,9 @@
retval = MPI_Init(&argc, &argv);
}
- add_pcomm(this);
+ int myid = add_pcomm(this);
+ if (id)
+ *id = myid;
}
MBParallelComm::~MBParallelComm()
@@ -3654,6 +3678,44 @@
return pc_array[index];
}
+ //! get the indexed pcomm object from the interface
+MBParallelComm *MBParallelComm::get_pcomm( MBInterface *impl,
+ MBEntityHandle prtn,
+ const MPI_Comm* comm )
+{
+ MBErrorCode rval;
+ MBParallelComm* result = 0;
+
+ MBTag prtn_tag;
+ rval = impl->tag_create( PARTITIONING_PCOMM_TAG_NAME,
+ sizeof(int),
+ MB_TAG_SPARSE,
+ MB_TYPE_INTEGER,
+ prtn_tag,
+ 0, true );
+ if (MB_SUCCESS != rval)
+ return 0;
+
+ int pcomm_id;
+ rval = impl->tag_get_data( prtn_tag, &prtn, 1, &pcomm_id );
+ if (MB_SUCCESS == rval) {
+ result= get_pcomm( impl, pcomm_id );
+ }
+ else if (MB_TAG_NOT_FOUND == rval && comm) {
+ result = new MBParallelComm( impl, *comm, &pcomm_id );
+ if (!result)
+ return 0;
+
+ rval = impl->tag_set_data( prtn_tag, &prtn, 1, &pcomm_id );
+ if (MB_SUCCESS != rval) {
+ delete result;
+ result = 0;
+ }
+ }
+
+ return result;
+}
+
//! return all the entities in parts owned locally
MBErrorCode MBParallelComm::get_part_entities(MBRange &ents, int dim)
{
Modified: MOAB/trunk/parallel/MBParallelComm.hpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.hpp 2008-10-14 18:05:20 UTC (rev 2142)
+++ MOAB/trunk/parallel/MBParallelComm.hpp 2008-10-14 19:25:26 UTC (rev 2143)
@@ -51,13 +51,26 @@
//! constructor
MBParallelComm(MBInterface *impl,
- MPI_Comm comm = MPI_COMM_WORLD);
+ MPI_Comm comm = MPI_COMM_WORLD,
+ int* pcomm_id_out);
//! constructor taking packed buffer, for testing
MBParallelComm(MBInterface *impl,
std::vector<unsigned char> &tmp_buff,
- MPI_Comm comm = MPI_COMM_WORLD);
+ MPI_Comm comm = MPI_COMM_WORLD,
+ int* pcomm_id_out);
+
+ //! get the indexed pcomm object from the interface
+ static MBParallelComm *get_pcomm(MBInterface *impl, const int index);
+
+ //! Get MBParallelComm instance associated with partition handle
+ //! Will create MBParallelComm instance if a) one does not already
+ //! exist and b) a valid value for MPI_Comm is passed.
+ static MBParallelComm *get_pcomm( MBInterface* impl,
+ MBEntityHandle partitioning,
+ const MPI_Comm* comm = 0 );
+
//! destructor
~MBParallelComm();
@@ -317,9 +330,6 @@
//! to look for one on the interface
static MBTag pcomm_tag(MBInterface *impl,
bool create_if_missing = true);
-
- //! get the indexed pcomm object from the interface
- static MBParallelComm *get_pcomm(MBInterface *impl, const int index);
//! return partitions set tag
MBTag partition_tag();
@@ -648,7 +658,7 @@
MBErrorCode tag_iface_entities();
//! add a pc to the iface instance tag PARALLEL_COMM
- void add_pcomm(MBParallelComm *pc);
+ int add_pcomm(MBParallelComm *pc);
//! remove a pc from the iface instance tag PARALLEL_COMM
void remove_pcomm(MBParallelComm *pc);
More information about the moab-dev
mailing list