Salome HOME
PR: merge some files (MPI) from debug_V2_1_0a2
authorprascle <prascle>
Thu, 27 Jan 2005 18:43:38 +0000 (18:43 +0000)
committerprascle <prascle>
Thu, 27 Jan 2005 18:43:38 +0000 (18:43 +0000)
idl/SALOME_MPIContainer.idl
src/MPIContainer/MPIContainer_i.cxx
src/MPIContainer/MPIContainer_i.hxx
src/MPIContainer/SALOME_MPIContainer.cxx
src/TestMPIContainer/Makefile.in
src/TestMPIContainer/TestMPIComponentEngine.cxx
src/TestMPIContainer/TestMPIContainer.cxx

index 8265c7380425796268ea6a409a5da2f29015db68..c23e1c06107f97c6d1b8e9c6d03077fbdcb5db95 100644 (file)
@@ -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);
index 73e9ffaa0e3b01ce610d1aa9c7091d7dcb4de996..c190fa2bbecb992e4a176cd12f928fb8b042568a 100644 (file)
@@ -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_<SALOME_NamingService>::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();
+
+}
+
index 7d9ddc9a26425bdea04da91a5f1e32785462a0a8..a971b7f201da226ea3da739a2c82a24b63f7da7c 100644 (file)
@@ -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);
 
index d6fb4474fc110c4eb32072064f234926bab00d6f..52152364e87d181e0fd157abda372b2a4a82c569 100644 (file)
@@ -4,6 +4,7 @@
 #include "Utils_SINGLETON.hxx"
 #include "utilities.h"
 #include <mpi.h>
+#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_<ORB_INIT>::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_<ORB_INIT>::Instance() ;
-    ASSERT(SINGLETON_<ORB_INIT>::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 ;
 }
 
index 3924ce0e012f2bb5858e797395d0b8680f41da9d..b268fd20e47117e0ef1943f61b4c4e417ffa1102 100644 (file)
@@ -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@
index b0bf10b0cf2526dfc409589d361daf609326c2ae..aee37178c34f89a68835832fd9564eba24ee4a8c 100644 (file)
@@ -7,6 +7,7 @@
 // $Header$
 //=============================================================================
 
+#include <mpi.h>
 #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"
index b195a019954b13aa5f14b394dba1c3db0987717f..8980074879dea70df07bec5e4d0b4c6f88d91c97 100644 (file)
 # 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_<ORB_INIT>::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 ;
 }