Back to index

salome-med  6.5.0
CommInterface.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __COMMINTERFACE_HXX__
00021 #define __COMMINTERFACE_HXX__
00022 
00023 #include <mpi.h>
00024 namespace ParaMEDMEM
00025 {
00026 
00027   class CommInterface
00028   {
00029   public:
00030     CommInterface(){}
00031     virtual ~CommInterface(){}
00032     int worldSize() const {
00033       int size;
00034       MPI_Comm_size(MPI_COMM_WORLD, &size);
00035       return size;}
00036     int commSize(MPI_Comm comm, int* size) const { return MPI_Comm_size(comm,size); }
00037     int commRank(MPI_Comm comm, int* rank) const { return MPI_Comm_rank(comm,rank); }
00038     int commGroup(MPI_Comm comm, MPI_Group* group) const { return MPI_Comm_group(comm, group); }
00039     int groupIncl(MPI_Group group, int size, int* ranks, MPI_Group* group_output) const { return MPI_Group_incl(group, size, ranks, group_output); }
00040     int commCreate(MPI_Comm comm, MPI_Group group, MPI_Comm* comm_output) const { return MPI_Comm_create(comm,group,comm_output); }
00041     int groupFree(MPI_Group* group) const { return MPI_Group_free(group); }
00042     int commFree(MPI_Comm* comm) const { return MPI_Comm_free(comm); }
00043 
00044     int send(void* buffer, int count, MPI_Datatype datatype, int target, int tag, MPI_Comm comm) const { return MPI_Send(buffer,count, datatype, target, tag, comm); }
00045     int recv(void* buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status) const { return MPI_Recv(buffer,count, datatype, source, tag, comm, status); }
00046     int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, 
00047                  int dest, int sendtag, void* recvbuf, int recvcount, 
00048                  MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm,
00049                  MPI_Status* status) { return MPI_Sendrecv(sendbuf, sendcount, sendtype, dest, sendtag, recvbuf, recvcount, recvtype, source, recvtag, comm,status); }
00050 
00051     int Isend(void* buffer, int count, MPI_Datatype datatype, int target,
00052               int tag, MPI_Comm comm, MPI_Request *request) const { return MPI_Isend(buffer,count, datatype, target, tag, comm, request); }
00053     int Irecv(void* buffer, int count, MPI_Datatype datatype, int source,
00054               int tag, MPI_Comm comm, MPI_Request* request) const { return MPI_Irecv(buffer,count, datatype, source, tag, comm, request); }
00055 
00056     int wait(MPI_Request *request, MPI_Status *status) const { return MPI_Wait(request, status); }
00057     int test(MPI_Request *request, int *flag, MPI_Status *status) const { return MPI_Test(request, flag, status); }
00058     int requestFree(MPI_Request *request) const { return MPI_Request_free(request); }
00059     int waitany(int count, MPI_Request *array_of_requests, int *index, MPI_Status *status) const { return MPI_Waitany(count, array_of_requests, index, status); }
00060     int testany(int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status) const { return MPI_Testany(count, array_of_requests, index, flag, status); }
00061     int waitall(int count, MPI_Request *array_of_requests, MPI_Status *array_of_status) const { return MPI_Waitall(count, array_of_requests, array_of_status); }
00062     int testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_status) const { return MPI_Testall(count, array_of_requests, flag, array_of_status); }
00063     int waitsome(int incount, MPI_Request *array_of_requests,int *outcount, int *array_of_indices, MPI_Status *array_of_status) const { return MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_status); }
00064     int testsome(int incount, MPI_Request *array_of_requests, int *outcount,
00065                  int *array_of_indices, MPI_Status *array_of_status) const { return MPI_Testsome(incount, array_of_requests, outcount, array_of_indices, array_of_status); }
00066     int probe(int source, int tag, MPI_Comm comm, MPI_Status *status) const { return MPI_Probe(source, tag, comm, status) ; }
00067     int Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status) const { return MPI_Iprobe(source, tag, comm, flag, status) ; }
00068     int cancel(MPI_Request *request) const { return MPI_Cancel(request); }
00069     int testCancelled(MPI_Status *status, int *flag) const { return MPI_Test_cancelled(status, flag); }
00070     int barrier(MPI_Comm comm) const { return MPI_Barrier(comm); }
00071     int errorString(int errorcode, char *string, int *resultlen) const { return MPI_Error_string(errorcode, string, resultlen); }
00072     int getCount(MPI_Status *status, MPI_Datatype datatype, int *count) const { return MPI_Get_count(status, datatype, count); }
00073 
00074     int broadcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) const { return MPI_Bcast(buffer, count,  datatype, root, comm); }
00075     int allGather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
00076                   void* recvbuf, int recvcount, MPI_Datatype recvtype,
00077                   MPI_Comm comm) const { return MPI_Allgather(sendbuf,sendcount, sendtype, recvbuf, recvcount, recvtype, comm); }
00078     int allToAll(void* sendbuf, int sendcount, MPI_Datatype sendtype,
00079                  void* recvbuf, int recvcount, MPI_Datatype recvtype,
00080                  MPI_Comm comm) const { return MPI_Alltoall(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); }
00081     int allToAllV(void* sendbuf, int* sendcounts, int* senddispls,
00082                   MPI_Datatype sendtype, void* recvbuf, int* recvcounts,
00083                   int* recvdispls, MPI_Datatype recvtype, 
00084                   MPI_Comm comm) const { return MPI_Alltoallv(sendbuf, sendcounts, senddispls, sendtype, recvbuf, recvcounts, recvdispls, recvtype, comm); }
00085 
00086     int reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype,
00087                MPI_Op op, int root, MPI_Comm comm) const { return MPI_Reduce(sendbuf, recvbuf, count, datatype, op, root, comm); }
00088     int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const { return MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm); }
00089   };
00090 }
00091 
00092 #endif /*COMMINTERFACE_HXX_*/