[MOAB-dev] commit/MOAB: danwu: Merged master into error_handling_enhancement
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Feb 20 13:59:01 CST 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/ea42701b91c7/
Changeset: ea42701b91c7
Branch: error_handling_enhancement
User: danwu
Date: 2014-02-20 20:58:57
Summary: Merged master into error_handling_enhancement
Affected #: 6 files
diff --git a/examples/CrystalRouterExample.cpp b/examples/CrystalRouterExample.cpp
index 200f012..83a1e7c 100644
--- a/examples/CrystalRouterExample.cpp
+++ b/examples/CrystalRouterExample.cpp
@@ -18,12 +18,14 @@
*
* the example needs to be launched in parallel.
* Every proc will build a list of tuples, that will be send to a few procs;
+ * In general, we will send to num_comms tasks, and about num_tuples to each task
+ * We vary num_comms and num_tuples for processor
*
- * every proc will send 1 tuple, to proc rank + 1 and rank + rank*(size-1)+2 , with value
- * 10000 * send + 100* rank
+ * we will send long ints of the form
+ * 100000 * send + 1000* rank +j, where j is the index of tuple
*
- * at the receive, we verify we received
- * 10000 * rank + 100 * from
+ * after routing, we verify we received
+ * 100000 * rank + 1000 * from
*
* For some reportrank we also print the tuples.
*
@@ -35,13 +37,20 @@
/** @example CrystalRouterExample.cpp \n
* \brief generalized gather scatter using tuples \n
- * <b>To run</b>: mpiexec -np <n> CrystalRouterExample [reportrank] \n
+ * <b>To run</b>: mpiexec -np <n> CrystalRouterExample -r [reportrank] -t [num_tuples] -n [num_comms] \n
*
*/
//
#include "moab/ProcConfig.hpp"
#include "moab/TupleList.hpp"
+#include "moab/ProgOptions.hpp"
+#include <time.h>
#include <iostream>
+#include <sstream>
+
+const char BRIEF_DESC[] =
+ "Example of gather scatter with tuple lists \n";
+std::ostringstream LONG_DESC;
using namespace moab;
using namespace std;
@@ -50,56 +59,94 @@ int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
- int reportrank = 1;
- if (argc>1)
- reportrank = atoi(argv[1]);
ProcConfig pc(MPI_COMM_WORLD);
int size = pc.proc_size();
int rank = pc.proc_rank();
- if (reportrank==rank)
+ // start copy
+ LONG_DESC << "This program does a gather scatter with a list of tuples. \n"
+ " It tries to see how much communication costs in terms of time and memory. \n"
+ << "It starts with creating a list of tuples to be sent from each processor, \n to a list of other processors.\n" <<
+ "The number of tuples and how many tasks to communicate to are controlled by input parameters.\n" <<
+ "After communication, we verify locally if we received what we expected. \n";
+ ProgOptions opts(LONG_DESC.str(), BRIEF_DESC);
+
+ // how many procs communicate to current proc, on average (we will vary that too)
+ int num_comms = 2;
+ opts.addOpt<int>("num_comms,n",
+ "each task will send to about num_comms other tasks some tuples (default 2)", &num_comms);
+
+ int num_tuples = 4;
+ opts.addOpt<int>("num_tuples,t",
+ "each task will send to some task about num_tuples tuples (default 4)", &num_tuples);
+
+ int reportrank = size+1;
+ opts.addOpt<int>("reporting_rank,r",
+ "this rank will report the tuples sent and the tuples received; it could be higher than num_procs, then no reporting"
+ ,&reportrank);
+
+ opts.parseCommandLine(argc, argv);
+
+
+
+
+ if (rank==reportrank || (reportrank>=size && rank == 0))
{
- std::cout << " there are " << size << " procs in example\n";
+ std::cout << " There are " << size << " tasks in example.\n";
+ std::cout<< " We will send groups of " << num_tuples << " from each task towards " <<
+ num_comms << " other tasks.\n";
}
- // send some data from proc i to i+n/2, also to i +n/2+1 modulo n, wher en is num procs
+
+ // send some data from proc i to i+n/2, also to i +n/2+1 modulo n, where n is num procs
gs_data::crystal_data *cd = pc.crystal_router();
- TupleList tl;
+ long total_n_tuples = num_comms*num_tuples;
- // at most 100 to send
+ // vary the number of tasks to send to, and the number of tuples to send
+ if (rank<size/2)
+ num_comms--;
+ else
+ num_comms++;
+
+ if (rank<size/3)
+ num_tuples*=2;
+ else if (rank>size-size/3)
+ num_tuples/=2;
+
+
+ TupleList tl;
+ // at most num_tuples* num_comms to send
// we do a preallocate with this; some tuples on some processors might need more memory, to be able
- // to grow locally; 100 is a very large number for this example, considering that each task sends only
- // 2 tuples. Some tasks might receive more tuples though, and in the process, some might grow more than
+ // to grow locally; Some tasks might receive more tuples though, and in the process, some might grow more than
// others. By doing these logP sends/receives, we do not grow local memory too much.
- tl.initialize(1, 1, 0, 1, 100);
+ tl.initialize(1, 1, 0, 1, num_tuples*num_comms);
tl.enableWriteAccess();
- // form 2 tuples, send to rank+1 and rank+2 (mod size)
+ // form num_tuples*num_comms tuples, send to various ranks
unsigned int n = tl.get_n();
- int sendTo = rank+1;
- sendTo = sendTo%size;
- long intToSend = 100*rank + 10000*sendTo;
- tl.vi_wr[n]= sendTo;
- tl.vl_wr[n]= intToSend;
- tl.vr_wr[n]= 100.*rank;
- tl.inc_n();
-
- n = tl.get_n();
- sendTo = rank+(rank+1)*rank+2;// just some number relatively different from rank
- sendTo = sendTo%size;
- intToSend = 100*rank + 10000*sendTo;
- tl.vi_wr[n]= sendTo;
- tl.vl_wr[n]= intToSend;
- tl.vr_wr[n]= 1000.*rank;
- tl.inc_n();
-
- if (reportrank==rank)
+ for (int i=0; i<num_comms; i++)
+ {
+ int sendTo = rank+i*size/2+1;// spread out the send to, for a stress-like test
+ sendTo = sendTo%size;//
+ long intToSend = 1000*rank + 100000*sendTo;
+ for (int j=0; j<num_tuples; j++)
+ {
+ n = tl.get_n();
+ tl.vi_wr[n]= sendTo;
+ tl.vl_wr[n]= intToSend+j;
+ tl.vr_wr[n]= 10000.*rank+j;
+ tl.inc_n();
+ }
+ }
+
+ if (rank==reportrank)
{
std::cout << "rank " << rank << "\n";
tl.print(" before sending");
}
- // all communication happens here:
+ clock_t tt = clock();
+ // all communication happens here; no mpi calls for the user
ErrorCode rval = cd->gs_transfer(1,tl,0);
if (MB_SUCCESS!= rval)
@@ -107,23 +154,34 @@ int main(int argc, char **argv)
std::cout << "error in tuple transfer\n";
}
- if (reportrank==rank)
+ double secs=0;
+ if (rank==reportrank || (reportrank>=size && rank == 0))
+ {
+ secs = (clock() - tt) / (double) CLOCKS_PER_SEC;
+ }
+ if (rank==reportrank)
{
std::cout << "rank " << rank << "\n";
tl.print(" after transfer");
}
// check that all tuples received have the form 10000* rank + 100*from
unsigned int received = tl.get_n();
- for (int i=0; i<received; i++)
+ for (int i=0; i<(int)received; i++)
{
int from = tl.vi_rd[i];
long valrec = tl.vl_rd[i];
- int remainder = valrec -10000*rank -100*from;
- if (remainder != 0 )
+ int remainder = valrec -100000*rank -1000*from;
+ if (remainder < 0 || remainder >= num_tuples*4)
std::cout << " error: tuple " << i << " received at proc rank " << rank << " from proc " << from << " has value " <<
valrec << " remainder " << remainder << "\n";
}
+ if (rank==reportrank || (reportrank>=size && rank == 0))
+ {
+ std::cout << "communication of about "<< total_n_tuples << " tuples/per proc took "
+ << secs << " seconds" << std::endl;
+ tt = clock();
+ }
MPI_Finalize();
return 0;
diff --git a/examples/StructuredMeshSimple.cpp b/examples/StructuredMeshSimple.cpp
index bd21dd1..bc80ed8 100644
--- a/examples/StructuredMeshSimple.cpp
+++ b/examples/StructuredMeshSimple.cpp
@@ -17,7 +17,7 @@
* -# Get the coordinates of the vertices comprising that element
* -# Release the structured mesh interface and destroy the MOAB instance
*
- * <b> To run: </b> ./structuredmesh [d [N] ] \n
+ * <b> To run: </b> ./StructuredMeshSimple [d [N] ] \n
* (default values so can run w/ no user interaction)
*/
diff --git a/examples/structuredmesh.cpp b/examples/structuredmesh.cpp
index 5ad42fb..0214c3e 100644
--- a/examples/structuredmesh.cpp
+++ b/examples/structuredmesh.cpp
@@ -28,6 +28,7 @@ using namespace moab;
int main(int argc, char **argv)
{
+ argv[0] = argv[argc - argc]; // To remove the warnings about unused parameters
int I, J, K;
// progoptions?
std::cout << "Enter I, J, K... " << std::endl;
diff --git a/src/io/Tqdcfr.cpp b/src/io/Tqdcfr.cpp
index 2c0317b..76767ea 100644
--- a/src/io/Tqdcfr.cpp
+++ b/src/io/Tqdcfr.cpp
@@ -2321,6 +2321,8 @@ ErrorCode Tqdcfr::read_acis_records( const char* sat_filename )
// get next occurrence of '#' (record terminator)
ret = strchr(&(char_buf[buf_pos]), '#');
+ while (ret && ret+1-&char_buf[0] < bytes_left && *(ret+1) != '\n')
+ ret = strchr(ret+1, '#');
if (NULL != ret) {
// grab the string (inclusive of the record terminator and the line feed) and complete the record
int num_chars = ret-&(char_buf[buf_pos])+2;
@@ -2460,7 +2462,10 @@ ErrorCode Tqdcfr::parse_acis_attribs(const unsigned int entity_rec_num,
}
else if (strncmp(records[current_attrib].att_string.c_str(), "UNIQUE_ID", 9) == 0) {
// parse uid
- num_read = sscanf(records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid);
+ if (major >=14) // change of format for cubit 14:
+ num_read =sscanf(records[current_attrib].att_string.c_str(), "UNIQUE_ID 0 1 %d", &uid);
+ else
+ num_read = sscanf(records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid);
if (1 != num_read) return MB_FAILURE;
}
else if (strncmp(records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID", 29) == 0) {
diff --git a/tools/mbcoupler/Coupler.cpp b/tools/mbcoupler/Coupler.cpp
index 29dbb3d..b496441 100644
--- a/tools/mbcoupler/Coupler.cpp
+++ b/tools/mbcoupler/Coupler.cpp
@@ -113,11 +113,22 @@ ErrorCode Coupler::initialize_tree()
box.bMax.get(&allBoxes[6*my_rank+3]);
// now communicate to get all boxes
- // use "in place" option
if (myPc) {
- int mpi_err = MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
+ int mpi_err;
+#if (MPI_VERSION >= 2)
+ // use "in place" option
+ mpi_err = MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
&allBoxes[0], 6, MPI_DOUBLE,
myPc->proc_config().proc_comm());
+#else
+ {
+ std::vector<double> allBoxes_tmp(6*myPc->proc_config().proc_size());
+ mpi_err = MPI_Allgather( &allBoxes[6*my_rank], 6, MPI_DOUBLE,
+ &allBoxes_tmp[0], 6, MPI_DOUBLE,
+ myPc->proc_config().proc_comm());
+ allBoxes = allBoxes_tmp;
+ }
+#endif
if (MPI_SUCCESS != mpi_err) return MB_FAILURE;
}
diff --git a/tools/mbcslam/Intx2Mesh.cpp b/tools/mbcslam/Intx2Mesh.cpp
index 22fdc3f..9859d00 100644
--- a/tools/mbcslam/Intx2Mesh.cpp
+++ b/tools/mbcslam/Intx2Mesh.cpp
@@ -483,10 +483,21 @@ ErrorCode Intx2Mesh::build_processor_euler_boxes(EntityHandle euler_set, Range &
}
// now communicate to get all boxes
- // use "in place" option
- int mpi_err = MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
- &allBoxes[0], 6, MPI_DOUBLE,
- parcomm->proc_config().proc_comm());
+ int mpi_err;
+#if (MPI_VERSION >= 2)
+ // use "in place" option
+ mpi_err = MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
+ &allBoxes[0], 6, MPI_DOUBLE,
+ parcomm->proc_config().proc_comm());
+#else
+ {
+ std::vector<double> allBoxes_tmp(6*parcomm->proc_config().proc_size());
+ mpi_err = MPI_Allgather( &allBoxes[6*my_rank], 6, MPI_DOUBLE,
+ &allBoxes_tmp[0], 6, MPI_DOUBLE,
+ parcomm->proc_config().proc_comm());
+ allBoxes = allBoxes_tmp;
+ }
+#endif
if (MPI_SUCCESS != mpi_err) return MB_FAILURE;
// also process the max number of vertices per cell (4 for quads, but could be more for polygons)
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list