]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
- Adapt code to the new PaCO++ version
authorribes <ribes>
Fri, 18 Jan 2008 09:20:35 +0000 (09:20 +0000)
committerribes <ribes>
Fri, 18 Jan 2008 09:20:35 +0000 (09:20 +0000)
- Remove Parallel Idl compilation when PaCO++ is used

14 files changed:
idl/Makefile.am
src/Container/SALOME_ContainerManager.cxx
src/DSC/ParallelDSC/ParallelDSC_i.cxx
src/DSC/ParallelDSC/ParallelDSC_i.hxx
src/ParallelContainer/Parallel_Salome_file_i.cxx
src/ParallelContainer/Parallel_Salome_file_i.hxx
src/ParallelContainer/SALOME_ParallelComponent_i.cxx
src/ParallelContainer/SALOME_ParallelComponent_i.hxx
src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.hxx

index b6a3f3d0b93ca03940a985971dbeb8aafd6c5768..f864c7187c0590bac2eb2023fac1470f09a64a45 100644 (file)
 
 include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 
+if WITH_PACO_PARALLEL
+MAKEFLAGS = -j1
+endif
+
 AM_CXXFLAGS = -fPIC
 
 BASEIDL_FILES = \
index ec691459dcdea991f22da8003de38abc7628584c..679dc190666f445e61b59f3d24454ac8271a26b1 100644 (file)
@@ -344,6 +344,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
                             const Engines::MachineList& possibleComputers)
 {
   CORBA::Object_var obj;
+  PaCO::InterfaceManager_var proxy;
   Engines::Container_ptr ret = Engines::Container::_nil();
   Engines::MachineParameters params(params_const);
 
@@ -376,6 +377,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
        params_proxy.nb_component_nodes = 0;
        obj = LaunchParallelContainer(command, params_proxy, _NS->ContainerName(params));
        ret = Engines::Container::_narrow(obj);
+       proxy = PaCO::InterfaceManager::_narrow(obj);
 
        // Step 4 : starting parallel container nodes
        command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerNode", params, "xterm");
@@ -411,8 +413,9 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
 
        PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
        MESSAGE("[FindOrStartParallelContainer] Deploying node : " << name);
-       node->deploy(i);
+       node->deploy();
        }
+       proxy->start();
        }
        catch(CORBA::SystemException& e)
        {
index c4f15adb57efc617e330ca5ba512525fda130f59..291e3138c6b3e7ea3cfabe1ec84c5fd3fb368aeb 100644 (file)
 
 #include "ParallelDSC_i.hxx"
 
-Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior,
+Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
+                                            char * ior,
+                                            int rank,
                                             PortableServer::POA_ptr poa,
                                             PortableServer::ObjectId * contId,
                                             const char *instanceName,
                                             const char *interfaceName,
                                             bool notif) :
-  Engines_Parallel_Component_i(orb, ior, poa, contId, instanceName, interfaceName, notif),
-  Engines::Parallel_DSC_serv(orb, ior),
-  Engines::DSC_serv(orb, ior),
-  Engines::Superv_Component_serv(orb, ior),
-  Engines::Component_serv(orb, ior),
-  Engines::Parallel_Component_serv(orb, ior),
-  InterfaceParallel_impl(orb,ior)
+  Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif),
+  Engines::Parallel_DSC_serv(orb, ior, rank),
+  Engines::DSC_serv(orb, ior, rank),
+  Engines::Superv_Component_serv(orb, ior, rank),
+  Engines::Component_serv(orb, ior, rank),
+  Engines::Parallel_Component_serv(orb, ior, rank),
+  InterfaceParallel_impl(orb, ior, rank)
 {
 }
 
@@ -56,10 +58,8 @@ Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref,
   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
                                           provides_port_name,
                                           port_prop);
-  PaCO_operation * global_ptr = getContext("global_paco_context");
-  cerr << " my_comm : " << global_ptr->my_com << endl;
   // Waiting that all the nodes have the proxy
-  global_ptr->my_com->paco_barrier(); 
+  _my_com->paco_barrier(); 
   cerr << "set_paco_proxy node fin" << endl;
 }
 
