1 // SALOME ParallelContainerProxyMpi : Launching the proxy of a MPI PaCO++ object
3 // Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_ParallelContainerProxyMpi.cxx
25 // Author : André Ribes, EDF
26 // Module : SALOME PARALLEL
38 #include "SALOME_ComponentPaCO_Engines_Container_server.h"
39 #include <paco_omni.h>
44 #include "SALOME_NamingService.hxx"
46 #include "utilities.h"
47 #include "Utils_ORB_INIT.hxx"
48 #include "Utils_SINGLETON.hxx"
49 #include "SALOMETraceCollector.hxx"
57 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
58 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
59 cerr << "SIGSEGV in :" << getpid() << endl;
60 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
61 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
66 int main(int argc, char* argv[])
68 INFOS("Launching a parallel Mpi proxy container");
71 signal(SIGSEGV, handler);
76 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
78 // Initialise the ORB.
79 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
80 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
81 CORBA::ORB_var orb = init(0, 0);
82 //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
84 char *containerName = "";
86 containerName = argv[1];
95 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
96 ASSERT(!CORBA::is_nil(obj));
97 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
98 PortableServer::POAManager_var pman = root_poa->the_POAManager();
101 // add this container to the kill list
103 sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
107 SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
108 Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb));
111 paco_fabrique_manager* pfm = paco_getFabriqueManager();
113 PaCO_operation * global_ptr = proxy->getContext("global_paco_context");
114 pfm->register_com("mpi", new paco_mpi_fabrique());
115 MPI_Comm group = MPI_COMM_WORLD;
116 global_ptr->setLibCom("mpi", &group);
117 pfm->register_thread("omnithread", new paco_omni_fabrique());
118 global_ptr->setLibThread("omnithread");
119 global_ptr->setTypeClient(true);
120 PaCO::PacoTopology_t client_topo;
121 client_topo.total = 1;
122 global_ptr->setClientTopo(client_topo);
123 PaCO::PacoTopology_t serveur_topo;
124 serveur_topo.total = atoi(nb_nodes);
125 proxy->setTopo(serveur_topo);
128 PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
129 obj = root_poa->id_to_reference(_id);
131 // in the NamingService
132 string hostname = GetHostname();
133 Engines::Container_var pCont = Engines::Container::_narrow(obj);
134 string _containerName = ns->BuildContainerNameForNS(containerName,
136 cerr << "---------" << _containerName << "----------" << endl;
137 ns->Register(pCont, _containerName.c_str());
141 catch(CORBA::SystemException&)
143 INFOS("Caught CORBA::SystemException.");
145 catch(PortableServer::POA::ServantAlreadyActive&)
147 INFOS("Caught CORBA::ServantAlreadyActiveException");
149 catch(CORBA::Exception&)
151 INFOS("Caught CORBA::Exception.");
153 catch(std::exception& exc)
155 INFOS("Caught std::exception - "<<exc.what());
159 INFOS("Caught unknown exception.");