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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MPIObject_i.cxx
27 #include "MPIObject_i.hxx"
28 #include "utilities.h"
32 MPIObject_i::MPIObject_i()
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* 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_var pobj,
73 MPI_Status status; /* status de reception de message MPI */
75 // Conversion IOR vers string
76 CORBA::String_var sior(orb->object_to_string(pobj));
80 //Allocation du tableau des IOR
81 Engines::IORTab *iort = new Engines::IORTab;
82 iort->length(_nbproc);
86 // Process 0 recupere les ior de l'object sur les autres process
87 for(ip=1;ip<_nbproc;ip++){
88 err = MPI_Recv(&n,1,MPI_INTEGER,ip,ip,MPI_COMM_WORLD,&status);
90 MESSAGE("[" << _numproc << "] MPI_RECV error");
93 // Allocation de la chaine de longueur n
94 ior = (char*)calloc(n,sizeof(char));
95 err = MPI_Recv(ior,n,MPI_CHARACTER,ip,2*ip,MPI_COMM_WORLD,&status);
97 MESSAGE("[" << _numproc << "] MPI_RECV error");
100 (*iort)[ip] = Engines::MPIObject::_narrow(orb->string_to_object(ior));
103 // On donne le tableau des ior a l'objet Corba du process 0
111 // On envoie l'IOR au process 0
114 err = MPI_Send(&n,1,MPI_INTEGER,0,_numproc,MPI_COMM_WORLD);
116 MESSAGE("[" << _numproc << "] MPI_SEND error");
119 err = MPI_Send(ior,n,MPI_CHARACTER,0,2*_numproc,MPI_COMM_WORLD);
121 MESSAGE("[" << _numproc << "] MPI_SEND error");
126 MPI_Barrier(MPI_COMM_WORLD);