@@ -80,8 +80,8 @@ Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr
 {
   assert(provides_port_name);
   CORBA::Boolean rtn_bool = false;
-  CORBA::Object_ptr _comp_proxy = _orb->string_to_object(_ior.c_str());
-  Engines::Parallel_DSC_var real_comp_proxy = Engines::Parallel_DSC::_narrow(_comp_proxy);
+  Engines::Parallel_DSC_var real_comp_proxy = 
+    Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
   rtn_bool = true;
   return rtn_bool;
@@ -114,7 +114,7 @@ Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref,
 {
   CORBA::Boolean rtn_bool = false;
   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
-  node->deploy(getMyRank());
+  node->deploy();
   rtn_bool = true;
   return rtn_bool;
 }
index ed900566fa281a961e104a2ca3cae58dde495888..05859c0023f69070329c80cf8d8fcb20655c13f1 100644 (file)
@@ -39,7 +39,9 @@ class Engines_ParallelDSC_i:
   public virtual Engines_DSC_interface 
 {
 public:
-  Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
+                       char * ior,
+                       int rank,
                        PortableServer::POA_ptr poa,
                        PortableServer::ObjectId * contId,
                        const char *instanceName,
index 15f9338fbf76b7682a8d4a23b454f9976e896891..7c93948637688ece96b5008d858a867389cb0d97 100644 (file)
 #include "Parallel_Salome_file_i.hxx"
 #include "utilities.h"
 
-Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior) :
-  InterfaceParallel_impl(orb,ior), 
-  Engines::Salome_file_serv(orb,ior),
-  Engines::fileTransfer_serv(orb,ior),
-  Engines::Parallel_Salome_file_serv(orb,ior)
+Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, 
+                                              const char * ior,
+                                              int rank) :
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Salome_file_serv(orb,ior,rank),
+  Engines::fileTransfer_serv(orb,ior,rank),
+  Engines::Parallel_Salome_file_serv(orb,ior,rank)
 {
   CORBA::Object_ptr obj = _orb->string_to_object(ior);
   proxy = Engines::Parallel_Salome_file::_narrow(obj);
@@ -168,8 +170,8 @@ Parallel_Salome_file_i::recvFiles_node() {
          // 2 cases :
          // Source file is a Salome_file
          // Source file is a Parallel_Salome_file
-         PaCO::ParallelKernel_var interface_manager = 
-           PaCO::ParallelKernel::_narrow(_fileDistributedSource[file_infos.file_name.in()]);
+         PaCO::InterfaceManager_var interface_manager = 
+           PaCO::InterfaceManager::_narrow(_fileDistributedSource[file_infos.file_name.in()]);
          if (CORBA::is_nil(interface_manager))
            result = getDistributedFile(file_infos.file_name.in());
          else
index c3814a5c4124861413678c3e8fa736b22ea0aec0..21384fef918d2823b6edc1b5f34da22b2cab639e 100644 (file)
@@ -39,7 +39,9 @@ class CONTAINER_EXPORT Parallel_Salome_file_i:
   public virtual Engines::Parallel_Salome_file_serv
 {
   public:
-    Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior);
+    Parallel_Salome_file_i(CORBA::ORB_ptr orb, 
+                          const char * ior,
+                          int rank);
     virtual ~Parallel_Salome_file_i();
 
     virtual void setFileNode(const char* file_name, CORBA::Long node);
index db60ae5e414d2774d8bd8d531c83db3f4029a5c1..fab45e7032dccba174f5007b1d9c3a63ec02805c 100644 (file)
@@ -44,6 +44,7 @@ int SIGUSR11 = 1000;
 #endif
 
 #include <paco_dummy.h>
+#include <paco_omni.h>
 
 using namespace std;
 
@@ -59,8 +60,10 @@ bool Engines_Parallel_Component_i::_isMultiInstance = false;
  */
 //=============================================================================
 
-Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior) : 
-  InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior), Engines::Parallel_Component_serv(orb,ior)
+Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank) : 
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Component_serv(orb,ior,rank), 
+  Engines::Parallel_Component_serv(orb,ior,rank)
 {
   //ASSERT(0);
   INFOS("Default Constructor...");
@@ -79,15 +82,15 @@ Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, c
  */
 //=============================================================================
 
-Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior,
+Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank,
                                         PortableServer::POA_ptr poa, 
                                         PortableServer::ObjectId * contId, 
                                         const char *instanceName,
                                         const char *interfaceName,
                                          bool notif) :
-  InterfaceParallel_impl(orb,ior), 
-  Engines::Component_serv(orb,ior),
-  Engines::Parallel_Component_serv(orb,ior),
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Component_serv(orb,ior,rank),
+  Engines::Parallel_Component_serv(orb,ior,rank),
   _instanceName(instanceName),
   _interfaceName(interfaceName),
   _myConnexionToRegistry(0),
@@ -818,34 +821,21 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     // Firstly, we have to create the proxy object
     // of the Salome_file and transmit his
     // reference to the other nodes.
