[MOAB-dev] r2068 - MOAB/trunk/parallel
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Fri Sep 19 14:44:47 CDT 2008
Author: tautges
Date: 2008-09-19 14:44:47 -0500 (Fri, 19 Sep 2008)
New Revision: 2068
Modified:
MOAB/trunk/parallel/MBParallelComm.cpp
MOAB/trunk/parallel/mbparallelcomm_test.cpp
Log:
Better handling of get_pcomm. Changing an assert to be more precise.
Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp 2008-09-18 16:41:07 UTC (rev 2067)
+++ MOAB/trunk/parallel/MBParallelComm.cpp 2008-09-19 19:44:47 UTC (rev 2068)
@@ -171,6 +171,7 @@
std::vector<MBParallelComm *> pc_array(MAX_SHARING_PROCS,
(MBParallelComm*)NULL);
MBTag pc_tag = pcomm_tag(mbImpl, true);
+ assert(0 != pc_tag);
MBErrorCode result = mbImpl->tag_get_data(pc_tag, 0, 0, (void*)&pc_array[0]);
if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) return;
@@ -3259,7 +3260,7 @@
std::copy(sent_ents[ind-MAX_SHARING_PROCS].begin(),
sent_ents[ind-MAX_SHARING_PROCS].end(),
std::back_inserter(sent_ents_tmp));
- assert(!sent_ents_tmp.empty());
+ assert(sent_ents_tmp.size() == sent_ents[ind-MAX_SHARING_PROCS].size());
result = set_remote_data(&sent_ents_tmp[0], &remote_handles_v[0], sent_ents_tmp.size(),
buffProcs[ind-MAX_SHARING_PROCS]);
RRA("Trouble setting remote data range on sent entities in ghost exchange.");
@@ -3574,13 +3575,18 @@
bool create_if_missing)
{
MBTag this_tag = 0;
- MBErrorCode result = impl->tag_create(PARALLEL_COMM_TAG_NAME,
- MAX_SHARING_PROCS*sizeof(MBParallelComm*),
- MB_TAG_SPARSE,
- MB_TYPE_OPAQUE, this_tag,
- NULL, create_if_missing);
+ MBErrorCode result;
+ result = impl->tag_get_handle(PARALLEL_COMM_TAG_NAME, this_tag);
+ if ((MB_TAG_NOT_FOUND == result || 0 == this_tag) &&
+ create_if_missing) {
+ result = impl->tag_create(PARALLEL_COMM_TAG_NAME,
+ MAX_SHARING_PROCS*sizeof(MBParallelComm*),
+ MB_TAG_SPARSE,
+ MB_TYPE_OPAQUE, this_tag,
+ NULL, true);
if (MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result)
return 0;
+ }
return this_tag;
}
@@ -3588,10 +3594,10 @@
//! get the indexed pcomm object from the interface
MBParallelComm *MBParallelComm::get_pcomm(MBInterface *impl, const int index)
{
- MBParallelComm *pc_array[MAX_SHARING_PROCS];
MBTag pc_tag = pcomm_tag(impl, false);
if (0 == pc_tag) return NULL;
+ MBParallelComm *pc_array[MAX_SHARING_PROCS];
MBErrorCode result = impl->tag_get_data(pc_tag, 0, 0, (void*)pc_array);
if (MB_SUCCESS != result) return NULL;
Modified: MOAB/trunk/parallel/mbparallelcomm_test.cpp
===================================================================
--- MOAB/trunk/parallel/mbparallelcomm_test.cpp 2008-09-18 16:41:07 UTC (rev 2067)
+++ MOAB/trunk/parallel/mbparallelcomm_test.cpp 2008-09-19 19:44:47 UTC (rev 2068)
@@ -88,7 +88,7 @@
return 1;
}
- int npos = 1, tag_val, distrib, with_ghosts = 1, resolve_shared = 1, use_mpio = 0;
+ int npos = 1, tag_val, distrib, with_ghosts = 0, resolve_shared = 1, use_mpio = 0;
const char *tag_name;
std::vector<std::string> filenames;
int parallel_option = 0;
@@ -331,30 +331,38 @@
std::vector<MBParallelComm*> pcs(filenames.size());
std::vector<ReadParallel*> rps(filenames.size());
MBErrorCode result;
-
- for (unsigned int i = 0; i < filenames.size(); i++) {
- pcs[i] = new MBParallelComm(mbImpl);
- rps[i] = new ReadParallel(mbImpl, pcs[i]);
+
+ if (1 < filenames.size()) {
+ for (unsigned int i = 0; i < filenames.size(); i++) {
+ pcs[i] = new MBParallelComm(mbImpl);
+ rps[i] = new ReadParallel(mbImpl, pcs[i]);
- result = rps[i]->load_file(filenames[i].c_str(), filesets[i],
- FileOptions(options.str().c_str()), NULL, 0);
- if (MB_SUCCESS != result)
- PRINT_LAST_ERROR;
+ result = rps[i]->load_file(filenames[i].c_str(), filesets[i],
+ FileOptions(options.str().c_str()), NULL, 0);
+ if (MB_SUCCESS != result)
+ PRINT_LAST_ERROR;
- if (MB_SUCCESS != result) {
- MPI_Abort(MPI_COMM_WORLD, result);
- break;
- }
+ if (MB_SUCCESS != result) {
+ MPI_Abort(MPI_COMM_WORLD, result);
+ break;
+ }
- // exchange tag
- result = pcs[i]->exchange_tags("GLOBAL_ID");
- if (MB_SUCCESS != result) {
- std::cerr << "Tag exchange didn't work." << std::endl;
- break;
+ // exchange tag
+ result = pcs[i]->exchange_tags("GLOBAL_ID");
+ if (MB_SUCCESS != result) {
+ std::cerr << "Tag exchange didn't work." << std::endl;
+ break;
+ }
+
}
-
}
-
+ else {
+ result = mbImpl->load_file(filenames[0].c_str(), filesets[0],
+ options.str().c_str());
+ pcs[0] = MBParallelComm::get_pcomm(mbImpl, 0);
+ assert(pcs[0]);
+ }
+
if (MB_SUCCESS == result) report_iface_ents(mbImpl, pcs);
return result;
More information about the moab-dev
mailing list