[MOAB-dev] r3250 - in MOAB/trunk: . parallel
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Thu Oct 29 13:49:24 CDT 2009
Author: tautges
Date: 2009-10-29 13:49:24 -0500 (Thu, 29 Oct 2009)
New Revision: 3250
Modified:
MOAB/trunk/MBCore.cpp
MOAB/trunk/parallel/MBParallelComm.cpp
MOAB/trunk/parallel/MBParallelComm.hpp
MOAB/trunk/parallel/Makefile.am
MOAB/trunk/parallel/mbparallelcomm_test.cpp
MOAB/trunk/parallel/scdtest.cpp
Log:
MBCore: using swap instead of '=' for range copy, for efficiency
parallel:
scdtest.cpp: rearranged a bit to make easier to debug
mbparallelcomm_test.cpp: removed warnings, and delete instance at end
MBParallelComm.cpp:
- added DEBUG_MSGS #define to help debug messages
- removed commented-out #define's
- increased size passed into CHECK_BUFF_SPACE in pack_entities, was computing
that size wrongly before
- added functionality to print_buffer to print all message types, not just sending
entities; added arguments for printing procs and whether send or receive is being
done
- in pack_shared_handles, checked error return of call to get_sharing_data
Also added uber_parallel_test, for testing the various ghosting and non-ghosting options
for loading, and scdtest, for testing parallel structured mesh representation.
Passes make check (including parallel ones), except for iMeshP tests.
Modified: MOAB/trunk/MBCore.cpp
===================================================================
--- MOAB/trunk/MBCore.cpp 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/MBCore.cpp 2009-10-29 18:49:24 UTC (rev 3250)
@@ -1228,7 +1228,7 @@
std::set_intersection(adj_entities.begin(), adj_entities.end(),
temp_vec.begin(), temp_vec.end(),
mb_range_inserter(temp_range));
- adj_entities = temp_range;
+ adj_entities.swap(temp_range);
}
else if (operation_type == MBInterface::UNION) {
std::copy(temp_vec.begin(), temp_vec.end(), mb_range_inserter(adj_entities));
Modified: MOAB/trunk/parallel/MBParallelComm.cpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.cpp 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/parallel/MBParallelComm.cpp 2009-10-29 18:49:24 UTC (rev 3250)
@@ -56,6 +56,7 @@
#endif
#undef DEBUG_COMM
#undef DEBUG_PACKING
+#undef DEBUG_MSGS
#ifdef DEBUG_PACKING
unsigned int __PACK_num = 0, __UNPACK_num = 0, __PACK_count = 0, __UNPACK_count = 0;
std::string __PACK_string, __UNPACK_string;
@@ -93,27 +94,22 @@
buff += count*sizeof(T);
}
-//#define PACK_INTS(buff, int_val, num) {memcpy(buff, int_val, (num)*sizeof(int)); buff += (num)*sizeof(int); PC(num, " ints");}
static inline
void PACK_INTS( unsigned char*& buff, const int* int_val, size_t num )
{ PACK( buff, int_val, num ); PC(num, " ints"); }
-//#define PACK_INT(buff, int_val) {int tmp_val = int_val; PACK_INTS(buff, &tmp_val, 1);}
static inline
void PACK_INT( unsigned char*& buff, int int_val )
{ PACK_INTS( buff, &int_val, 1 ); }
-//#define PACK_DBL(buff, dbl_val, num) {memcpy(buff, dbl_val, (num)*sizeof(double)); buff += (num)*sizeof(double); PC(num, " doubles");}
static inline
void PACK_DBL( unsigned char*& buff, const double* dbl_val, size_t num )
{ PACK( buff, dbl_val, num ); PC(num, " doubles"); }
-//#define PACK_EH(buff, eh_val, num) {memcpy(buff, eh_val, (num)*sizeof(MBEntityHandle)); buff += (num)*sizeof(MBEntityHandle); PC(num, " handles");}
static inline
void PACK_EH( unsigned char*& buff, const MBEntityHandle* eh_val, size_t num )
{ PACK( buff, eh_val, num ); PC(num, " handles"); }
-//#define PACK_CHAR_64(buff, char_val) {strcpy((char*)buff, char_val); buff += 64; PC(64, " chars");}
static inline
void PACK_CHAR_64( unsigned char*& buff, const char* str )
{
@@ -122,7 +118,6 @@
PC(64, " chars");
}
-//#define PACK_VOID(buff, val, num) {memcpy(buff, val, num); buff += num; PC(num, " void");}
static inline
void PACK_VOID( unsigned char*& buff, const void* val, size_t num )
{
@@ -130,17 +125,10 @@
PC(num, " void");
}
-//#define PACK_BYTES(buff, val, num) PACK_INT(buff, num) PACK_VOID(buff, val, num)
static inline
void PACK_BYTES( unsigned char*& buff, const void* val, int num )
{ PACK_INT(buff, num); PACK_VOID(buff, val, num); }
-/*
-#define PACK_RANGE(buff, rng) {int num_subs = num_subranges(rng); PACK_INTS(buff, &num_subs, 1); PC(num_subs, "-subranged range"); \
- for (MBRange::const_pair_iterator cit = rng.const_pair_begin(); cit != rng.const_pair_end(); cit++) { \
- MBEntityHandle eh = (*cit).first; PACK_EH(buff, &eh, 1); \
- eh = (*cit).second; PACK_EH(buff, &eh, 1);}; }
-*/
static inline
void PACK_RANGE( unsigned char*& buff, const MBRange& rng )
{
@@ -153,27 +141,22 @@
PC(rng.psize(), "-subranged range");
}
-//#define UNPACK_INTS(buff, int_val, num) {memcpy(int_val, buff, (num)*sizeof(int)); buff += (num)*sizeof(int); UPC(num, " ints");}
static inline
void UNPACK_INTS( unsigned char*& buff, int* int_val, size_t num )
{ UNPACK(buff, int_val, num); UPC(num, " ints"); }
-//#define UNPACK_INT(buff, int_val) {UNPACK_INTS(buff, &int_val, 1);}
static inline
void UNPACK_INT( unsigned char*& buff, int& int_val )
{ UNPACK_INTS( buff, &int_val, 1 ); }
-//#define UNPACK_DBL(buff, dbl_val, num) {memcpy(dbl_val, buff, (num)*sizeof(double)); buff += (num)*sizeof(double); UPC(num, " doubles");}
static inline
void UNPACK_DBL( unsigned char*& buff, double* dbl_val, size_t num )
{ UNPACK(buff, dbl_val, num); UPC(num, " doubles"); }
-//#define UNPACK_EH(buff, eh_val, num) {memcpy(eh_val, buff, (num)*sizeof(MBEntityHandle)); buff += (num)*sizeof(MBEntityHandle); UPC(num, " handles");}
static inline
void UNPACK_EH( unsigned char*& buff, MBEntityHandle* eh_val, size_t num )
{ UNPACK(buff, eh_val, num); UPC(num, " handles"); }
-//#define UNPACK_CHAR_64(buff, char_val) {strcpy(char_val, (char*)buff); buff += 64; UPC(64, " chars");}
static inline
void UNPACK_CHAR_64( unsigned char*& buff, char* char_val )
{
@@ -182,7 +165,6 @@
UPC(64, " chars");
}
-//#define UNPACK_VOID(buff, val, num) {memcpy(val, buff, num); buff += num; UPC(num, " void");}
static inline
void UNPACK_VOID( unsigned char*& buff, void* val, size_t num )
{
@@ -199,10 +181,6 @@
assert(type >= MBVERTEX && type <= MBMAXTYPE);
}
-/*
-#define UNPACK_RANGE(buff, rng) {int num_subs; UNPACK_INTS(buff, &num_subs, 1); UPC(num_subs, "-subranged range"); MBEntityHandle _eh[2]; \
- for (int i = 0; i < num_subs; i++) { UNPACK_EH(buff, _eh, 2); rng.insert(_eh[0], _eh[1]);}}
-*/
static inline
void UNPACK_RANGE( unsigned char*& buff, MBRange& rng )
{
@@ -216,14 +194,6 @@
}
}
-/*
-#define CHECK_BUFF_SPACE(buff_vec, buff_ptr, addl_space) { \
- unsigned int _old_size = buff_ptr - &buff_vec[0], \
- _new_size = _old_size + (addl_space); \
- if (_new_size > buff_vec.size()) { \
- buff_vec.resize(1.5*_new_size); \
- buff_ptr = &buff_vec[_new_size-(addl_space)];} }
-*/
template <typename T> static inline
void CHECK_BUFF_SPACE( std::vector<T>& buff_vec,
T*& buff_ptr,
@@ -237,11 +207,6 @@
}
}
-/*
-#define INIT_BUFFER(_buff_vec, _buff_ptr) \
- _buff_vec.reserve(INITIAL_BUFF_SIZE); _buff_vec.resize(sizeof(int)); \
- _buff_ptr = &_buff_vec[sizeof(int)]
-*/
template<typename T> static inline
void INIT_BUFFER(std::vector<T>& buff_vec, T*& buff_ptr)
{
@@ -251,7 +216,6 @@
}
-//#define RANGE_SIZE(rng) (2*sizeof(MBEntityHandle)*num_subranges(rng)+sizeof(int))
static inline size_t RANGE_SIZE(const MBRange& rng)
{ return 2*sizeof(MBEntityHandle)*rng.psize()+sizeof(int); }
@@ -898,7 +862,8 @@
RRA("Failed to build sharedhps.");
// now pack them
- CHECK_BUFF_SPACE(buff, buff_ptr, (num_ents+1)*sizeof(int) + sizeof(MBEntityHandle));
+ CHECK_BUFF_SPACE(buff, buff_ptr, (num_ents+1)*sizeof(int) +
+ num_ents*sizeof(MBEntityHandle));
PACK_INT(buff_ptr, num_ents);
PACK_INTS(buff_ptr, tmp_procs, num_ents);
PACK_EH(buff_ptr, tmp_handles, num_ents);
@@ -1036,7 +1001,9 @@
num_ents = 1;
}
+#ifndef NDEBUG
int tmp_ps = num_ents;
+#endif
// now add others, with zero handle for now
for (std::set<unsigned int>::iterator sit = entprocs.begin();
@@ -1330,7 +1297,7 @@
// procs the sending proc is telling me I'll be receiving from
std::set<unsigned int> comm_procs;
-
+
// 1. # entities = E
int num_ents;
unsigned char *buff_save = buff_ptr;
@@ -1539,81 +1506,115 @@
return MB_SUCCESS;
}
-MBErrorCode MBParallelComm::print_buffer(unsigned char *buff_ptr)
+MBErrorCode MBParallelComm::print_buffer(unsigned char *buff_ptr, int mesg_tag,
+ int from_proc, bool sent)
{
- int total_size;
- UNPACK_INT(buff_ptr, total_size);
- std::cout << total_size << " entities..." << std::endl;
+ std::cout << procConfig.proc_rank();
+ if (sent) std::cout << " sent";
+ else std::cout << " received";
+ std::cout << " message type " << mesg_tag
+ << " to/from proc " << from_proc << "; contents:" << std::endl;
- // 1. # entities = E
- int num_ents;
- int i, j, k;
- std::vector<int> ps;
- std::vector<MBEntityHandle> hs;
+ if (MB_MESG_ENTS == mesg_tag) {
+ int total_size;
+ UNPACK_INT(buff_ptr, total_size);
+ std::cout << total_size << " entities..." << std::endl;
- UNPACK_INT(buff_ptr, num_ents);
- std::cout << num_ents << " entities..." << std::endl;
+ // 1. # entities = E
+ int num_ents;
+ int i, j, k;
+ std::vector<int> ps;
+ std::vector<MBEntityHandle> hs;
- // save place where remote handle info starts, then scan forward to ents
- for (i = 0; i < num_ents; i++) {
- UNPACK_INT(buff_ptr, j);
- ps.resize(j);
- hs.resize(j);
- std::cout << "Entity " << i << ": # procs = " << j << std::endl;
- UNPACK_INTS(buff_ptr, &ps[0], j);
- UNPACK_EH(buff_ptr, &hs[0], j);
- std::cout << " Procs: ";
- for (k = 0; k < j; k++) std::cout << ps[k] << " ";
- std::cout << std::endl;
- std::cout << " Handles: ";
- for (k = 0; k < j; k++) std::cout << hs[k] << " ";
- std::cout << std::endl;
- }
+ UNPACK_INT(buff_ptr, num_ents);
+ std::cout << num_ents << " entities..." << std::endl;
+
+ // save place where remote handle info starts, then scan forward to ents
+ for (i = 0; i < num_ents; i++) {
+ UNPACK_INT(buff_ptr, j);
+ ps.resize(j);
+ hs.resize(j);
+ std::cout << "Entity " << i << ": # procs = " << j << std::endl;
+ UNPACK_INTS(buff_ptr, &ps[0], j);
+ UNPACK_EH(buff_ptr, &hs[0], j);
+ std::cout << " Procs: ";
+ for (k = 0; k < j; k++) std::cout << ps[k] << " ";
+ std::cout << std::endl;
+ std::cout << " Handles: ";
+ for (k = 0; k < j; k++) std::cout << hs[k] << " ";
+ std::cout << std::endl;
+ }
while (true) {
MBEntityType this_type = MBMAXTYPE;
UNPACK_TYPE(buff_ptr, this_type);
assert(this_type != MBENTITYSET);
- // MBMAXTYPE signifies end of entities data
- if (MBMAXTYPE == this_type) break;
+ // MBMAXTYPE signifies end of entities data
+ if (MBMAXTYPE == this_type) break;
- // get the number of ents
- int num_ents2, verts_per_entity;
- UNPACK_INT(buff_ptr, num_ents2);
+ // get the number of ents
+ int num_ents2, verts_per_entity;
+ UNPACK_INT(buff_ptr, num_ents2);
- // unpack the nodes per entity
- if (MBVERTEX != this_type && num_ents2) {
- UNPACK_INT(buff_ptr, verts_per_entity);
- }
+ // unpack the nodes per entity
+ if (MBVERTEX != this_type && num_ents2) {
+ UNPACK_INT(buff_ptr, verts_per_entity);
+ }
- std::cout << "Type: " << MBCN::EntityTypeName(this_type)
- << "; num_ents = " << num_ents2;
- if (MBVERTEX != this_type) std::cout << "; verts_per_ent = " << verts_per_entity;
- std::cout << std::endl;
+ std::cout << "Type: " << MBCN::EntityTypeName(this_type)
+ << "; num_ents = " << num_ents2;
+ if (MBVERTEX != this_type) std::cout << "; verts_per_ent = " << verts_per_entity;
+ std::cout << std::endl;
- for (int e = 0; e < num_ents2; e++) {
- // check for existing entity, otherwise make new one
- MBEntityHandle *connect;
- double *coords;
+ for (int e = 0; e < num_ents2; e++) {
+ // check for existing entity, otherwise make new one
+ MBEntityHandle *connect;
+ double *coords;
- if (MBVERTEX == this_type) {
- coords = (double*) buff_ptr;
- buff_ptr += 3*sizeof(double);
- std::cout << "xyz = " << coords[0] << ", " << coords[1] << ", "
- << coords[2] << std::endl;
- }
- else {
- connect = (MBEntityHandle*) buff_ptr;
- buff_ptr += verts_per_entity * sizeof(MBEntityHandle);
+ if (MBVERTEX == this_type) {
+ coords = (double*) buff_ptr;
+ buff_ptr += 3*sizeof(double);
+ std::cout << "xyz = " << coords[0] << ", " << coords[1] << ", "
+ << coords[2] << std::endl;
+ }
+ else {
+ connect = (MBEntityHandle*) buff_ptr;
+ buff_ptr += verts_per_entity * sizeof(MBEntityHandle);
- // update connectivity to local handles
- std::cout << "Connectivity: ";
- for (k = 0; k < verts_per_entity; k++) std::cout << connect[k] << " ";
- std::cout << std::endl;
+ // update connectivity to local handles
+ std::cout << "Connectivity: ";
+ for (k = 0; k < verts_per_entity; k++) std::cout << connect[k] << " ";
+ std::cout << std::endl;
+ }
}
}
}
+
+ else if (MB_MESG_REMOTE_HANDLES) {
+ int num_ents;
+ UNPACK_INT(buff_ptr, num_ents);
+ std::vector<MBEntityHandle> L1hloc(num_ents), L1hrem(num_ents);
+ std::vector<int> L1p(num_ents);
+ UNPACK_INTS(buff_ptr, &L1p[0], num_ents);
+ UNPACK_EH(buff_ptr, &L1hrem[0], num_ents);
+ UNPACK_EH(buff_ptr, &L1hloc[0], num_ents);
+ std::cout << num_ents << " Entity pairs; hremote/hlocal/proc: " << std::endl;
+ for (int i = 0; i < num_ents; i++) {
+ MBEntityType etype = TYPE_FROM_HANDLE(L1hloc[i]);
+ std::cout << MBCN::EntityTypeName(etype) << ID_FROM_HANDLE(L1hrem[i]) << ", "
+ << MBCN::EntityTypeName(etype) << ID_FROM_HANDLE(L1hloc[i]) << ", "
+ << L1p[i] << std::endl;
+ }
+ }
+ else if (MB_MESG_TAGS) {
+ assert(false);
+ return MB_FAILURE;
+ }
+ else {
+ assert(false);
+ return MB_FAILURE;
+ }
return MB_SUCCESS;
}
@@ -1803,8 +1804,8 @@
// set sharing tags
if (num_exist > 2) {
- std::fill(tag_ps+num_exist, tag_ps+MAX_SHARING_PROCS-num_exist, -1);
- std::fill(tag_hs+num_exist, tag_hs+MAX_SHARING_PROCS-num_exist, 0);
+ std::fill(tag_ps+num_exist, tag_ps+MAX_SHARING_PROCS, -1);
+ std::fill(tag_hs+num_exist, tag_hs+MAX_SHARING_PROCS, 0);
result = mbImpl->tag_set_data(sharedps_tag(), &new_h, 1, tag_ps);
RRA("Couldn't set sharedps tag.");
result = mbImpl->tag_set_data(sharedhs_tag(), &new_h, 1, tag_hs);
@@ -2698,7 +2699,14 @@
result = mbImpl->get_dimension(shared_dim);
RRA("Couldn't get dimension.");
}
- else shared_dim = mbImpl->dimension_from_handle(*proc_ents.begin())-1;
+ else if (!proc_ents.empty())
+ shared_dim = mbImpl->dimension_from_handle(*proc_ents.begin())-1;
+ else if (resolve_dim == 3)
+ shared_dim = 2;
+ else {
+ assert(false && "Unable to guess shared_dim.");
+ return MB_FAILURE;
+ }
}
assert(shared_dim >= 0 && resolve_dim >= 0);
@@ -2734,7 +2742,7 @@
// zero; don't create them if they don't exist already
for (int this_dim = skin_dim-1; this_dim >= 0; this_dim--) {
result = mbImpl->get_adjacencies(skin_ents[skin_dim], this_dim,
- false, skin_ents[this_dim],
+ true, skin_ents[this_dim],
MBInterface::UNION);
RRA("Failed getting skin adjacencies.");
}
@@ -3746,6 +3754,10 @@
&entprocs, &allsent);
RRA("Packing entities failed.");
+#ifdef DEBUG_MSGS
+ result = print_buffer(&ownerSBuffs[ind][0], MB_MESG_ENTS, *proc_it, true);
+#endif
+
// send the buffer (buffer size saved in send_buffer)
result = send_buffer(*proc_it, &ownerSBuffs[ind][0],
buff_ptr-&ownerSBuffs[ind][0], MB_MESG_ENTS,
@@ -3799,10 +3811,17 @@
if (done) {
unsigned char *buff_ptr = &ghostRBuffs[ind][sizeof(int)];
+#ifdef DEBUG_MSGS
+ print_buffer(buff_ptr-sizeof(int), MB_MESG_ENTS, buffProcs[ind], false);
+#endif
result = unpack_entities(buff_ptr,
store_remote_handles, ind, is_iface,
L1hloc, L1hrem, L1p, L2hloc, L2hrem, L2p, new_ents);
RRA("Failed to unpack entities.");
+
+ if (recv_reqs.size() != buffProcs.size()) {
+ recv_reqs.resize(buffProcs.size(), MPI_REQUEST_NULL);
+ }
}
else {
num_incoming++;
@@ -3890,6 +3909,10 @@
result = pack_remote_handles(L1hloc[ind], L1hrem[ind], L1p[ind], *proc_it,
ownerSBuffs[ind], buff_ptr);
RRA("Failed to pack remote handles.");
+
+#ifdef DEBUG_MSGS
+ print_buffer(&ownerSBuffs[ind][0], MB_MESG_REMOTE_HANDLES, buffProcs[ind], true);
+#endif
result = send_buffer(buffProcs[ind], &ownerSBuffs[ind][0],
buff_ptr - &ownerSBuffs[ind][0],
MB_MESG_REMOTE_HANDLES,
@@ -3932,6 +3955,9 @@
if (done) {
// incoming remote handles
buff_ptr = &ghostRBuffs[ind][sizeof(int)];
+#ifdef DEBUG_MSGS
+ print_buffer(buff_ptr, MB_MESG_REMOTE_HANDLES, buffProcs[ind], false);
+#endif
result = unpack_remote_handles(buffProcs[ind], buff_ptr,
L2hloc, L2hrem, L2p);
RRA("Failed to unpack remote handles.");
@@ -5481,6 +5507,8 @@
unsigned char pstat;
rval = get_sharing_data( *i, ent_procs, handles, pstat, num_sharing );
+ if (MB_SUCCESS != rval)
+ return rval;
for (int j = 0; j < num_sharing; ++j) {
if (ent_procs[j] == (int)proc_config().proc_rank())
continue;
Modified: MOAB/trunk/parallel/MBParallelComm.hpp
===================================================================
--- MOAB/trunk/parallel/MBParallelComm.hpp 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/parallel/MBParallelComm.hpp 2009-10-29 18:49:24 UTC (rev 3250)
@@ -285,7 +285,7 @@
int resolve_dim = 3,
int shared_dim = -1,
const MBTag* id_tag = 0);
-
+
static MBErrorCode resolve_shared_ents(MBParallelComm **pc,
const unsigned int np,
const int to_dim);
@@ -704,7 +704,8 @@
std::vector<unsigned char> &buff,
unsigned char *&buff_ptr);
- MBErrorCode print_buffer(unsigned char *buff_ptr);
+ MBErrorCode print_buffer(unsigned char *buff_ptr, int mesg_type, int from_proc,
+ bool sent);
//! for all the entities in the received buffer; for each, save
//! entities in this instance which match connectivity, or zero if none found
Modified: MOAB/trunk/parallel/Makefile.am
===================================================================
--- MOAB/trunk/parallel/Makefile.am 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/parallel/Makefile.am 2009-10-29 18:49:24 UTC (rev 3250)
@@ -45,7 +45,7 @@
ReadParallel.hpp \
crystal.h errmem.h types.h
- MOAB_PARALLEL_TEST += pcomm_unit parallel_unit_tests
+ MOAB_PARALLEL_TEST += pcomm_unit parallel_unit_tests uber_parallel_test scdtest
if PARALLEL_HDF5
# libMOABpar_la_LIBADD = $(top_builddir)/mhdf/libmhdf.la
@@ -85,8 +85,13 @@
parallel_unit_tests_LDADD = ../libMOAB.la
parallel_write_test_SOURCES = parallel_write_test.cc
parallel_write_test_LDADD = ../libMOAB.la
+uber_parallel_test_SOURCES = uber_parallel_test.cpp
+uber_parallel_test_LDADD = ../libMOAB.la
+scdtest_SOURCES = scdtest.cpp
+scdtest_LDADD = ../libMOAB.la
+
# Other files to clean up (e.g. output from tests)
MOSTLYCLEANFILES = mhdf_ll.h5m
Modified: MOAB/trunk/parallel/mbparallelcomm_test.cpp
===================================================================
--- MOAB/trunk/parallel/mbparallelcomm_test.cpp 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/parallel/mbparallelcomm_test.cpp 2009-10-29 18:49:24 UTC (rev 3250)
@@ -36,7 +36,7 @@
#define RRA(a) if (MB_SUCCESS != result) {\
std::string tmp_str; mbImpl->get_last_error(tmp_str);\
tmp_str.append("\n"); tmp_str.append(a);\
- dynamic_cast<MBCore*>(mbImpl)->get_error_handler()->set_last_error(tmp_str.c_str()); \
+ dynamic_cast<MBCore*>(mbImpl)->get_error_handler()->set_last_error(tmp_str); \
return result;}
MBErrorCode create_linear_mesh(MBInterface *mbImpl,
@@ -69,7 +69,7 @@
err = MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// start time
- double stime, rtime, setime, dtime, ltime;
+ double stime, rtime, dtime, ltime;
if (0 == rank) stime = MPI_Wtime();
// create MOAB instance based on that
@@ -202,12 +202,12 @@
if (0 == rank) std::cout << "Times: "
<< dtime-stime << " "
<< rtime-stime << " "
- << setime-rtime << " "
- << ltime-setime << " "
<< dtime - ltime
- << " (total/read/shared/report/delete)"
+ << " (total/read/delete)"
<< std::endl;
-
+
+ delete mbImpl;
+
return (MB_SUCCESS == result ? 0 : 1);
}
Modified: MOAB/trunk/parallel/scdtest.cpp
===================================================================
--- MOAB/trunk/parallel/scdtest.cpp 2009-10-28 21:26:24 UTC (rev 3249)
+++ MOAB/trunk/parallel/scdtest.cpp 2009-10-29 18:49:24 UTC (rev 3250)
@@ -13,11 +13,11 @@
using namespace std;
// Number of cells in each direction:
-const int NC = 4;
+const int NC = 2;
-const int MNI = 5;
-const int MNJ = 10;
-const int MNK = 10;
+const int NI = 2;
+const int NJ = 2;
+const int NK = 1;
// Number of processes:
const int NPROCS = 4;
@@ -66,56 +66,52 @@
void set_local_domain_bounds()
{
- switch(rank) {
- case 0:
-
- switch (size) {
+ switch (size) {
case 2:
- is = 0; ie = NC/2;
- js = 0; je = NC;
- ks = 0; ke = NC;
- break;
+ switch(rank) {
+ case 0:
+ is = 0; ie = NI/2;
+ js = 0; je = NJ;
+ ks = 0; ke = NK;
+ break;
- case 4:
- is = 0; ie = NC/2;
- js = 0; je = NC/2;
- ks = 0; ke = NC;
- break;
- }
- break;
- case 1:
-
- switch(size) {
- case 2:
- is = NC/2; ie = NC;
- js = 0; je = NC;
- ks = 0; ke = NC;
- break;
-
+ case 1:
+ is = NI/2; ie = NI;
+ js = 0; je = NJ;
+ ks = 0; ke = NK;
+ break;
+ }
+ break;
+
case 4:
- is = NC/2; ie = NC;
- js = 0; je = NC/2;
- ks = 0; ke = NC;
- break;
- }
- break;
+ switch(rank) {
+ case 0:
+ is = 0; ie = NI/2;
+ js = 0; je = NJ/2;
+ ks = 0; ke = NK;
+ break;
+ case 1:
+ is = NI/2; ie = NI;
+ js = 0; je = NJ/2;
+ ks = 0; ke = NK;
+ break;
+ case 2:
+ is = 0; ie = NI/2;
+ js = NJ/2; je = NJ;
+ ks = 0; ke = NK;
+ break;
+ case 3:
+ is = NI/2; ie = NI;
+ js = NJ/2; je = NJ;
+ ks = 0; ke = NK;
+ break;
+ }
+ break;
- case 2:
- is = 0; ie = NC/2;
- js = NC/2; je = NC;
- ks = 0; ke = NC;
- break;
-
- case 3:
- is = NC/2; ie = NC;
- js = NC/2; je = NC;
- ks = 0; ke = NC;
- break;
-
- default:
- cerr << "Run this with 4 processes\n";
- exit(1);
+ default:
+ cerr << "Run this with 4 processes\n";
+ exit(1);
}
}
@@ -124,7 +120,7 @@
{
MBCore *mbcore = dynamic_cast<MBCore*>(mbint);
HomCoord coord_min(0,0,0);
- HomCoord coord_max(NC/2, NC, NC);
+ HomCoord coord_max(ie-is, je-js, ke-ks);
EntitySequence* vertex_seq = NULL;
EntitySequence* cell_seq = NULL;
MBEntityHandle vs, cs;
@@ -133,8 +129,8 @@
error(mbcore->create_scd_sequence(coord_min, coord_max, MBHEX, 1, cs, cell_seq));
HomCoord p1(0,0,0);
- HomCoord p2(NC/2,0,0);
- HomCoord p3(0,NC/2,0);
+ HomCoord p2(1,0,0);
+ HomCoord p3(0,1,0);
error(mbcore->add_vsequence(vertex_seq, cell_seq, p1, p1, p2, p2, p3, p3));
@@ -147,22 +143,22 @@
MBErrorCode err;
- for(i = is; i < ie + 1; i++)
+ for(k = ks; k < ke + 1; k++)
for(j = js; j < je + 1; j++)
- for(k = ks; k < ke + 1; k++) {
- gid = k + j*(NC+1) + i*(NC+1)*(NC+1) + 1;
+ for(i = is; i < ie + 1; i++) {
+ gid = 1 + i + j*(NI+1) + k*(NI+1)*(NJ+1);
err = mbint->tag_set_data(global_id_tag, &handle, 1, &gid);
- if(err != MB_SUCCESS) {
- exit(1);
- }
- handle++;
+ if(err != MB_SUCCESS) {
+ exit(1);
+ }
+ handle++;
}
handle = cs;
- for(i = is; i < ie; i++)
+ for(k = ks; k < ke; k++)
for(j = js; j < je; j++)
- for(k = ks; k < ke; k++) {
- gid = k + j*NC + i*NC*NC + 1;
+ for(i = is; i < ie; i++) {
+ gid = 1 + i + j*NI + k*NI*NJ;
error(mbint->tag_set_data(global_id_tag, &handle, 1, &gid));
handle++;
}
@@ -172,7 +168,6 @@
void resolve_and_exchange()
{
MBEntityHandle entity_set;
- MBErrorCode err;
// Create the entity set:
error(mbint->create_meshset(MESHSET_SET, entity_set));
More information about the moab-dev
mailing list