+    Engines::Parallel_Salome_file_proxy_impl * proxy = NULL;
     if (getMyRank() == 0) {
-      Engines::Parallel_Salome_file_proxy_impl * proxy = 
-       new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
-      PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
-      
-      paco_fabrique_manager* pfm = paco_getFabriqueManager();
-      pfm->register_com("dummy", new paco_dummy_fabrique());
-      proxy_global_ptr->setComFab(NULL);
-      proxy_global_ptr->setLibCom("dummy",NULL);
-      
-      proxy_global_ptr->setTypeClient(true);
-      PaCO::PacoTopology_t client_topo;
-      client_topo.total = 1;
-      proxy_global_ptr->setClientTopo(client_topo);
+      proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb),
+                                                          new paco_omni_fabrique());
+      proxy->copyGlobalContext(this); 
       PaCO::PacoTopology_t serveur_topo;
       serveur_topo.total = getTotalNode();
-      proxy->setTopo(serveur_topo);
+      proxy->setTopology(serveur_topo);
 
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
       // We send the reference to all the nodes...
-      CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
-      Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+      Engines::Parallel_Component_var component_proxy = 
+       Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy);
       component_proxy->send_parallel_proxy_object(proxy_ref);
 
       // Adding proxy into the map
@@ -863,32 +853,35 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     for (int i = 0; i < getTotalNode(); i++) {
       if (i ==  getMyRank()) {
        Parallel_Salome_file_i * servant = 
-         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
-       PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
-       
-       // We initialize the object with the context of the Parallel component
-       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-//     compo_global_ptr->init_context(servant_global_ptr);
-       servant_global_ptr->init_context(compo_global_ptr);
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), 
+                                    proxy_ior.c_str(),
+                                    i);
+       servant->copyGlobalContext(this); 
        
        // We register the CORBA objet into the POA
        servant->POA_PaCO::InterfaceParallel::_this();
 
        // Register the servant
-       servant->deploy(getMyRank());
+       servant->deploy();
 
        // Adding servant to the map
        (*_map)[Salome_file_name] = servant;
       }
 
-      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-      compo_global_ptr->my_com->paco_barrier();
+      _my_com->paco_barrier();
+      // start parallel object
+      if (getMyRank() == 0) {
+       proxy->start();
+       _my_com->paco_barrier();
+      }
+      else
+       _my_com->paco_barrier();
     }
-
     // Parallel_Salome_file is created and deployed
     delete _proxy;
     _proxy = NULL;
   }
+
   pthread_mutex_unlock(deploy_mutex);
   proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
   CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
@@ -918,6 +911,7 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
 
   // Try to find the Salome_file ...
   _Salome_file_map_it = _map->find(Salome_file_name);
+  Engines::Parallel_Salome_file_proxy_impl * proxy;
   if (_Salome_file_map_it ==  _map->end()) {
 
     // We create a new PaCO++ object.
@@ -928,33 +922,19 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     // of the Salome_file and transmit his
     // reference to the other nodes.
     if (getMyRank() == 0) {
-      Engines::Parallel_Salome_file_proxy_impl * proxy = 
-       new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
-      PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
-
-      paco_fabrique_manager* pfm = paco_getFabriqueManager();
-      pfm->register_com("dummy", new paco_dummy_fabrique());
-      proxy_global_ptr->setComFab(NULL);
-      proxy_global_ptr->setLibCom("dummy",NULL);
-
-      proxy_global_ptr->setTypeClient(true);
-      PaCO::PacoTopology_t client_topo;
-      client_topo.total = 1;
-      proxy_global_ptr->setClientTopo(client_topo);
+       proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb),
+                                                            new paco_omni_fabrique());
+      proxy->copyGlobalContext(this); 
       PaCO::PacoTopology_t serveur_topo;
       serveur_topo.total = getTotalNode();
-      proxy->setTopo(serveur_topo);
+      proxy->setTopology(serveur_topo);
 
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
       // We send the reference to all the nodes...
-      CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
-      Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+      Engines::Parallel_Component_var component_proxy = 
+       Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy);
       component_proxy->send_parallel_proxy_object(proxy_ref);
 
       // Adding proxy into the map
@@ -972,26 +952,29 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     for (int i = 0; i < getTotalNode(); i++) {
       if (i ==  getMyRank()) {
        Parallel_Salome_file_i * servant = 
-         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
-       PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
-       
-       // We initialize the object with the context of the Parallel component
-       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-//     compo_global_ptr->init_context(servant_global_ptr);
-       servant_global_ptr->init_context(compo_global_ptr);
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), 
+                                    proxy_ior.c_str(),
+                                    i);
+       servant->copyGlobalContext(this); 
        
        // We register the CORBA objet into the POA
        servant->POA_PaCO::InterfaceParallel::_this();
 
        // Register the servant
-       servant->deploy(getMyRank());
+       servant->deploy();
 
        // Adding servant to the map
        (*_map)[Salome_file_name] = servant;
       }
 
