From: prascle Date: Thu, 27 Jan 2005 18:43:38 +0000 (+0000) Subject: PR: merge some files (MPI) from debug_V2_1_0a2 X-Git-Tag: V2_2_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=627049c0bc747e1fd4f9939323e6b4680c0557d5;p=modules%2Fkernel.git PR: merge some files (MPI) from debug_V2_1_0a2 --- diff --git a/idl/SALOME_MPIContainer.idl b/idl/SALOME_MPIContainer.idl index 8265c7380..c23e1c061 100644 --- a/idl/SALOME_MPIContainer.idl +++ b/idl/SALOME_MPIContainer.idl @@ -34,6 +34,9 @@ module Engines // start MPI container executable MPIContainer start_MPIimpl( in string ContainerName, in short nbproc ); + // shutdown corba server + void MPIShutdown() ; + // asynchronous version to load and remove parallel component in parallel oneway void SPload_impl(in string nameToRegister, in string componentName); oneway void SPremove_impl(in Component component_i); diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index 73e9ffaa0..c190fa2bb 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -44,6 +44,7 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, { MESSAGE("[" << numproc << "] activate object"); _id = _poa->activate_object(this); + this->_add_ref(); if(numproc==0){ @@ -52,8 +53,9 @@ Engines_MPIContainer_i::Engines_MPIContainer_i(int nbproc, int numproc, ASSERT(SINGLETON_::IsAlreadyExisting()) ; _NS->init_orb( orb ) ; - Engines::Container_ptr pCont - = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); +// Engines::Container_ptr pCont +// = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); + Engines::Container_ptr pCont = Engines::Container::_narrow(_poa->id_to_reference(*_id)); SCRUTE(_containerName); _NS->Register(pCont, _containerName.c_str()); } @@ -384,3 +386,18 @@ void Engines_MPIContainer_i::Lfinalize_removal() END_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); } + +// Load component +void Engines_MPIContainer_i::MPIShutdown() +{ + int ip; + MESSAGE("[" << _numproc << "] shutdown of Corba Server"); + if( _numproc == 0 ){ + for(ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown(); + } + + Shutdown(); + +} + diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx index 7d9ddc9a2..a971b7f20 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -56,6 +56,9 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer, // synchronous version for process 0 Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); + // shutdown corba server + void MPIShutdown(); + // asynchronous version for other process void SPload_impl(const char* nameToRegister, const char* componentName); diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index d6fb4474f..52152364e 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -4,6 +4,7 @@ #include "Utils_SINGLETON.hxx" #include "utilities.h" #include +#include "LocalTraceCollector.hxx" using namespace std; int main(int argc, char* argv[]) @@ -12,21 +13,18 @@ int main(int argc, char* argv[]) int flag; Engines_MPIContainer_i * myContainer=NULL; - BEGIN_OF(argv[0]) + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD,&nbproc); + MPI_Comm_rank(MPI_COMM_WORLD,&numproc); + + // Initialise the ORB. + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &orb = init( argc , argv ) ; + LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + + BEGIN_OF("[" << numproc << "] " << argv[0]) try { - MESSAGE("Connection MPI"); - MPI_Init(&argc,&argv); - MPI_Comm_size(MPI_COMM_WORLD,&nbproc); - MPI_Comm_rank(MPI_COMM_WORLD,&numproc); - - MESSAGE("[" << numproc << "] Initialisation CORBA"); - // Initialise the ORB. - // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; - // Obtain a reference to the root POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); @@ -65,7 +63,7 @@ int main(int argc, char* argv[]) containerName = argv[1] ; } - MESSAGE("[" << numproc << "] Chargement container"); + MESSAGE("[" << numproc << "] MPIContainer: load MPIContainer servant"); myContainer = new Engines_MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName,argc,argv); pman->activate(); @@ -96,6 +94,8 @@ int main(int argc, char* argv[]) if(flag) MPI_Finalize(); - END_OF(argv[0]); + END_OF("[" << numproc << "] " << argv[0]); + delete myThreadTrace; + return 0 ; } diff --git a/src/TestMPIContainer/Makefile.in b/src/TestMPIContainer/Makefile.in index 3924ce0e0..b268fd20e 100644 --- a/src/TestMPIContainer/Makefile.in +++ b/src/TestMPIContainer/Makefile.in @@ -31,7 +31,9 @@ BIN_SRC = BIN_CLIENT_IDL = Logger.idl SALOME_MPIObject.idl SALOME_MPIContainer.idl SALOME_TestMPIComponent.idl BIN_SERVER_IDL = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeMPILifeCycleCORBA -lSalomeLifeCycleCORBA -lSalomeMPIContainer -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace ${MPI_LIBS} +CXXFLAGS+=${MPI_INCLUDES} +CXX_DEPEND_FLAG+=${MPI_INCLUDES} @CONCLUDE@ diff --git a/src/TestMPIContainer/TestMPIComponentEngine.cxx b/src/TestMPIContainer/TestMPIComponentEngine.cxx index b0bf10b0c..aee37178c 100644 --- a/src/TestMPIContainer/TestMPIComponentEngine.cxx +++ b/src/TestMPIContainer/TestMPIComponentEngine.cxx @@ -7,6 +7,7 @@ // $Header$ //============================================================================= +#include #include "utilities.h" #include "TestMPIComponentEngine.hxx" using namespace std; @@ -22,7 +23,7 @@ TestMPIComponentEngine::TestMPIComponentEngine(int nbproc, int numproc, { MESSAGE("activate object") _thisObj = this ; - _id = _poa->activate_object(_thisObj); + _id = _poa->reference_to_id(_thisObj->_this()); } TestMPIComponentEngine::TestMPIComponentEngine(): Engines_Component_i(), MPIObject_i() @@ -35,19 +36,18 @@ TestMPIComponentEngine::~TestMPIComponentEngine() void TestMPIComponentEngine::Coucou(CORBA::Long L) { - BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); if(_numproc==0) for(int ip=1;ip<_nbproc;ip++) Engines::TestMPIComponent::_narrow((*_tior)[ip])->SPCoucou(L); - MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L); - END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); + SPCoucou(L); } void TestMPIComponentEngine::SPCoucou(CORBA::Long L) { - BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()"); + BEGIN_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); MESSAGE("[" << _numproc << "] TestMPIComponentEngine : L = " << L); - END_OF("[" << _numproc << "] TestMPIComponentEngine::SPCoucou()"); + END_OF("[" << _numproc << "] TestMPIComponentEngine::Coucou()"); + MPI_Barrier(MPI_COMM_WORLD); } extern "C" diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index b195a0199..898007487 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -20,24 +20,27 @@ # include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" +#include "LocalTraceCollector.hxx" using namespace std; int main (int argc, char * argv[]) { + // Initializing omniORB + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &orb = init( argc , argv ) ; + LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + + BEGIN_OF(argv[0]) try{ int status; - MESSAGE("COUCOU"); if( argc != 3 || strcmp(argv[1],"-np") ){ cout << "Usage: TestMPIContainer -np nbproc" << endl; exit(0); } - // Initializing omniORB - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); - // Obtain a reference to the root POA CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; @@ -48,15 +51,12 @@ int main (int argc, char * argv[]) string hostName = GetHostname(); containerName += hostName + "/MPIFactoryServer_" + argv[2]; - MESSAGE(containerName); - string dirn(getenv("KERNEL_ROOT_DIR")); dirn += "/lib/salome/libSalomeTestMPIComponentEngine.so"; - MESSAGE(dirn.c_str()); // Try to resolve MPI Container obj = NS.Resolve(containerName.c_str()) ; - Engines::Container_var iGenFact = Engines::Container::_narrow(obj); + Engines::MPIContainer_var iGenFact = Engines::MPIContainer::_narrow(obj); if(CORBA::is_nil(iGenFact)){ @@ -82,41 +82,42 @@ int main (int argc, char * argv[]) do{ sleep(1); obj = NS.Resolve(containerName.c_str()) ; - iGenFact = Engines::Container::_narrow(obj); + iGenFact = Engines::MPIContainer::_narrow(obj); MESSAGE("Waiting for MPI Container " << containerName << " : it = " << it ); }while( CORBA::is_nil(iGenFact) && (it++<15) ); } if(CORBA::is_nil(iGenFact)){ - MESSAGE("echec recuperation poignee container"); + MESSAGE("launching container failed"); exit(1); } + Engines::TestMPIComponent_var m1; - for (int iter = 0; iter < 1 ; iter++){ - MESSAGE("----------------------------------------------------" << iter); - obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str()); +// for (int iter = 0; iter < 1 ; iter++){ +// MESSAGE("----------------------------------------------------" << iter); + obj = iGenFact->load_impl("TestMPIComponent",dirn.c_str()); - m1 = Engines::TestMPIComponent::_narrow(obj); - if(CORBA::is_nil(m1)){ - INFOS("echec recuperation poignee composant"); - } - else{ - - INFOS("recup m1"); - SCRUTE(m1->instanceName()); - INFOS("Lancement de coucou"); - m1->Coucou(1L); - INFOS("On remove le composant"); - iGenFact->remove_impl(m1) ; - sleep(5); - } + INFOS("Get Handle on MPI Component"); + m1 = Engines::TestMPIComponent::_narrow(obj); + if(CORBA::is_nil(m1)){ + INFOS("getting handle on MPI component failed"); + } + else{ + m1->Coucou(1L); +// // sleep(5); + INFOS("Unload MPI Component"); + iGenFact->remove_impl(m1) ; } - // Clean-up. - iGenFact->finalize_removal() ; - orb->destroy(); +// } +// // Clean-up. +// // iGenFact->finalize_removal() ; +// // sleep(5); + iGenFact->MPIShutdown(); +// INFOS("shut down corba server for Test MPI Container"); +// orb->destroy(); } catch(CORBA::COMM_FAILURE& ex) { INFOS("Caught system exception COMM_FAILURE -- unable to contact the object."); @@ -131,5 +132,7 @@ int main (int argc, char * argv[]) INFOS("Caught unknown exception."); } - return 0; + END_OF(argv[0]); + delete myThreadTrace; + return 0 ; }