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 
40 class 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 
187  Address getMemoryBaseRead(const Size coreId) const;
188 
196  Address getMemoryBaseWrite(const Size coreId) const;
197 
198  private:
199 
202 
205 
208 
211 
214 };
215 
221 #endif /* __LIB_LIBMPI_MPITARGET_H */
MpiTarget::MaximumChannels
static const Size MaximumChannels
Maximum number of communication channels.
Definition: MpiTarget.h:45
Memory::Range
Memory range.
Definition: Memory.h:55
Types.h
MpiTarget::initializeSlave
Result initializeSlave(int *argc, char ***argv)
Initialize a slave.
Definition: MpiTarget.cpp:299
MPI_Comm
uint MPI_Comm
Communicator identifier.
Definition: mpi.h:38
Index.h
MpiBackend::Result
int Result
Result code.
Definition: MpiBackend.h:47
MpiTarget::getCommRank
virtual Result getCommRank(MPI_Comm comm, int *rank)
Retrieve communication rank (core id)
Definition: MpiTarget.cpp:64
Index< MemoryChannel, MaximumChannels >
MpiTarget::m_readChannels
Index< MemoryChannel, MaximumChannels > m_readChannels
Stores all channels for receiving data from other cores.
Definition: MpiTarget.h:210
Address
unsigned long Address
A memory address.
Definition: Types.h:131
MpiTarget::createWriteChannel
Result createWriteChannel(const Size coreId, const Address memoryBase)
Create a new MPI channel for writing.
Definition: MpiTarget.cpp:367
MpiTarget::m_coreId
Size m_coreId
Core identifier is a unique number on each core.
Definition: MpiTarget.h:201
MpiTarget::m_coreCount
Size m_coreCount
Total number of cores.
Definition: MpiTarget.h:204
MPI_Status
uint MPI_Status
Status holder.
Definition: mpi.h:41
MpiBackend.h
MpiTarget::m_memChannelBase
Memory::Range m_memChannelBase
Memory base address for local MPI communication.
Definition: MpiTarget.h:207
MpiTarget::initializeMaster
Result initializeMaster(int *argc, char ***argv)
Initialize the master.
Definition: MpiTarget.cpp:159
MpiTarget::createReadChannel
Result createReadChannel(const Size coreId, const Address memoryBase)
Create a new MPI channel for reading.
Definition: MpiTarget.cpp:345
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
MPI_Datatype
MPI_Datatype
Named Predefined Datatypes.
Definition: mpi.h:46
MpiTarget::getMemoryBaseWrite
Address getMemoryBaseWrite(const Size coreId) const
Get memory address for MPI write communication.
Definition: MpiTarget.cpp:405
MpiTarget::getCommSize
virtual Result getCommSize(MPI_Comm comm, int *size)
Retrieve communication size (total cores)
Definition: MpiTarget.cpp:71
MpiTarget::terminate
virtual Result terminate()
Terminate the backend.
Definition: MpiTarget.cpp:59
MpiBackend
Represents a Message Passing Interface (MPI) implementation backend.
Definition: MpiBackend.h:36
MpiTarget::initialize
virtual Result initialize(int *argc, char ***argv)
Initialize the backend.
Definition: MpiTarget.cpp:44
MemoryChannel.h
MpiTarget::m_writeChannels
Index< MemoryChannel, MaximumChannels > m_writeChannels
Stores all channels for sending data to other cores.
Definition: MpiTarget.h:213
MpiTarget::getMemoryBaseRead
Address getMemoryBaseRead(const Size coreId) const
Get memory address for MPI read communication.
Definition: MpiTarget.cpp:389
MpiTarget::receive
virtual Result receive(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Synchronous receive data.
Definition: MpiTarget.cpp:118
MpiTarget::MpiTarget
MpiTarget()
Constructor.
Definition: MpiTarget.cpp:37
MpiTarget
Implements a Message Passing Interface (MPI) for communication between local cores.
Definition: MpiTarget.h:40
coreId
u8 coreId
Definition: IntelACPI.h:64
MpiTarget::send
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