FreeNOS
MpiBackend.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __LIB_LIBMPI_MPIBACKEND_H
19 #define __LIB_LIBMPI_MPIBACKEND_H
20 
21 #include <Types.h>
22 #include <Factory.h>
23 #include "mpi.h"
24 
36 class MpiBackend : public AbstractFactory<MpiBackend>
37 {
38  public:
39 
47  typedef int Result;
48 
49  public:
50 
59  virtual Result initialize(int *argc,
60  char ***argv) = 0;
61 
67  virtual Result terminate() = 0;
68 
77  virtual Result getCommRank(MPI_Comm comm,
78  int *rank) = 0;
79 
88  virtual Result getCommSize(MPI_Comm comm,
89  int *size) = 0;
90 
103  virtual Result send(const void *buf,
104  int count,
105  MPI_Datatype datatype,
106  int dest,
107  int tag,
108  MPI_Comm comm) = 0;
109 
123  virtual Result receive(void *buf,
124  int count,
125  MPI_Datatype datatype,
126  int source,
127  int tag,
128  MPI_Comm comm,
129  MPI_Status *status) = 0;
130 };
131 
137 #endif /* __LIB_LIBMPI_MPIBACKEND_H */
Types.h
MPI_Comm
uint MPI_Comm
Communicator identifier.
Definition: mpi.h:38
MpiBackend::Result
int Result
Result code.
Definition: MpiBackend.h:47
AbstractFactory
Abstract Factory pattern providing a creation function declaration.
Definition: Factory.h:50
MPI_Status
uint MPI_Status
Status holder.
Definition: mpi.h:41
MpiBackend::getCommSize
virtual Result getCommSize(MPI_Comm comm, int *size)=0
Retrieve communication size (total cores)
MpiBackend::terminate
virtual Result terminate()=0
Terminate the backend.
MpiBackend::getCommRank
virtual Result getCommRank(MPI_Comm comm, int *rank)=0
Retrieve communication rank (core id)
MpiBackend::initialize
virtual Result initialize(int *argc, char ***argv)=0
Initialize the backend.
mpi.h
MPI_Datatype
MPI_Datatype
Named Predefined Datatypes.
Definition: mpi.h:46
MpiBackend
Represents a Message Passing Interface (MPI) implementation backend.
Definition: MpiBackend.h:36
MpiBackend::receive
virtual Result receive(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)=0
Synchronous receive data.
Factory.h
MpiBackend::send
virtual Result send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)=0
Synchronous send data.