FreeNOS
MpiHost.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_MPIHOST_H
19#define __LIB_LIBMPI_MPIHOST_H
20
21#include <arpa/inet.h>
22#include <netinet/in.h>
23#include <Types.h>
24#include <Index.h>
25#include <List.h>
26#include "MpiBackend.h"
27
39class MpiHost : public MpiBackend
40{
41 private:
42
44 static const Size MaximumNodes = 512;
45
46 private:
47
51 struct Node
52 {
53 in_addr_t ipAddress;
56 };
57
61 struct Packet
62 {
65 };
66
67 public:
68
72 MpiHost();
73
82 virtual Result initialize(int *argc,
83 char ***argv);
84
90 virtual Result terminate();
91
100 virtual Result getCommRank(MPI_Comm comm,
101 int *rank);
102
111 virtual Result getCommSize(MPI_Comm comm,
112 int *size);
113
126 virtual Result send(const void *buf,
127 int count,
128 MPI_Datatype datatype,
129 int dest,
130 int tag,
131 MPI_Comm comm);
132
146 virtual Result receive(void *buf,
147 int count,
148 MPI_Datatype datatype,
149 int source,
150 int tag,
151 MPI_Comm comm,
152 MPI_Status *status);
153
154 private:
155
163 Result parseHostsFile(const char *hostsfile);
164
173 Result startProcesses(int argc,
174 char **argv);
175
185 Result sendPacket(const Size nodeId,
186 const void *packet,
187 const Size size) const;
188
199 Result receivePacket(const Size nodeId,
200 const MpiProxy::Operation operation,
201 void *packet,
202 Size & size);
203
204 private:
205
208
211
214};
215
221#endif /* __LIB_LIBMPI_MPIHOST_H */
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 MPI backend for the host OS which communicates with mpiproxy servers.
Definition MpiHost.h:40
Result startProcesses(int argc, char **argv)
Start remote processes.
Definition MpiHost.cpp:418
MpiHost()
Constructor.
Definition MpiHost.cpp:37
Index< List< Packet * >, MaximumNodes > m_packetBuffers
Buffers incoming packets for later processing.
Definition MpiHost.h:213
virtual Result initialize(int *argc, char ***argv)
Initialize the backend.
Definition MpiHost.cpp:41
static const Size MaximumNodes
Maximum number of supported nodes.
Definition MpiHost.h:44
Index< Node, MaximumNodes > m_nodes
Contains all known nodes that participate in the computation.
Definition MpiHost.h:210
int m_sock
UDP socket for communicating with remote nodes.
Definition MpiHost.h:207
virtual Result getCommRank(MPI_Comm comm, int *rank)
Retrieve communication rank (core id)
Definition MpiHost.cpp:156
Result parseHostsFile(const char *hostsfile)
Parse the given hosts file.
Definition MpiHost.cpp:315
virtual Result send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
Synchronous send data.
Definition MpiHost.cpp:170
virtual Result getCommSize(MPI_Comm comm, int *size)
Retrieve communication size (total cores)
Definition MpiHost.cpp:163
virtual Result receive(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
Synchronous receive data.
Definition MpiHost.cpp:236
virtual Result terminate()
Terminate the backend.
Definition MpiHost.cpp:105
Result receivePacket(const Size nodeId, const MpiProxy::Operation operation, void *packet, Size &size)
Receive UDP packet from remote node.
Definition MpiHost.cpp:537
Result sendPacket(const Size nodeId, const void *packet, const Size size) const
Send UDP packet to a remote node.
Definition MpiHost.cpp:506
Operation
Encodes various MPI operations.
Definition MpiProxy.h:72
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 int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned short u16
Unsigned 16-bit number.
Definition Types.h:56
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
unsigned char u8
Unsigned 8-bit number.
Definition Types.h:59
Describes a remote CPU node accessible via MPI.
Definition MpiHost.h:52
in_addr_t ipAddress
Definition MpiHost.h:53
u32 coreId
< UDP port of the node
Definition MpiHost.h:55
u16 udpPort
< IP address of the node
Definition MpiHost.h:54
Describes data received via UDP.
Definition MpiHost.h:62
Size size
< Payload data
Definition MpiHost.h:64