1 // SALOME MPIContainer : implemenation of container based on MPI libraries
3 // Copyright (C) 2003 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : MPIObject_i.cxx
28 #include "MPIObject_i.hxx"
29 #include "utilities.h"
32 MPIObject_i::MPIObject_i()
34 MPI_Comm_size( MPI_COMM_WORLD, &_nbproc );
35 MPI_Comm_rank( MPI_COMM_WORLD, &_numproc );
39 MPIObject_i::MPIObject_i(int nbproc, int numproc)
46 MPIObject_i::~MPIObject_i()
48 if(_tior) delete _tior;
51 Engines::IORTab* MPIObject_i::tior()
53 Engines::IORTab_var tior = new Engines::IORTab;
54 tior->length(_tior->length());
55 for(unsigned int ip=0;ip<tior->length();ip++)
56 tior[ip] = (*_tior)[ip];
60 void MPIObject_i::tior(const Engines::IORTab& ior)
62 _tior = new Engines::IORTab;
63 _tior->length(ior.length());
64 for(unsigned int ip=0;ip<ior.length();ip++)
65 (*_tior)[ip] = ior[ip];
68 void MPIObject_i::BCastIOR(CORBA::ORB_ptr orb, Engines::MPIObject_ptr pobj,
73 MPI_Status status; /* status de reception de message MPI */
77 //Allocation du tableau des IOR
78 Engines::IORTab_var iort = new Engines::IORTab;
79 iort->length(_nbproc);
83 // Process 0 recupere les ior de l'object sur les autres process
84 for(ip=1;ip<_nbproc;ip++){
85 err = MPI_Recv(&n,1,MPI_INT,ip,ip,MPI_COMM_WORLD,&status);
87 MESSAGE("[" << _numproc << "] MPI_RECV error");
90 // Allocation de la chaine de longueur n
92 err = MPI_Recv(ior,n,MPI_CHAR,ip,2*ip,MPI_COMM_WORLD,&status);
94 MESSAGE("[" << _numproc << "] MPI_RECV error");
97 iort[ip] = orb->string_to_object(ior);
100 // On donne le tableau des ior a l'objet Corba du process 0
102 tior(*(iort._retn()));
104 pobj->tior(*(iort._retn()));
108 // Conversion IOR vers string
109 ior = orb->object_to_string(pobj);
111 // On envoie l'IOR au process 0
112 err = MPI_Send(&n,1,MPI_INT,0,_numproc,MPI_COMM_WORLD);
114 MESSAGE("[" << _numproc << "] MPI_SEND error");
117 err = MPI_Send(ior,n,MPI_CHAR,0,2*_numproc,MPI_COMM_WORLD);
119 MESSAGE("[" << _numproc << "] MPI_SEND error");
122 CORBA::string_free(ior);