11 #define BOOST_TEST_DYN_LINK
12 #define BOOST_TEST_MODULE "Test module for cf3::common 's parallel environment - part of testing the commpattern."
16 #include <boost/test/unit_test.hpp>
17 #include <boost/shared_ptr.hpp>
18 #include <boost/weak_ptr.hpp>
44 m_argc = boost::unit_test::framework::master_test_suite().argc;
45 m_argv = boost::unit_test::framework::master_test_suite().argv;
61 for (
Uint i=0; i<nproc; i++)
63 rank[0*nproc+1*i+0]=i;
64 gid[ 0*nproc+1*i+0]=(6*nproc-1)-(6*i+0);
66 for (
Uint i=0; i<nproc; i++)
68 rank[1*nproc+2*i+0]=i;
69 rank[1*nproc+2*i+1]=i;
70 gid[ 1*nproc+2*i+0]=(6*nproc-1)-(6*i+1);
71 gid[ 1*nproc+2*i+1]=(6*nproc-1)-(6*i+2);
73 for (
Uint i=0; i<nproc; i++)
75 rank[3*nproc+3*i+0]=i;
76 rank[3*nproc+3*i+1]=i;
77 rank[3*nproc+3*i+2]=i;
78 gid[ 3*nproc+3*i+0]=(6*nproc-1)-(6*i+3);
79 gid[ 3*nproc+3*i+1]=(6*nproc-1)-(6*i+4);
80 gid[ 3*nproc+3*i+2]=(6*nproc-1)-(6*i+5);
99 CFinfo.setFilterRankZero(
false);
107 boost::shared_ptr<CommPattern> pecp_ptr = allocate_component<CommPattern>(
"CommPattern");
109 BOOST_CHECK_EQUAL( pecp.isUpToDate() , false );
111 boost::shared_ptr< std::vector<double> > d1(
new std::vector<double>(32) );
112 boost::shared_ptr< std::vector<double> > d2(
new std::vector<double>(24) );
115 pecp.insert<
double>(
"VectorWeakPtr1",*d1,2,
true);
116 pecp.insert<
double>(
"VectorWeakPtr2",*d2,3,
true);
119 boost::shared_ptr<Component> dir1 ( allocate_component<Group> (
"dir1" ) );
120 boost::shared_ptr<Component> dir2 ( allocate_component<Group> (
"dir2" ) );
121 pecp.add_component( dir1 );
122 pecp.add_component( dir2 );
125 BOOST_CHECK_EQUAL( pecp.count_children() , 4u );
131 BOOST_FOREACH(
CommWrapper& pobj, find_components_recursively<CommWrapper>(pecp) )
133 BOOST_CHECK_EQUAL( pobj.
type_name() ,
"CommWrapper" );
134 BOOST_CHECK_EQUAL( pobj.
size_of() ,
static_cast<int>(
sizeof(double)) );
135 if (pobj.
name()==
"VectorWeakPtr1"){
136 BOOST_CHECK_EQUAL( pobj.
size() , 16 );
137 BOOST_CHECK_EQUAL( pobj.
stride() , 2 );
139 if (pobj.
name()==
"VectorWeakPtr2"){
140 BOOST_CHECK_EQUAL( pobj.
size() , 8 );
141 BOOST_CHECK_EQUAL( pobj.
stride() , 3 );
166 boost::shared_ptr<CommPattern> pecp_ptr = allocate_component<CommPattern>(
"CommPattern");
170 std::vector<Uint> gid;
171 std::vector<Uint> rank;
172 setupGidAndRank(gid,rank);
174 const bool to_synchronize=
false;
175 pecp.insert(
"gid",gid,stride,to_synchronize);
179 for(
int i=0;i<6*nproc;i++) v1.push_back(-((irank+1)*1000+i+1));
180 pecp.insert(
"v1",v1,1,
true);
181 std::vector<double> v2;
182 for(
int i=0;i<12*nproc;i++) v2.push_back((
double)((irank+1)*1000+i+1));
183 pecp.insert(
"v2",v2,2,
true);
194 pecp.synchronize_all();
204 for (i=0; i< nproc; i++, idx++ ) BOOST_CHECK_EQUAL( v1[i], (
int)(-((((i-0*nproc)/1)+1)*1000+idx+1)) );
205 for ( ; i<3*nproc; i++, idx++ ) BOOST_CHECK_EQUAL( v1[i], (
int)(-((((i-1*nproc)/2)+1)*1000+idx+1)) );
206 for ( ; i<6*nproc; i++, idx++ ) BOOST_CHECK_EQUAL( v1[i], (
int)(-((((i-3*nproc)/3)+1)*1000+idx+1)) );
208 for (i=0; i< 2*nproc; i++, idx++) BOOST_CHECK_EQUAL( v2[i], (
double)((((i-0*nproc)/2)+1)*1000+idx+1) );
209 for ( ; i< 6*nproc; i++, idx++) BOOST_CHECK_EQUAL( v2[i], (
double)((((i-2*nproc)/4)+1)*1000+idx+1) );
210 for ( ; i<12*nproc; i++, idx++) BOOST_CHECK_EQUAL( v2[i], (
double)((((i-6*nproc)/6)+1)*1000+idx+1) );
281 CFinfo.setFilterRankZero(
true);
288 BOOST_AUTO_TEST_SUITE_END()
static std::string type_name()
Get the class name.
#define CFinfo
these are always defined
~CommPatternFixture()
common tear-down for each test case
CommPatternFixture()
common setup for each test case
Safe pointer to an object. This is the supported method for referring to components.
Parallel Communication Pattern. This class provides functionality to collect communication. For efficiency it works such a way that you submit your request via the constructor or the add/remove/move magic triangle and then call setup to modify the commpattern. The data needed to be kept synchronous can be registered via the insert function. The word node here means any kind of "point of storage", in this context it is not directly related with the computational mesh.
const std::string & name() const
Access the name of the component.
Uint rank() const
Return rank, additionally, if is_init==0.
Uint size() const
Return the number of processes, or 1 if is_init==0.
Holds the Component class, as well as the ComponentIterator class plus some functions related to comp...
Base wrapper class serving as interface.
#define PECheckPoint(msec, msg)
#define PEDebugVector(v, length)
virtual int stride() const =0
void setupGidAndRank(std::vector< Uint > &gid, std::vector< Uint > &rank)
function for setting up a gid & rank combo (with size of 6*nproc on each process) ...
void init(int argc=0, char **args=0)
Top-level namespace for coolfluid.
unsigned int Uint
typedef for unsigned int
Classes offering a MPI interface for COOLFluiD.
BOOST_AUTO_TEST_CASE(init)
virtual int size_of() const =0
virtual int size() const =0
static Comm & instance()
Return a reference to the current PE.
Most basic kernel library.
#define PEProcessSortedExecute(irank, expression)