FreeNOS
mpi.cpp
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#include <Assert.h>
19#include "MpiBackend.h"
20#include "mpi.h"
21
23
24extern C int MPI_Init(int *argc, char ***argv)
25{
27 return mpiBackend->initialize(argc, argv);
28}
29
30extern C int MPI_Finalize(void)
31{
33 return mpiBackend->terminate();
34}
35
36extern C int MPI_Send(const void *buf,
37 int count,
38 MPI_Datatype datatype,
39 int dest,
40 int tag,
41 MPI_Comm comm)
42{
44 return mpiBackend->send(buf, count, datatype, dest, tag, comm);
45}
46
47extern C int MPI_Recv(void *buf,
48 int count,
49 MPI_Datatype datatype,
50 int source,
51 int tag,
52 MPI_Comm comm,
53 MPI_Status *status)
54{
56 return mpiBackend->receive(buf, count, datatype, source, tag, comm, status);
57}
58
59extern C int MPI_Comm_rank(MPI_Comm comm,
60 int *rank)
61{
63 return mpiBackend->getCommRank(comm, rank);
64}
65
66extern C int MPI_Comm_size(MPI_Comm comm,
67 int *size)
68{
70 return mpiBackend->getCommSize(comm, size);
71}
static MpiBackend * create()
Abstract function to create an instance of T.
Represents a Message Passing Interface (MPI) implementation backend.
Definition MpiBackend.h:37
virtual Result getCommSize(MPI_Comm comm, int *size)=0
Retrieve communication size (total cores)
virtual Result terminate()=0
Terminate the backend.
virtual Result receive(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)=0
Synchronous receive data.
virtual Result getCommRank(MPI_Comm comm, int *rank)=0
Retrieve communication rank (core id)
virtual Result send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)=0
Synchronous send data.
virtual Result initialize(int *argc, char ***argv)=0
Initialize the backend.
C int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Definition mpi.cpp:36
C int MPI_Comm_rank(MPI_Comm comm, int *rank)
Definition mpi.cpp:59
MPI_Datatype
Named Predefined Datatypes.
Definition mpi.h:47
C int MPI_Comm_size(MPI_Comm comm, int *size)
Definition mpi.cpp:66
C int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Definition mpi.cpp:47
C int MPI_Init(int *argc, char ***argv)
Definition mpi.cpp:24
uint MPI_Status
Status holder.
Definition mpi.h:41
uint MPI_Comm
Communicator identifier.
Definition mpi.h:38
C int MPI_Finalize(void)
Definition mpi.cpp:30
#define assert(exp)
Insert program diagnostics.
Definition assert.h:60
#define ZERO
Zero value.
Definition Macros.h:43
#define C
Used to define external C functions.
Definition Macros.h:134
static MpiBackend * mpiBackend
Definition mpi.cpp:22