FreeNOS
Data Structures | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
MpiHost Class Reference

Implements a MPI backend for the host OS which communicates with mpiproxy servers. More...

#include <MpiHost.h>

Inheritance diagram for MpiHost:
MpiBackend AbstractFactory< MpiBackend >

Data Structures

struct  Node
 Describes a remote CPU node accessible via MPI. More...
 
struct  Packet
 Describes data received via UDP. More...
 

Public Member Functions

 MpiHost ()
 Constructor. More...
 
virtual Result initialize (int *argc, char ***argv)
 Initialize the backend. More...
 
virtual Result terminate ()
 Terminate the backend. More...
 
virtual Result getCommRank (MPI_Comm comm, int *rank)
 Retrieve communication rank (core id) More...
 
virtual Result getCommSize (MPI_Comm comm, int *size)
 Retrieve communication size (total cores) More...
 
virtual Result send (const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
 Synchronous send data. More...
 
virtual Result receive (void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
 Synchronous receive data. More...
 

Private Member Functions

Result parseHostsFile (const char *hostsfile)
 Parse the given hosts file. More...
 
Result startProcesses (int argc, char **argv)
 Start remote processes. More...
 
Result sendPacket (const Size nodeId, const void *packet, const Size size) const
 Send UDP packet to a remote node. More...
 
Result receivePacket (const Size nodeId, const MpiProxy::Operation operation, void *packet, Size &size)
 Receive UDP packet from remote node. More...
 

Private Attributes

int m_sock
 UDP socket for communicating with remote nodes. More...
 
Index< Node, MaximumNodesm_nodes
 Contains all known nodes that participate in the computation. More...
 
Index< List< Packet * >, MaximumNodesm_packetBuffers
 Buffers incoming packets for later processing. More...
 

Static Private Attributes

static const Size MaximumNodes = 512
 Maximum number of supported nodes. More...
 

Additional Inherited Members

- Public Types inherited from MpiBackend
typedef int Result
 Result code. More...
 
- Static Public Member Functions inherited from AbstractFactory< MpiBackend >
static MpiBackendcreate ()
 Abstract function to create an instance of T. More...
 

Detailed Description

Implements a MPI backend for the host OS which communicates with mpiproxy servers.

Definition at line 39 of file MpiHost.h.

Constructor & Destructor Documentation

◆ MpiHost()

MpiHost::MpiHost ( )

Constructor.

Definition at line 37 of file MpiHost.cpp.

Member Function Documentation

◆ getCommRank()

MpiHost::Result MpiHost::getCommRank ( MPI_Comm  comm,
int *  rank 
)
virtual

Retrieve communication rank (core id)

Parameters
commCommunication reference
rankOutput the communication rank number
Returns
Result code

Implements MpiBackend.

Definition at line 156 of file MpiHost.cpp.

References MPI_SUCCESS.

◆ getCommSize()

MpiHost::Result MpiHost::getCommSize ( MPI_Comm  comm,
int *  size 
)
virtual

Retrieve communication size (total cores)

Parameters
commCommunication reference
sizeOutput the communication size
Returns
Result code

Implements MpiBackend.

Definition at line 163 of file MpiHost.cpp.

References m_nodes, and MPI_SUCCESS.

◆ initialize()

MpiHost::Result MpiHost::initialize ( int *  argc,
char ***  argv 
)
virtual

Initialize the backend.

Parameters
argcArgument count pointer
argvArgument values array pointer
Returns
Result code

Implements MpiBackend.

Definition at line 41 of file MpiHost.cpp.

References MpiHost::Node::coreId, errno, ERROR, MpiHost::Node::ipAddress, m_nodes, m_sock, memset(), MPI_ERR_ARG, MPI_ERR_IO, MPI_SUCCESS, parseHostsFile(), startProcesses(), strerror(), and MpiHost::Node::udpPort.

◆ parseHostsFile()

MpiHost::Result MpiHost::parseHostsFile ( const char *  hostsfile)
private

Parse the given hosts file.

Parameters
hostsfilePath to the hosts file to parse
Returns
Result code

Definition at line 315 of file MpiHost.cpp.

References atoi(), MpiHost::Node::coreId, List< T >::count(), DEBUG, errno, ERROR, fclose(), fopen(), fread(), ListIterator< T >::hasCurrent(), MpiHost::Node::ipAddress, m_nodes, m_packetBuffers, MPI_ERR_ARG, MPI_ERR_IO, MPI_ERR_NO_MEM, MPI_SUCCESS, NULL, String::split(), stat::st_size, stat(), strerror(), and MpiHost::Node::udpPort.

Referenced by initialize().

◆ receive()

MpiHost::Result MpiHost::receive ( void *  buf,
int  count,
MPI_Datatype  datatype,
int  source,
int  tag,
MPI_Comm  comm,
MPI_Status status 
)
virtual

Synchronous receive data.

Parameters
bufOutput data buffer
countNumber of data items
datatypeType of data
sourceSource to receive data from (core id)
tagOptional data identifier to receive
commCommunication reference
statusOutput the MPI status
Returns
Result code

Implements MpiBackend.

Definition at line 236 of file MpiHost.cpp.

References MpiHost::Node::coreId, MpiProxy::Header::coreId, MpiProxy::Header::datacount, MpiProxy::Header::datatype, ERROR, header, m_nodes, MpiProxy::MaximumPacketSize, MPI_ERR_RANK, MPI_ERR_UNSUPPORTED_DATAREP, MPI_INT, MPI_SUCCESS, MPI_UNSIGNED_CHAR, MpiProxy::MpiOpRecv, MpiProxy::Header::operation, MpiProxy::Header::rankId, receivePacket(), sendPacket(), and ZERO.

◆ receivePacket()

MpiHost::Result MpiHost::receivePacket ( const Size  nodeId,
const MpiProxy::Operation  operation,
void *  packet,
Size size 
)
private

Receive UDP packet from remote node.

Parameters
nodeIdIdentification number of the node to receive from
operationExpected MPI operation value of the packet
packetPayload output
sizeOutput for number of bytes received
Returns
Result code

Definition at line 537 of file MpiHost.cpp.

References MemoryBlock::copy(), MpiHost::Node::coreId, MpiProxy::Header::coreId, MpiHost::Packet::data, DEBUG, errno, ERROR, ListIterator< T >::hasCurrent(), MpiHost::Node::ipAddress, m_nodes, m_packetBuffers, m_sock, MPI_ERR_ARG, MPI_ERR_IO, MPI_ERR_NO_MEM, MPI_SUCCESS, MpiProxy::Header::operation, MpiProxy::Header::rankId, recvfrom(), MpiHost::Packet::size, strerror(), MpiHost::Node::udpPort, and ZERO.

Referenced by receive(), startProcesses(), and terminate().

◆ send()

MpiHost::Result MpiHost::send ( const void *  buf,
int  count,
MPI_Datatype  datatype,
int  dest,
int  tag,
MPI_Comm  comm 
)
virtual

Synchronous send data.

Parameters
bufInput data buffer
countNumber of data items
datatypeType of data
destDestination to send to (core id)
tagOptional data identifier to send
commCommunication reference
Returns
Result code

Implements MpiBackend.

Definition at line 170 of file MpiHost.cpp.

References MemoryBlock::copy(), MpiHost::Node::coreId, MpiProxy::Header::coreId, MpiProxy::Header::datacount, MpiProxy::Header::datatype, ERROR, m_nodes, MpiProxy::MaximumPacketSize, MPI_ERR_ARG, MPI_INT, MPI_SUCCESS, MPI_UNSIGNED_CHAR, MpiProxy::MpiOpSend, MpiProxy::Header::operation, MpiProxy::Header::rankId, MpiProxy::Header::result, sendPacket(), and ZERO.

◆ sendPacket()

MpiHost::Result MpiHost::sendPacket ( const Size  nodeId,
const void *  packet,
const Size  size 
) const
private

Send UDP packet to a remote node.

Parameters
nodeIdIdentification number of the node
packetBuffer with data to send
sizeNumber of bytes to send
Returns
Result code

Definition at line 506 of file MpiHost.cpp.

References DEBUG, errno, ERROR, MpiHost::Node::ipAddress, m_nodes, m_sock, MPI_ERR_ARG, MPI_ERR_IO, MPI_SUCCESS, sendto(), strerror(), MpiHost::Node::udpPort, and ZERO.

Referenced by receive(), send(), startProcesses(), and terminate().

◆ startProcesses()

MpiHost::Result MpiHost::startProcesses ( int  argc,
char **  argv 
)
private

Start remote processes.

Parameters
argcArgument count passed to remote program
argvArgument values passed to remote program
Returns
Result code

Definition at line 418 of file MpiHost.cpp.

References basename(), MemoryBlock::copy(), MpiProxy::Header::coreCount, coreId, MpiProxy::Header::coreId, DEBUG, ERROR, String::length(), m_nodes, MpiProxy::MaximumPacketSize, MPI_SUCCESS, MpiProxy::MpiOpExec, NOTICE, MpiProxy::Header::operation, MpiProxy::Header::rankId, receivePacket(), MpiProxy::Header::result, and sendPacket().

Referenced by initialize().

◆ terminate()

MpiHost::Result MpiHost::terminate ( )
virtual

Field Documentation

◆ m_nodes

Index<Node, MaximumNodes> MpiHost::m_nodes
private

Contains all known nodes that participate in the computation.

Definition at line 210 of file MpiHost.h.

Referenced by getCommSize(), initialize(), parseHostsFile(), receive(), receivePacket(), send(), sendPacket(), startProcesses(), and terminate().

◆ m_packetBuffers

Index<List<Packet *>, MaximumNodes> MpiHost::m_packetBuffers
private

Buffers incoming packets for later processing.

Definition at line 213 of file MpiHost.h.

Referenced by parseHostsFile(), and receivePacket().

◆ m_sock

int MpiHost::m_sock
private

UDP socket for communicating with remote nodes.

Definition at line 207 of file MpiHost.h.

Referenced by initialize(), receivePacket(), and sendPacket().

◆ MaximumNodes

const Size MpiHost::MaximumNodes = 512
staticprivate

Maximum number of supported nodes.

Definition at line 44 of file MpiHost.h.


The documentation for this class was generated from the following files: