]> SALOME platform Git repositories - tools/medcoupling.git/blobdiff - src/ParaMEDMEM/CommInterface.cxx
Salome HOME
refactor!: remove adm_local/ directory
[tools/medcoupling.git] / src / ParaMEDMEM / CommInterface.cxx
index abcfaddb8847287a6199775aa54ef4e1d5472121..04e3e8d425789c917423bb386576c592d4dba23d 100644 (file)
@@ -1,62 +1,73 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "CommInterface.hxx"
 
-namespace ParaMEDMEM
+namespace MEDCoupling
 {
-  /*! \defgroup comm_interface CommInterface
-    Class \a CommInterface is the gateway to the MPI library.
-    It is a helper class that gathers the calls to the MPI
-    library that are made in the ParaMEDMEM library. This gathering
-    allows easier gathering of information about the communication
-    in the library.
-
-    It is typically called after the MPI_Init() call in a program. It is afterwards passed as a parameter to the constructors of ParaMEDMEM objects so that they access the MPI library via the CommInterface.
-
-    As an example, the following code excerpt initializes a processor group made of the zero processor.
-
-    \verbatim
-    #include "CommInterface.hxx"
-    #include "ProcessorGroup.hxx"
-
-    int main(int argc, char** argv)
-    {
-    //initialization
-    MPI_Init(&argc, &argv);
-    ParaMEDMEM::CommInterface comm_interface;
-
-    //setting up a processor group with proc 0
-    set<int> procs;
-    procs.insert(0);
-    ParaMEDMEM::ProcessorGroup group(procs, comm_interface);
-
-    //cleanup
-    MPI_Finalize();
-    }
-    \endverbatim
-  */
+  MPI_Datatype ParaTraits<double>::MPIDataType = MPI_DOUBLE;
+
+  MPI_Datatype ParaTraits<Int32>::MPIDataType = MPI_INT;
+
+  MPI_Datatype ParaTraits<Int64>::MPIDataType = MPI_LONG;
+
+  void CommInterface::gatherArrays(MPI_Comm comm, int root, const DataArrayIdType *array, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
+  {
+    this->gatherArraysT2<mcIdType>(comm,root,array,arraysOut);
+  }
+
+  /*!
+   * Generalized AllGather collective communication.
+   * This method send input \a array to all procs.
+   */
+  void CommInterface::allGatherArrays(MPI_Comm comm, const DataArrayIdType *array, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
+  {
+    this->allGatherArraysT2<mcIdType>(comm,array,arraysOut);
+  }
 
-  CommInterface::CommInterface()
+  /*!
+   * Generalized AllGather collective communication.
+   * This method send input \a array to all procs.
+   */
+  int CommInterface::allGatherArrays(MPI_Comm comm, const DataArrayIdType *array, std::unique_ptr<mcIdType[]>& result, std::unique_ptr<mcIdType[]>& resultIndex) const
   {
+    return this->allGatherArraysT<mcIdType>(comm,array,result,resultIndex);
   }
 
-  CommInterface::~CommInterface()
+  void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayDouble> >& arrays, std::vector< MCAuto<DataArrayDouble> >& arraysOut) const
   {
+    this->allToAllArraysT<double>(comm,arrays,arraysOut);
   }
+
+  void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayDouble> >& arrays, MCAuto<DataArrayDouble>& arraysOut) const
+  {
+    std::unique_ptr<mcIdType[]> notUsed1;
+    mcIdType notUsed2;
+    this->allToAllArraysT2<double>(comm,arrays,arraysOut,notUsed1,notUsed2);
+  }
+
+  /*!
+  * Generalized AllToAll collective communication.
+  */
+  void CommInterface::allToAllArrays(MPI_Comm comm, const std::vector< MCAuto<DataArrayIdType> >& arrays, std::vector< MCAuto<DataArrayIdType> >& arraysOut) const
+  {
+    this->allToAllArraysT<mcIdType>(comm,arrays,arraysOut);
+  }
+
 }