From: abn Date: Wed, 4 May 2016 15:27:56 +0000 (+0200) Subject: ParaMEDMEM::DisjointDEC - Added more tests (IDs and procs groups X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0ff0db3b6a0cfe0ac9eb8bb4f26b6a1035c669e;p=tools%2Fmedcoupling.git ParaMEDMEM::DisjointDEC - Added more tests (IDs and procs groups in constructor) + method to check group consistency. --- diff --git a/src/ParaMEDMEM/DisjointDEC.cxx b/src/ParaMEDMEM/DisjointDEC.cxx index 0ed91beae..f00fb88b7 100644 --- a/src/ParaMEDMEM/DisjointDEC.cxx +++ b/src/ParaMEDMEM/DisjointDEC.cxx @@ -73,6 +73,7 @@ namespace ParaMEDMEM _owns_groups(false), _union_comm(MPI_COMM_NULL) { + checkPartitionGroup(); _union_group = source_group.fuse(target_group); } @@ -218,6 +219,28 @@ namespace ParaMEDMEM _comm_interface->commFree(&_union_comm); } + /** + * Check that the sources and targets procs form a partition of the world communicator referenced in the groups. + * This world communicator is not necessarily MPI_WORLD_COMM, but it has to be covered completly for the DECs to work. + */ + void DisjointDEC::checkPartitionGroup() const + { + int size = -1; + MPIProcessorGroup * tgt = static_cast(_target_group); + MPIProcessorGroup * src = static_cast(_source_group); + MPI_Comm comm_t = tgt->getWorldComm(); + MPI_Comm comm_s = src->getWorldComm(); + if (comm_t != comm_s) + throw INTERP_KERNEL::Exception("DisjointDEC constructor: Inconsistent world communicator when building DisjointDEC"); + MPI_Comm_size(comm_t, &size); + + std::set union_ids; // source and target ids in world_comm + union_ids.insert(src->getProcIDs().begin(),src->getProcIDs().end()); + union_ids.insert(tgt->getProcIDs().begin(),tgt->getProcIDs().end()); + if(union_ids.size()!=size) + throw INTERP_KERNEL::Exception("DisjointDEC constructor: source_ids and target_ids do not form a partition of the communicator! Restrain the world communicator passed to MPIProcessorGroup ctor."); + } + void DisjointDEC::setNature(NatureOfField nature) { if(_local_field) diff --git a/src/ParaMEDMEM/DisjointDEC.hxx b/src/ParaMEDMEM/DisjointDEC.hxx index 8d47d285e..8f4eed289 100644 --- a/src/ParaMEDMEM/DisjointDEC.hxx +++ b/src/ParaMEDMEM/DisjointDEC.hxx @@ -74,6 +74,7 @@ namespace ParaMEDMEM void compareFieldAndMethod() const throw(INTERP_KERNEL::Exception); void cleanInstance(); void copyInstance(const DisjointDEC& other); + void checkPartitionGroup() const; protected: const ParaFIELD* _local_field; //! Processor group representing the union of target and source processors diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx index 98454b701..561462ddb 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx @@ -77,8 +77,9 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testICoco1); // 2 procs CPPUNIT_TEST(testGauthier1); // 4 procs CPPUNIT_TEST(testGauthier2); // >= 2 procs - CPPUNIT_TEST(testGauthier3); // 4 procs - CPPUNIT_TEST(testGauthier3_bis); // 4 procs + CPPUNIT_TEST(testGauthier3_1); // 4 procs + CPPUNIT_TEST(testGauthier3_2); // 4 procs + CPPUNIT_TEST(testGauthier3_3); // 5 procs CPPUNIT_TEST(testGauthier4); // 3 procs CPPUNIT_TEST(testFabienAPI1); // 3 procs CPPUNIT_TEST(testFabienAPI2); // 3 procs @@ -138,8 +139,9 @@ public: void testICoco1(); void testGauthier1(); void testGauthier2(); - void testGauthier3(); - void testGauthier3_bis(); + void testGauthier3_1(); + void testGauthier3_2(); + void testGauthier3_3(); void testGauthier4(); void testFabienAPI1(); void testFabienAPI2(); @@ -161,7 +163,7 @@ private: void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth); void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth); void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth); - void testGauthier3_GEN(bool); + void testGauthier3_GEN(bool, int); }; // to automatically remove temporary files from disk diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx index a0174a91a..4cdf40c09 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx @@ -356,42 +356,53 @@ void ParaMEDMEMTest::testGauthier2() } } -void ParaMEDMEMTest::testGauthier3() +void ParaMEDMEMTest::testGauthier3_1() { - testGauthier3_GEN(true); + testGauthier3_GEN(true,4); } -void ParaMEDMEMTest::testGauthier3_bis() +void ParaMEDMEMTest::testGauthier3_2() { - testGauthier3_GEN(false); + testGauthier3_GEN(false,4); } +void ParaMEDMEMTest::testGauthier3_3() +{ + testGauthier3_GEN(true,5); +} + +//void ParaMEDMEMTest::testGauthier3_4() +//{ +// testGauthier3_GEN(false,5); +//} + + /*! * Non regression test testing copy constructor of InterpKernelDEC. */ -void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) +void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs, int nprocs) { int num_cas=0; int rank, size; MPI_Comm_rank(MPI_COMM_WORLD,&rank); MPI_Comm_size(MPI_COMM_WORLD,&size); - + int is_master=0; CommInterface comm; set emetteur_ids; set recepteur_ids; emetteur_ids.insert(0); - if(size!=4) + if(size!=nprocs) return; recepteur_ids.insert(1); - if (size >2) - recepteur_ids.insert(2); - if (size >2) - emetteur_ids.insert(3); - if ((rank==0)||(rank==1)) + + recepteur_ids.insert(size-2); + + emetteur_ids.insert(size-1); + if ((rank==0)||(rank==1)) is_master=1; - + MPIProcessorGroup recepteur_group(comm,recepteur_ids); MPIProcessorGroup emetteur_group(comm,emetteur_ids); @@ -404,10 +415,14 @@ void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) } else { - cas="emetteur"; + if (emetteur_group.containsMyRank()) + cas="emetteur"; + else + cas="vide"; // freopen("emetteur.out","w",stdout); //freopen("emetteur.err","w",stderr); } + double expected[8][4]={ {1.,1.,1.,1.}, {40., 40., 1., 1.}, @@ -419,13 +434,15 @@ void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) {20.5,1.,1e200,1e200} }; int expectedLgth[8]={4,4,2,2,4,4,2,2}; - + for (int send=0;send<2;send++) for (int rec=0;rec<2;rec++) { std::vector decu(1); -// decu[0]=InterpKernelDEC(emetteur_group,recepteur_group); - decu[0]=InterpKernelDEC(emetteur_ids,recepteur_ids); + if (withIDs) + decu[0] = InterpKernelDEC(emetteur_ids,recepteur_ids); + else + decu[0] = InterpKernelDEC(emetteur_group,recepteur_group); InterpKernelDEC& dec_emetteur=decu[0]; ParaMEDMEM::ParaFIELD *champ_emetteur(0),*champ_recepteur(0); ParaMEDMEM::ParaMESH *paramesh(0); @@ -439,29 +456,31 @@ void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) { mesh=init_triangleGauthier1(is_master); } - paramesh=new ParaMEDMEM::ParaMESH(mesh,recepteur_group.containsMyRank()?recepteur_group:emetteur_group,"emetteur mesh"); - ParaMEDMEM::ComponentTopology comptopo; - champ_emetteur=new ParaMEDMEM::ParaFIELD(ON_CELLS,ONE_TIME,paramesh,comptopo); - champ_emetteur->getField()->setNature(ConservativeVolumic); - champ_emetteur->setOwnSupport(true); - if (rec==0) - { - mesh=init_triangleGauthier1(is_master); - } - else - { - mesh=init_quadGauthier1(is_master); - } - paramesh=new ParaMEDMEM::ParaMESH(mesh,recepteur_group.containsMyRank()?recepteur_group:emetteur_group,"recepteur mesh"); - champ_recepteur=new ParaMEDMEM::ParaFIELD(ON_CELLS,ONE_TIME,paramesh,comptopo); - champ_recepteur->getField()->setNature(ConservativeVolumic); - champ_recepteur->setOwnSupport(true); - if (cas=="emetteur") + if (cas!="vide") { - champ_emetteur->getField()->getArray()->fillWithValue(1.); + paramesh=new ParaMEDMEM::ParaMESH(mesh,recepteur_group.containsMyRank()?recepteur_group:emetteur_group,"emetteur mesh"); + ParaMEDMEM::ComponentTopology comptopo; + champ_emetteur=new ParaMEDMEM::ParaFIELD(ON_CELLS,ONE_TIME,paramesh,comptopo); + champ_emetteur->getField()->setNature(ConservativeVolumic); + champ_emetteur->setOwnSupport(true); + if (rec==0) + { + mesh=init_triangleGauthier1(is_master); + } + else + { + mesh=init_quadGauthier1(is_master); + } + paramesh=new ParaMEDMEM::ParaMESH(mesh,recepteur_group.containsMyRank()?recepteur_group:emetteur_group,"recepteur mesh"); + champ_recepteur=new ParaMEDMEM::ParaFIELD(ON_CELLS,ONE_TIME,paramesh,comptopo); + champ_recepteur->getField()->setNature(ConservativeVolumic); + champ_recepteur->setOwnSupport(true); + if (cas=="emetteur") + { + champ_emetteur->getField()->getArray()->fillWithValue(1.); + } } - - + MPI_Barrier(MPI_COMM_WORLD); //clock_t clock0= clock (); @@ -471,50 +490,50 @@ void ParaMEDMEMTest::testGauthier3_GEN(bool withIDs) bool stop=false; //boucle sur les pas de quads while (!stop) { - - compti++; - //clock_t clocki= clock (); - //cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; - for (int non_unif=0;non_unif<2;non_unif++) - { - if (cas=="emetteur") - { - if (non_unif) - if(rank!=3) - champ_emetteur->getField()->getArray()->setIJ(0,0,40); - } - //bool ok=false; // Is the time interval successfully solved ? - - // Loop on the time interval tries - if(1) { - + compti++; + //clock_t clocki= clock (); + //cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; + for (int non_unif=0;non_unif<2;non_unif++) + { if (cas=="emetteur") - dec_emetteur.attachLocalField(champ_emetteur); - else - dec_emetteur.attachLocalField(champ_recepteur); - - - if(init) dec_emetteur.synchronize(); - init=false; - - if (cas=="emetteur") { - // affiche(champ_emetteur); - dec_emetteur.sendData(); - } - else if (cas=="recepteur") { - dec_emetteur.recvData(); - if (is_master) - afficheGauthier1(*champ_recepteur,expected[num_cas],expectedLgth[num_cas]); + if (non_unif) + if(rank!=3) + champ_emetteur->getField()->getArray()->setIJ(0,0,40); } - else - throw 0; - MPI_Barrier(MPI_COMM_WORLD); + //bool ok=false; // Is the time interval successfully solved ? + + // Loop on the time interval tries + if(1) { + + + if (cas=="emetteur") + dec_emetteur.attachLocalField(champ_emetteur); + else + dec_emetteur.attachLocalField(champ_recepteur); + + + if(init) dec_emetteur.synchronize(); + init=false; + + if (cas=="emetteur") { + // affiche(champ_emetteur); + dec_emetteur.sendData(); + } + else if (cas=="recepteur") + { + dec_emetteur.recvData(); + if (is_master) + afficheGauthier1(*champ_recepteur,expected[num_cas],expectedLgth[num_cas]); + } + // else + // throw 0; + MPI_Barrier(MPI_COMM_WORLD); + } + stop=true; + num_cas++; } - stop=true; - num_cas++; - } } delete champ_emetteur; delete champ_recepteur;