FreeNOS
MpiTarget.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_MPITARGET_H
19#define __LIB_LIBMPI_MPITARGET_H
20
21#include <Types.h>
22#include <Index.h>
23#include <MemoryChannel.h>
24#include "MpiBackend.h"
25
40class MpiTarget : public MpiBackend
41{
42 private:
43
45 static const Size MaximumChannels = 128u;
46
47 public:
48
52 MpiTarget();
53
62 virtual Result initialize(int *argc,
63 char ***argv);
64
70 virtual Result terminate();
71
80 virtual Result getCommRank(MPI_Comm comm,
81 int *rank);
82
91 virtual Result getCommSize(MPI_Comm comm,
92 int *size);
93
106 virtual Result send(const void *buf,
107 int count,
108 MPI_Datatype datatype,
109 int dest,
110 int tag,
111 MPI_Comm comm);
112
126 virtual Result receive(void *buf,
127 int count,
128 MPI_Datatype datatype,
129 int source,
130 int tag,
131 MPI_Comm comm,
132 MPI_Status *status);
133
134 private:
135
144 Result initializeMaster(int *argc,
145 char ***argv);
146
155 Result initializeSlave(int *argc,
156 char ***argv);
157
167 const Address memoryBase);
168
178 const Address memoryBase);
179
188
197
198 private:
199
202
205
208
211
214};
215
221#endif /* __LIB_LIBMPI_MPITARGET_H */
u8 coreId
Definition IntelACPI.h:1
Index is a N-sized array of pointers to items of type T.
Definition Index.h:37
Represents a Message Passing Interface (MPI) implementation backend.
Definition MpiBackend.h:37
int Result
Result code.
Definition MpiBackend.h:47
Implements a Message Passing Interface (MPI) for communication between local cores.
Definition MpiTarget.h:41
Index< MemoryChannel, MaximumChannels > m_readChannels
Stores all channels for receiving data from other cores.
Definition MpiTarget.h:210
Result createReadChannel(const Size coreId, const Address memoryBase)
Create a new MPI channel for reading.
Index< MemoryChannel, MaximumChannels > m_writeChannels
Stores all channels for sending data to other cores.
Definition MpiTarget.h:213
virtual Result getCommRank(MPI_Comm comm, int *rank)
Retrieve communication rank (core id)
Definition MpiTarget.cpp:64
Result initializeSlave(int *argc, char ***argv)
Initialize a slave.
virtual Result initialize(int *argc, char ***argv)
Initialize the backend.
Definition MpiTarget.cpp:44
MpiTarget()
Constructor.
Definition MpiTarget.cpp:37
static const Size MaximumChannels
Maximum number of communication channels.
Definition MpiTarget.h:45
virtual Result terminate()
Terminate the backend.
Definition MpiTarget.cpp:59
Address getMemoryBaseRead(const Size coreId) const
Get memory address for MPI read communication.
Size m_coreCount
Total number of cores.
Definition MpiTarget.h:204
virtual Result send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Synchronous send data.
Definition MpiTarget.cpp:78
Result initializeMaster(int *argc, char ***argv)
Initialize the master.
virtual Result getCommSize(MPI_Comm comm, int *size)
Retrieve communication size (total cores)
Definition MpiTarget.cpp:71
Memory::Range m_memChannelBase
Memory base address for local MPI communication.
Definition MpiTarget.h:207
virtual Result receive(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Synchronous receive data.
Result createWriteChannel(const Size coreId, const Address memoryBase)
Create a new MPI channel for writing.
Size m_coreId
Core identifier is a unique number on each core.
Definition MpiTarget.h:201
Address getMemoryBaseWrite(const Size coreId) const
Get memory address for MPI write communication.
MPI_Datatype
Named Predefined Datatypes.
Definition mpi.h:47
uint MPI_Status
Status holder.
Definition mpi.h:41
uint MPI_Comm
Communicator identifier.
Definition mpi.h:38
unsigned long Address
A memory address.
Definition Types.h:131
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Memory range.
Definition Memory.h:56