-      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-      compo_global_ptr->my_com->paco_barrier();
+      _my_com->paco_barrier();
+      // start parallel object
+      if (getMyRank() == 0) {
+       proxy->start();
+       _my_com->paco_barrier();
+      }
+      else
+       _my_com->paco_barrier();
     }
 
     // Parallel_Salome_file is created and deployed
index edadf93cea929b8bb650006da6a0fc7dd304d3d2..21886497061249a858d46d3014418801c0c62dcd 100644 (file)
@@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Component_i:
   public virtual PortableServer::RefCountServantBase
 {
 public:
-  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior);
-  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank);
+  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank,
                               PortableServer::POA_ptr poa,
                               PortableServer::ObjectId * contId, 
                               const char *instanceName, 
index 4f5d0d2749de547ab403ba68f7ce09dc5dd357aa..d3470b9de5334628228c15060e252beeac41f1b5 100644 (file)
@@ -54,12 +54,12 @@ using namespace std;
 #include <signal.h>
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
@@ -78,13 +78,13 @@ sighandler_t setsig(int sig, sighandler_t handler)
 void AttachDebugger()
 {
   if(getenv ("DEBUGGER"))
-    {
-      std::stringstream exec;
-      exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
-      system(exec.str().c_str());
-      while(1);
-    }
+  {
+    std::stringstream exec;
+    exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
+    std::cerr << exec.str() << std::endl;
+    system(exec.str().c_str());
+    while(1);
+  }
 }
 
 void Handler(int theSigId)
@@ -109,107 +109,104 @@ void unexpectedHandler(void)
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel container node");
+  INFOS("Launching a parallel container node");
 
-#ifdef _DEBUG_
-//     signal(SIGSEGV, handler);
-#endif
   if(getenv ("DEBUGGER"))
