Salome HOME
Copyright update 2021
[tools/medcoupling.git] / src / ParaMEDMEM / CommInterface.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "CommInterface.hxx"
21
22 namespace MEDCoupling
23 {
24   MPI_Datatype ParaTraits<double>::MPIDataType = MPI_DOUBLE;
25
26   MPI_Datatype ParaTraits<Int32>::MPIDataType = MPI_INT;
27
28   MPI_Datatype ParaTraits<Int64>::MPIDataType = MPI_LONG;
29
30   void CommInterface::gatherArrays(MPI_Comm comm, int root, const DataArrayIdType *array, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
31   {
32     this->gatherArraysT2<mcIdType>(comm,root,array,arraysOut);
33   }
34
35   /*!
36    * Generalized AllGather collective communication.
37    * This method send input \a array to all procs.
38    */
39   void CommInterface::allGatherArrays(MPI_Comm comm, const DataArrayIdType *array, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
40   {
41     this->allGatherArraysT2<mcIdType>(comm,array,arraysOut);
42   }
43
44   /*!
45    * Generalized AllGather collective communication.
46    * This method send input \a array to all procs.
47    */
48   int CommInterface::allGatherArrays(MPI_Comm comm, const DataArrayIdType *array, std::unique_ptr<mcIdType[]>& result, std::unique_ptr<mcIdType[]>& resultIndex) const
49   {
50     return this->allGatherArraysT<mcIdType>(comm,array,result,resultIndex);
51   }
52
53   void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayDouble> >& arrays, std::vector< MCAuto<DataArrayDouble> >& arraysOut) const
54   {
55     this->allToAllArraysT<double>(comm,arrays,arraysOut);
56   }
57
58   void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayDouble> >& arrays, MCAuto<DataArrayDouble>& arraysOut) const
59   {
60     std::unique_ptr<mcIdType[]> notUsed1;
61     mcIdType notUsed2;
62     this->allToAllArraysT2<double>(comm,arrays,arraysOut,notUsed1,notUsed2);
63   }
64
65   /*!
66   * Generalized AllToAll collective communication.
67   */
68   void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayIdType> >& arrays, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
69   {
70     this->allToAllArraysT<mcIdType>(comm,arrays,arraysOut);
71   }
72
73 }