FreeNOS
|
Server that bridges IP/UDP to local MPI communication channels. More...
#include <MpiProxy.h>
Data Structures | |
struct | Header |
Packet payload header for MPI messages via IP/UDP. More... | |
Public Types | |
enum | Operation { MpiOpSend = 0, MpiOpRecv, MpiOpExec, MpiOpTerminate } |
Encodes various MPI operations. More... | |
Public Types inherited from Application | |
enum | Result { Success, NotFound, IOError, InvalidArgument, ShowUsage, TimedOut, OutOfMemory } |
Result codes. More... | |
Public Member Functions | |
MpiProxy (int argc, char **argv) | |
Constructor. More... | |
virtual | ~MpiProxy () |
Destructor. More... | |
virtual Result | initialize () |
Initialize the server. More... | |
virtual Result | exec () |
Run the server. More... | |
Public Member Functions inherited from POSIXApplication | |
POSIXApplication (int argc, char **argv) | |
Class constructor. More... | |
virtual | ~POSIXApplication () |
Class destructor. More... | |
Public Member Functions inherited from Application | |
Application (int argc, char **argv) | |
Class constructor. More... | |
virtual | ~Application () |
Class destructor. More... | |
virtual int | run () |
Run the application. More... | |
Static Public Attributes | |
static const Size | MaximumPacketSize = 1448 |
Maximum size of packet payload. More... | |
Private Member Functions | |
Result | udpSend (const void *packet, const Size size, const struct sockaddr &addr) const |
Send UDP packet. More... | |
Result | udpSendMultiple (const struct iovec *vec, const Size count, const struct sockaddr &addr) const |
Send multiple UDP packets. More... | |
Result | udpReceive (void *packet, Size &size, struct sockaddr &addr) const |
Receive UDP packet. More... | |
Result | processRequest (const u8 *packet, const Size size, const struct sockaddr &addr) |
Process incoming packet. More... | |
Result | processSend (const Header *header, const u8 *packet, const Size size) |
Process MPI send request. More... | |
Result | processRecv (const Header *header, const u8 *packet, const Size size, const struct sockaddr &addr) |
Process MPI recv request. More... | |
Result | processExec (const Header *header, const u8 *packet, const Size size, const struct sockaddr &addr) |
Process execute request. More... | |
Result | processTerminate (const Header *header, const u8 *packet, const Size size, const struct sockaddr &addr) |
Process MPI terminate request. More... | |
Result | createChannels (const Size rankId, const Size coreCount) |
Create communication channels. More... | |
Result | startLocalProcess (const char *command, const Size rankId, const Size coreCount) |
Start a process on the local processor. More... | |
Result | startRemoteProcess (const Size coreId, const char *command, const Size rankId, const Size coreCount) |
Start a process on a secondary processor. More... | |
Private Attributes | |
int | m_sock |
IP/UDP socket for external communication. More... | |
NetworkClient * | m_client |
Networking client object. More... | |
Memory::Range | m_memChannelBase |
Memory base address for local MPI communication. More... | |
Index< MemoryChannel, MaximumChannels > | m_readChannels |
Stores all channels for receiving data from processes. More... | |
Index< MemoryChannel, MaximumChannels > | m_writeChannels |
Stores all channels for sending data to processes. More... | |
Array< ProcessID, MaximumChannels > | m_pids |
Records the PID of each process participating in the computation. More... | |
Static Private Attributes | |
static const u16 | UdpPort = 6660 |
Port number for IP/UDP traffic. More... | |
static const Size | ReceiveTimeoutMs = 500 |
Timeout in milliseconds to wait for packet receive. More... | |
static const Size | MaximumChannels = 128u |
Maximum number of supported MPI channels. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from POSIXApplication | |
virtual Result | output (const char *string) const |
Print text to output. More... | |
int | runProgram (const char *path, const char **argv) |
Runs an external program. More... | |
Protected Member Functions inherited from Application | |
virtual Result | output (String &string) const |
Print string to output. More... | |
ArgumentParser & | parser () |
Get program arguments parser. More... | |
const ArgumentParser & | parser () const |
Get constant program arguments parser. More... | |
const ArgumentContainer & | arguments () const |
Get program arguments. More... | |
void | setVersion (const String &version) |
Set program version. More... | |
Protected Attributes inherited from Application | |
int | m_argc |
Input argument count. More... | |
char ** | m_argv |
Input argument values. More... | |
Server that bridges IP/UDP to local MPI communication channels.
Definition at line 50 of file MpiProxy.h.
enum MpiProxy::Operation |
Encodes various MPI operations.
Enumerator | |
---|---|
MpiOpSend | |
MpiOpRecv | |
MpiOpExec | |
MpiOpTerminate |
Definition at line 71 of file MpiProxy.h.
MpiProxy::MpiProxy | ( | int | argc, |
char ** | argv | ||
) |
Constructor.
Definition at line 42 of file MpiProxy.cpp.
References ANY, Sequence< T >::fill(), m_memChannelBase, m_pids, Application::parser(), ArgumentParser::registerPositional(), MemoryBlock::set(), and ArgumentParser::setDescription().
|
virtual |
|
private |
Create communication channels.
rankId | Rank identifier |
coreCount | Total core count in the computation |
Definition at line 496 of file MpiProxy.cpp.
References Memory::Range::access, Channel::Consumer, DEBUG, ERROR, Index< T, N >::get(), Index< T, N >::insertAt(), Application::IOError, m_memChannelBase, m_readChannels, m_writeChannels, MapContiguous, NOTICE, Application::OutOfMemory, PAGESIZE, Memory::Range::phys, Channel::Producer, Memory::Readable, SELF, MemoryBlock::set(), MemoryChannel::setPhysical(), Memory::Range::size, Channel::Success, Application::Success, API::Success, MemoryChannel::unmap(), Memory::User, Memory::Range::virt, VMCtl(), Memory::Writable, and ZERO.
Referenced by processExec().
|
virtual |
Run the server.
Implements Application.
Definition at line 109 of file MpiProxy.cpp.
References sockaddr::addr, DEBUG, ERROR, MaximumPacketSize, processRequest(), Application::Success, Application::TimedOut, and udpReceive().
|
virtual |
Initialize the server.
Reimplemented from Application.
Definition at line 64 of file MpiProxy.cpp.
References Application::arguments(), NetworkClient::bindSocket(), NetworkClient::createSocket(), DEBUG, ERROR, ArgumentContainer::get(), NetworkClient::initialize(), Application::IOError, m_client, m_sock, Application::Success, NetworkClient::Success, NetworkClient::UDP, UdpPort, and ZERO.
|
private |
Process execute request.
header | Packet header pointer |
packet | Full packet input |
size | Number of bytes received |
addr | Source IP and port of the packet |
Definition at line 384 of file MpiProxy.cpp.
References MemoryBlock::copy(), MpiProxy::Header::coreId, createChannels(), DEBUG, ERROR, header, FileSystemPath::MaximumLength, MaximumPacketSize, MPI_ERR_IO, MPI_SUCCESS, MpiOpExec, MpiProxy::Header::operation, MpiProxy::Header::rankId, MpiProxy::Header::result, MemoryBlock::set(), startLocalProcess(), startRemoteProcess(), Application::Success, and udpSend().
Referenced by processRequest().
|
private |
Process MPI recv request.
header | Packet header pointer |
packet | Full packet input |
size | Number of bytes received |
addr | Source IP and port of the packet |
Definition at line 295 of file MpiProxy.cpp.
References assert, ERROR, header, MaximumPacketSize, NetworkQueue::MaxPackets, MPI_INT, MPI_UNSIGNED_CHAR, Application::NotFound, NOTICE, NetworkQueue::PayloadBufferSize, ProcessCtl(), Schedule, and SELF.
Referenced by processRequest().
|
private |
Process incoming packet.
packet | Payload input |
size | Number of bytes received |
addr | Source IP and port of the packet |
Definition at line 222 of file MpiProxy.cpp.
References DEBUG, ERROR, Number::Hex, MpiOpExec, MpiOpRecv, MpiOpSend, MpiOpTerminate, MpiProxy::Header::operation, processExec(), processRecv(), processSend(), processTerminate(), and Application::Success.
Referenced by exec().
|
private |
Process MPI send request.
header | Packet header pointer |
packet | Full packet input |
size | Number of bytes received |
Definition at line 252 of file MpiProxy.cpp.
References ERROR, Index< T, N >::get(), header, MPIMessage::integer, m_writeChannels, MPI_INT, MPI_UNSIGNED_CHAR, Application::NotFound, NOTICE, Channel::Success, Application::Success, MPIMessage::uchar, and MemoryChannel::write().
Referenced by processRequest().
|
private |
Process MPI terminate request.
header | Packet header pointer |
packet | Full packet input |
size | Number of bytes received |
addr | Source IP and port of the packet |
Definition at line 435 of file MpiProxy.cpp.
References ANY, MpiProxy::Header::coreId, ERROR, header, Array< T, N >::insert(), Application::IOError, m_memChannelBase, m_pids, MaximumPacketSize, MPI_SUCCESS, MpiOpTerminate, NOTICE, MpiProxy::Header::operation, MpiProxy::Header::rankId, Release, MpiProxy::Header::result, SELF, MemoryBlock::set(), Array< T, N >::size(), Application::Success, API::Success, udpSend(), Memory::Range::virt, VMCtl(), waitpid(), and ZERO.
Referenced by processRequest().
|
private |
Start a process on the local processor.
command | Command to execute |
rankId | Rank identifier |
coreCount | Total cores in the computation |
Definition at line 580 of file MpiProxy.cpp.
References List< T >::count(), ListIterator< T >::current(), DEBUG, Number::Dec, ERROR, ApplicationLauncher::exec(), ApplicationLauncher::getPid(), ListIterator< T >::hasCurrent(), Number::Hex, Array< T, N >::insert(), Application::IOError, m_memChannelBase, m_pids, NOTICE, Memory::Range::phys, String::split(), ApplicationLauncher::Success, Application::Success, and ZERO.
Referenced by processExec().
|
private |
Start a process on a secondary processor.
coreId | Core identifier of secondary processor |
command | Command to execute |
rankId | Rank identifier |
coreCount | Total cores in the computation |
Definition at line 642 of file MpiProxy.cpp.
References Memory::Range::access, assert, BufferedFile::buffer(), coreId, CoreClient::createProcess(), ListIterator< T >::current(), DEBUG, Number::Dec, ERROR, Lz4Decompressor::getUncompressedSize(), ListIterator< T >::hasCurrent(), Number::Hex, Lz4Decompressor::initialize(), Array< T, N >::insert(), Application::IOError, m_memChannelBase, m_pids, MapContiguous, Application::NotFound, NULL, Application::OutOfMemory, Memory::Range::phys, BufferedFile::read(), Lz4Decompressor::read(), Memory::Readable, Release, SELF, Memory::Range::size, BufferedFile::size(), String::split(), BufferedFile::Success, Core::Success, Application::Success, API::Success, Lz4Decompressor::Success, Memory::User, Memory::Range::virt, VMCtl(), and Memory::Writable.
Referenced by processExec().
|
private |
Receive UDP packet.
packet | Payload output |
size | Output for number of bytes received |
addr | Output for the source IP and port |
Definition at line 185 of file MpiProxy.cpp.
References sockaddr::addr, DEBUG, errno, ERROR, Application::IOError, m_client, m_sock, sockaddr::port, ReceiveTimeoutMs, recvfrom(), strerror(), Application::Success, NetworkClient::Success, Application::TimedOut, NetworkClient::TimedOut, IPV4::toString(), NetworkClient::UDP, and NetworkClient::waitSocket().
Referenced by exec().
|
private |
Send UDP packet.
packet | Payload input |
size | Number of bytes to send |
addr | The destination IP and port |
Definition at line 142 of file MpiProxy.cpp.
References sockaddr::addr, DEBUG, errno, ERROR, Application::IOError, m_sock, sendto(), strerror(), and Application::Success.
Referenced by processExec(), and processTerminate().
|
private |
Send multiple UDP packets.
vec | I/O vector with multiple packets |
count | Number of entries in the I/O vector |
addr | The destination IP and port |
Definition at line 160 of file MpiProxy.cpp.
References DEBUG, errno, ERROR, Application::IOError, m_sock, msghdr::msg_iov, msghdr::msg_iovlen, msghdr::msg_name, msghdr::msg_namelen, sendmsg(), strerror(), and Application::Success.
|
private |
Networking client object.
Definition at line 285 of file MpiProxy.h.
Referenced by initialize(), udpReceive(), and ~MpiProxy().
|
private |
Memory base address for local MPI communication.
Definition at line 288 of file MpiProxy.h.
Referenced by createChannels(), MpiProxy(), processTerminate(), startLocalProcess(), and startRemoteProcess().
|
private |
Records the PID of each process participating in the computation.
Definition at line 297 of file MpiProxy.h.
Referenced by MpiProxy(), processTerminate(), startLocalProcess(), and startRemoteProcess().
|
private |
Stores all channels for receiving data from processes.
Definition at line 291 of file MpiProxy.h.
Referenced by createChannels().
|
private |
IP/UDP socket for external communication.
Definition at line 282 of file MpiProxy.h.
Referenced by initialize(), udpReceive(), udpSend(), and udpSendMultiple().
|
private |
Stores all channels for sending data to processes.
Definition at line 294 of file MpiProxy.h.
Referenced by createChannels(), and processSend().
|
staticprivate |
Maximum number of supported MPI channels.
Definition at line 61 of file MpiProxy.h.
|
static |
Maximum size of packet payload.
Definition at line 66 of file MpiProxy.h.
Referenced by exec(), processExec(), processRecv(), processTerminate(), MpiHost::receive(), MpiHost::send(), MpiHost::startProcesses(), and MpiHost::terminate().
|
staticprivate |
Timeout in milliseconds to wait for packet receive.
Definition at line 58 of file MpiProxy.h.
Referenced by udpReceive().
|
staticprivate |
Port number for IP/UDP traffic.
Definition at line 55 of file MpiProxy.h.
Referenced by initialize().