-    {
-      setsig(SIGSEGV,&Handler);
-      set_terminate(&terminateHandler);
-      set_unexpected(&unexpectedHandler);
-    }
-
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       char * containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       char * hostname = "";
-       if(argc > 3) {
-               hostname = argv[3];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  {
+    setsig(SIGSEGV,&Handler);
+    set_terminate(&terminateHandler);
+    set_unexpected(&unexpectedHandler);
+  }
+
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  std::string containerName("");
+  if(argc > 1) {
+    containerName = argv[1];
+  }
+  std::string hostname("");
+  if(argc > 3) {
+    hostname = argv[3];
+  }
+
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               // Get the proxy
-               string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname);
-               obj = ns->Resolve(proxyNameInNS.c_str());
-               char * proxy_ior = orb->object_to_string(obj);
-
-               // Creating a node
-               string name(containerName);
-               string node_name = name + "Node";
-               Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior,
-                                                                                                                                                                                                                                                                                                                       root_poa,
-                                                                                                                                                                                                                                                                                                                       (char*) node_name.c_str(),
-                                                                                                                                                                                                                                                                                                                       argc, argv);
-               // PaCO++ init
-               paco_fabrique_manager * pfm = paco_getFabriqueManager();
-               pfm->register_com("dummy", new paco_dummy_fabrique());
-               pfm->register_thread("omni", new paco_omni_fabrique());
-
-               // Global context
-               PaCO_operation * global_ptr = servant->getContext("global_paco_context");
-               global_ptr->setLibCom("dummy",NULL);
-               global_ptr->setLibThread("omni");
-
-               // Activation
-               PortableServer::ObjectId * _id = root_poa->activate_object(servant);
-               servant->set_id(_id);
-               obj = root_poa->id_to_reference(*_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-               int myid = 0;
-               char buffer [5];
-               snprintf(buffer, 5, "%d", myid);
-               node_name = node_name + buffer;
-               string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(obj, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    // Get the proxy
+    string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), 
+                                                      hostname.c_str());
+    obj = ns->Resolve(proxyNameInNS.c_str());
+    char * proxy_ior = orb->object_to_string(obj);
+
+    // Creating a node
+    string node_name = containerName + "Node";
+    Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), 
+                                                                             proxy_ior,
+                                                                             0,
+                                                                             root_poa,
+                                                                             (char*) node_name.c_str(),
+                                                                             argc, argv);
+    // PaCO++ init
+    paco_fabrique_manager * pfm = paco_getFabriqueManager();
+    pfm->register_com("dummy", new paco_dummy_fabrique());
+    pfm->register_thread("omni", new paco_omni_fabrique());
+    servant->setLibCom("dummy", servant);
+    servant->setLibThread("omni");
+
+    // Activation
+    PortableServer::ObjectId * _id = root_poa->activate_object(servant);
+    servant->set_id(_id);
+    obj = root_poa->id_to_reference(*_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+    int myid = 0;
+    char buffer [5];
+    snprintf(buffer, 5, "%d", myid);
+    node_name = node_name + buffer;
+    string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(obj, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+  return 0 ;
 }
 
index 4852bcafb2c0f1c45324a69c79a3cbb51c583988..baea9d42140bb94e0e971131b921fb1d830d5909 100644 (file)
@@ -57,21 +57,21 @@ using namespace std;
 #include <signal.h>
 
 void test(int sigval) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
@@ -90,13 +90,13 @@ sighandler_t setsig(int sig, sighandler_t handler)
 void AttachDebugger()
 {
   if(getenv ("DEBUGGER"))
-    {
-      std::stringstream exec;
-      exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
-      system(exec.str().c_str());
-      while(1);
-    }
+  {
+    std::stringstream exec;
+    exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
+    std::cerr << exec.str() << std::endl;
+    system(exec.str().c_str());
+    while(1);
+  }
 }
 
 void Handler(int theSigId)
@@ -121,40 +121,31 @@ void unexpectedHandler(void)
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel Mpi container node");
+  INFOS("Launching a parallel Mpi container node");
 
-#ifdef _DEBUG_
-//     struct sigaction action;
-//     action.sa_handler = &test;
-//     sigaction(SIGSEGV, &action, NULL);
-#endif
-       
-       // MPI Init
-       int provided;
-       MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
+  // MPI Init
+  int provided;
+  int myid;
+  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
+  MPI_Comm_rank(MPI_COMM_WORLD,&myid);
 
   if(getenv ("DEBUGGER"))
-    {
-  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
-      setsig(SIGSEGV,&Handler);
-      set_terminate(&terminateHandler);
-      set_unexpected(&unexpectedHandler);
-    }
-#ifdef _DEBUG_
-       cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
-       cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
-       cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
-       cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl;
-       cerr << "Level provided : " << provided << endl;
-#endif
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       // Code pour choisir le reseau infiniband .....
-/*     string hostname_temp = GetHostname();
+  {
+    std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+    setsig(SIGSEGV,&Handler);
+    set_terminate(&terminateHandler);
+    set_unexpected(&unexpectedHandler);
+  }
+  cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
+  cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
+  cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
+  cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl;
+  cerr << "Level provided : " << provided << endl;
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  // Code pour choisir le reseau infiniband .....
+  /*   string hostname_temp = GetHostname();
        hostent * t = gethostbyname(hostname_temp.c_str());
        cerr << " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " << t->h_addr << " " << hostname_temp << endl;
        cerr << t->h_addr << endl;
@@ -165,96 +156,99 @@ int main(int argc, char* argv[])
        string com = "giop:tcp:" + ip + ":";
        const char* options[][2] = { { "endPoint", com.c_str() }, { 0, 0 } };
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
-*/
-       char * containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
+       */
+  std::string containerName("");
+  containerName = argv[1];
 
-       char * hostname = "";
-       if(argc > 3) {
-               hostname = argv[3];
-       }
+  std::string hostname("");
+  if(argc > 3) {
+    hostname = argv[3];
+  }
 
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               // On récupère le proxy 
-               string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname);
-               obj = ns->Resolve(proxyNameInNS.c_str());
-               char * proxy_ior = orb->object_to_string(obj);
-
-               // Node creation
-               string name(containerName);
-               string node_name = name + "Node";
-               Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior,
-                                                                                                                                                                                                                                                                                                                       root_poa,
-                                                                                                                                                                                                                                                                                                                       (char*) node_name.c_str(),
-                                                                                                                                                                                                                                                                                                                       argc, argv);
-               // PaCO++ init
-               paco_fabrique_manager * pfm = paco_getFabriqueManager();
-               pfm->register_com("mpi", new paco_mpi_fabrique());
-               pfm->register_thread("omni", new paco_omni_fabrique());
-
-               // Global context
-               PaCO_operation * global_ptr = servant->getContext("global_paco_context");
-               MPI_Comm group = MPI_COMM_WORLD;
-               global_ptr->setLibCom("mpi", &group);
-               global_ptr->setLibThread("omni");
-
-               // Activation
-               PortableServer::ObjectId * _id = root_poa->activate_object(servant);
-               servant->set_id(_id);
-               obj = root_poa->id_to_reference(*_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-
-               int myid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &myid);
-               char buffer [5];
-               snprintf(buffer, 5, "%d", myid);
-               node_name = node_name + buffer;
-               string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(obj, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-
-       MPI_Finalize();
-
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    // On récupère le proxy 
+    string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), 
+                                                      hostname.c_str());
+    obj = ns->Resolve(proxyNameInNS.c_str());
+    char * proxy_ior = orb->object_to_string(obj);
+
+    // Node creation
+    string node_name = containerName + "Node";
+    Engines_Parallel_Container_i * servant = 
+      new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), 
+                                      proxy_ior,
+                                      myid,
+                                      root_poa,
+                                      (char*) node_name.c_str(),
+                                      argc, argv);
+    // PaCO++ init
+    paco_fabrique_manager * pfm = paco_getFabriqueManager();
+    pfm->register_com("mpi", new paco_mpi_fabrique());
+    pfm->register_thread("omni", new paco_omni_fabrique());
+    MPI_Comm group = MPI_COMM_WORLD;
+    servant->setLibCom("mpi", &group);
+    servant->setLibThread("omni");
+
+    // Activation
+    PortableServer::ObjectId * _id = root_poa->activate_object(servant);
+    servant->set_id(_id);
+    obj = root_poa->id_to_reference(*_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+
+    int myid;
+    MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+    char buffer [5];
+    snprintf(buffer, 5, "%d", myid);
+    node_name = node_name + buffer;
+    string _containerName = ns->BuildContainerNameForNS(node_name.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(obj, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+
+  MPI_Finalize();
+
+  return 0 ;
 }
 
index 06e7a59f0f9bb36caf2d3c7868fa7366a7a61815..697ddc96d9ded1e65ca649bc45e1614d763c4726 100644 (file)
 using namespace std;
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel proxy container");
+  INFOS("Launching a parallel proxy container");
 
 #ifdef DEBUG_PARALLEL
-       signal(SIGSEGV, handler);
+  signal(SIGSEGV, handler);
 #endif
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
 
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+  std::string containerName("");
+  if(argc > 1) {
+    containerName = argv[1];
+  }
 
-       char *containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               ASSERT(!CORBA::is_nil(obj));
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    ASSERT(!CORBA::is_nil(obj));
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); 
-
-               // PaCO++ code
-               paco_fabrique_manager* pfm = paco_getFabriqueManager();
-               // Global context
-               PaCO_operation * global_ptr =  proxy->getContext("global_paco_context");
-               pfm->register_com("dummy", new paco_dummy_fabrique());
-               global_ptr->setLibCom("dummy", NULL);
-               pfm->register_thread("omnithread", new paco_omni_fabrique());
-               global_ptr->setLibThread("omnithread");
-               global_ptr->setTypeClient(true);
-               // The proxy is a PaCO++ client
-               PaCO::PacoTopology_t client_topo;
-               client_topo.total = 1;
-               global_ptr->setClientTopo(client_topo);
-               // Topo of the parallel object
-               PaCO::PacoTopology_t serveur_topo;
-               serveur_topo.total = 1;
-               proxy->setTopo(serveur_topo);
-
-               PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
-               obj = root_poa->id_to_reference(_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-               Engines::Container_var pCont = Engines::Container::_narrow(obj);
-               string _containerName = ns->BuildContainerNameForNS(containerName,
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(pCont, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    Engines::Container_proxy_impl * proxy = 
+      new Engines::Container_proxy_impl(orb,
+                                       new paco_omni_fabrique());
+
+    // PaCO++ code
+    paco_fabrique_manager* pfm = paco_getFabriqueManager();
+    pfm->register_com("dummy", new paco_dummy_fabrique());
+    proxy->setLibCom("dummy", proxy);
+    pfm->register_thread("omnithread", new paco_omni_fabrique());
+    proxy->setLibThread("omnithread");
+    // Topo of the parallel object
+    PaCO::PacoTopology_t serveur_topo;
+    serveur_topo.total = 1;
+    proxy->setTopology(serveur_topo);
+
+    PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+    obj = root_poa->id_to_reference(_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(pCont, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+  return 0 ;
 }
 
index 1e9739d6da944489d5b28e1b2d3410ad025c6874..bdc99bbb7f0a92117756c73c080c9144d82f0582 100644 (file)
@@ -54,113 +54,104 @@ using namespace std;
 #include <signal.h>
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel Mpi proxy container");
+  INFOS("Launching a parallel Mpi proxy container");
 
 #ifdef DEBUG_PARALLEL
-       signal(SIGSEGV, handler);
+  signal(SIGSEGV, handler);
 #endif
 
-       // MPI Init
-       int provided;
-       MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
-       
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       char *containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       char * nb_nodes = "";
-       if(argc > 2) {
-               nb_nodes = argv[2];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               ASSERT(!CORBA::is_nil(obj));
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  // MPI Init
+  int provided;
+  MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  std::string containerName("");
+  containerName = argv[1];
+  int nb_nodes;
+  sscanf(argv[2],"%d",&nb_nodes);
+
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    ASSERT(!CORBA::is_nil(obj));
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); 
-
-               // PaCO++ code
-               paco_fabrique_manager* pfm = paco_getFabriqueManager();
-               // Global context
-               PaCO_operation * global_ptr =  proxy->getContext("global_paco_context");
-               pfm->register_com("mpi", new paco_mpi_fabrique());
-               MPI_Comm group = MPI_COMM_WORLD;
-               global_ptr->setLibCom("mpi", &group);
-               pfm->register_thread("omnithread", new paco_omni_fabrique());
-               global_ptr->setLibThread("omnithread");
-               global_ptr->setTypeClient(true);
-               PaCO::PacoTopology_t client_topo;
-               client_topo.total = 1;
-               global_ptr->setClientTopo(client_topo);
-               PaCO::PacoTopology_t serveur_topo;
-               serveur_topo.total = atoi(nb_nodes);
-               proxy->setTopo(serveur_topo);
-
-               // Activation
-               PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
-               obj = root_poa->id_to_reference(_id);
-
-               // in the NamingService
-               string hostname = GetHostname();
-               Engines::Container_var pCont = Engines::Container::_narrow(obj);
-               string _containerName = ns->BuildContainerNameForNS(containerName,
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(pCont, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-
-       MPI_Finalize();
-
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    Engines::Container_proxy_impl * proxy = 
+      new Engines::Container_proxy_impl(orb, 
+                                       new paco_omni_fabrique());
+
+    // PaCO++ code
+    paco_fabrique_manager* pfm = paco_getFabriqueManager();
+    pfm->register_com("mpi", new paco_mpi_fabrique());
+    MPI_Comm group = MPI_COMM_WORLD;
+    proxy->setLibCom("mpi", &group);
+    pfm->register_thread("omnithread", new paco_omni_fabrique());
+    proxy->setLibThread("omnithread");
+    PaCO::PacoTopology_t serveur_topo;
+    serveur_topo.total = nb_nodes;
+    proxy->setTopology(serveur_topo);
+
+    // Activation
+    PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+    obj = root_poa->id_to_reference(_id);
+
+    // in the NamingService
+    string hostname = GetHostname();
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(pCont, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+
+  MPI_Finalize();
+
+  return 0 ;
 }
 
index 9fbf89e85cf3f768cb21c205de34a90e45fc96ad..937a2274bf9b6717c5032aa8a066aa129521f121 100644 (file)
@@ -50,6 +50,7 @@
 int SIGUSR1 = 1000;
 #endif
 
+#include <paco_omni.h>
 #include "utilities.h"
 using namespace std;
 
@@ -77,8 +78,11 @@ omni_mutex Engines_Parallel_Container_i::_numInstanceMutex ;
  */
 //=============================================================================
 
-Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior) : 
-  InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior),
+Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, 
+                                                           char * ior, 
+                                                           int rank) : 
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Container_serv(orb,ior,rank),
   _numInstance(0)
 {
 }
@@ -89,14 +93,17 @@ Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb,
  */
 //=============================================================================
 
-Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior,
+Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, 
+                                                           char * ior, 
+                                                           int rank,
                                                            PortableServer::POA_ptr poa,
                                                            char *containerName ,
                                                            int argc , char* argv[],
                                                            bool activAndRegist,
                                                            bool isServantAloneInProcess
                                                           ) :
-  InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior),
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Container_serv(orb,ior,rank),
   _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
 {
   _pid = (long)getpid();
@@ -257,7 +264,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName)
   }
 
   // To be sure that all the nodes of the component as loaded the library
-  global_paco_context_ptr->my_com->paco_barrier();
+  _my_com->paco_barrier();
 
   return ret;
 }
