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 "SALOME_ParallelContainerProxy_i.hxx"
40 #include <paco_omni.h>
45 #include "SALOME_NamingService.hxx"
47 #include "utilities.h"
48 #include "Utils_ORB_INIT.hxx"
49 #include "Utils_SINGLETON.hxx"
50 #include "SALOMETraceCollector.hxx"
58 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
59 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
60 cerr << "SIGSEGV in :" << getpid() << endl;
61 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
62 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
67 int main(int argc, char* argv[])
69 INFOS("Launching a parallel Mpi proxy container");
72 signal(SIGSEGV, handler);
77 MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
78 CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
80 std::string containerName("");
81 containerName = argv[1];
83 sscanf(argv[2],"%d",&nb_nodes);
86 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
87 ASSERT(!CORBA::is_nil(obj));
88 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
89 PortableServer::POAManager_var pman = root_poa->the_POAManager();
92 // add this container to the kill list
94 sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
98 SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
99 // Engines::Container_proxy_impl * proxy =
100 // new Engines::Container_proxy_impl(orb,
101 // new paco_omni_fabrique());
102 Container_proxy_impl_final * proxy =
103 new Container_proxy_impl_final(orb,
104 new paco_omni_fabrique());
107 paco_fabrique_manager* pfm = paco_getFabriqueManager();
108 pfm->register_com("mpi", new paco_mpi_fabrique());
109 MPI_Comm group = MPI_COMM_WORLD;
110 proxy->setLibCom("mpi", &group);
111 pfm->register_thread("omnithread", new paco_omni_fabrique());
112 proxy->setLibThread("omnithread");
113 PaCO::PacoTopology_t serveur_topo;
114 serveur_topo.total = nb_nodes;
115 proxy->setTopology(serveur_topo);
118 PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
119 obj = root_poa->id_to_reference(_id);
121 // in the NamingService
122 string hostname = GetHostname();
123 Engines::Container_var pCont = Engines::Container::_narrow(obj);
124 string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
126 cerr << "---------" << _containerName << "----------" << endl;
127 ns->Register(pCont, _containerName.c_str());
131 catch (PaCO::PACO_Exception& e)
133 INFOS("Caught PaCO::PACO_Exception");
134 std::cerr << e << std::endl;
136 catch(CORBA::SystemException&)
138 INFOS("Caught CORBA::SystemException.");
140 catch(PortableServer::POA::ServantAlreadyActive&)
142 INFOS("Caught CORBA::ServantAlreadyActiveException");
144 catch(CORBA::Exception&)
146 INFOS("Caught CORBA::Exception.");
148 catch(std::exception& exc)
150 INFOS("Caught std::exception - "<<exc.what());
154 INFOS("Caught unknown exception.");