@@ -652,6 +659,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
 
     typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
       (CORBA::ORB_ptr,
+       paco_fabrique_thread *,
        PortableServer::POA_ptr,
        PortableServer::ObjectId *, 
        const char *,
@@ -680,7 +688,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
 
       // --- Instanciate required CORBA object
       PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
-      id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), getTotalNode()) ;
+      id = (Component_factory) ( _orb, new paco_omni_fabrique(), _poa, _id, instanceName.c_str(), getTotalNode()) ;
 
       // --- get reference & servant from id
       CORBA::Object_var obj = _poa->id_to_reference(*id);
@@ -704,11 +712,11 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
     // in the nameing service.
     _numInstanceMutex.lock() ; // lock on the instance number
     _numInstance++ ;
-//    int numInstance = _numInstance ;
+    //    int numInstance = _numInstance ;
     _numInstanceMutex.unlock() ;
   }
   cerr << "Node " << getMyRank() << " entering in paco_barrier()" << endl;
-  global_paco_context_ptr->my_com->paco_barrier();
+  _my_com->paco_barrier();
   cerr << "Node " << getMyRank() << " quitting paco_barrier()" << endl;
 
   //////////////////////////////////////////////////////////////////////////
@@ -732,7 +740,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
   string factory_name = aGenRegisterName + string("Engine_factory");
 
   typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
-    (CORBA::ORB_ptr, char * ior,
+    (CORBA::ORB_ptr, char *, int,
      PortableServer::POA_ptr, 
      PortableServer::ObjectId *, 
      const char *, 
@@ -758,7 +766,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
     // --- Instanciate required CORBA object
 
     PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
-    id = (Component_factory) ( _orb, proxy_ior, _poa, _id, instanceName.c_str(),
+    id = (Component_factory) ( _orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(),
                               aGenRegisterName.c_str() ) ;
 
     // --- get reference & servant from id
@@ -777,11 +785,17 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
   //////////////////////////////////////////////////////////////////////////
   // 3: Deployment Step
 
-  iobject2->deploy(getMyRank());
-  global_paco_context_ptr->my_com->paco_barrier();
+  iobject2->deploy();
+  _my_com->paco_barrier();
   cerr << "--------- createParallelInstance : End Deploy step ----------" << endl;  
+  if (getMyRank() == 0) {
+    PaCO::InterfaceManager_var proxy = PaCO::InterfaceManager::_narrow(iobject);
+    proxy->start();
+    _my_com->paco_barrier();
+  }
+  else
+    _my_com->paco_barrier();
 
-  //  return obj_proxy._retn();
   return iobject._retn();
 }
 
@@ -954,22 +968,22 @@ Engines_Parallel_Container_i::createFileRef(const char* origFileName)
   Engines::fileRef_var theFileRef = Engines::fileRef::_nil();
 
   if (origName[0] != '/')
-    {
-      INFOS("path of file to copy must be an absolute path begining with '/'");
-      return Engines::fileRef::_nil();
-    }
+  {
+    INFOS("path of file to copy must be an absolute path begining with '/'");
+    return Engines::fileRef::_nil();
+  }
 
   if (CORBA::is_nil(_fileRef_map[origName]))
-    {
-      CORBA::Object_var obj=_poa->id_to_reference(*_id);
-      Engines::Container_var pCont = Engines::Container::_narrow(obj);
-      fileRef_i* aFileRef = new fileRef_i(pCont, origFileName);
-      theFileRef = Engines::fileRef::_narrow(aFileRef->_this());
-      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
-      _fileRef_map[origName] = theFileRef;
-      _numInstanceMutex.unlock() ;
-    }
-  
+  {
+    CORBA::Object_var obj=_poa->id_to_reference(*_id);
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    fileRef_i* aFileRef = new fileRef_i(pCont, origFileName);
+    theFileRef = Engines::fileRef::_narrow(aFileRef->_this());
+    _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+    _fileRef_map[origName] = theFileRef;
+    _numInstanceMutex.unlock() ;
+  }
+
   theFileRef =  Engines::fileRef::_duplicate(_fileRef_map[origName]);
   ASSERT(! CORBA::is_nil(theFileRef));
   return theFileRef._retn();
@@ -996,25 +1010,25 @@ Engines_Parallel_Container_i::createSalome_file(const char* origFileName)
 {
   string origName(origFileName);
   if (CORBA::is_nil(_Salome_file_map[origName]))
+  {
+    Salome_file_i* aSalome_file = new Salome_file_i();
+    try 
     {
-      Salome_file_i* aSalome_file = new Salome_file_i();
-      try 
-      {
-       aSalome_file->setLocalFile(origFileName);
-       aSalome_file->recvFiles();
-      }
-      catch (const SALOME::SALOME_Exception& e)
-      {
-       return Engines::Salome_file::_nil();
-      }
-
-      Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
-      theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
-      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
-      _Salome_file_map[origName] = theSalome_file;
-      _numInstanceMutex.unlock() ;
+      aSalome_file->setLocalFile(origFileName);
+      aSalome_file->recvFiles();
     }
-  
+    catch (const SALOME::SALOME_Exception& e)
+    {
+      return Engines::Salome_file::_nil();
+    }
+
+    Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+    theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+    _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+    _Salome_file_map[origName] = theSalome_file;
+    _numInstanceMutex.unlock() ;
+  }
+
   Engines::Salome_file_ptr theSalome_file =  
     Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
   ASSERT(!CORBA::is_nil(theSalome_file));
index 962bc9a1dc2f84604269d412b9e7db6023568301..7eaef5c7b42108920abc2095cc137a9003468b1c 100644 (file)
@@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Container_i:
   public virtual PortableServer::RefCountServantBase
 {
 public:
-  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior);
-  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank);
+  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank,
                      PortableServer::POA_ptr poa,
                      char * containerName ,
                       int argc, char* argv[],