FreeNOS
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
MpiPing Class Reference

Send a ping message via MPI to all available nodes. More...

#include <MpiPing.h>

Inheritance diagram for MpiPing:
POSIXApplication Application

Public Member Functions

 MpiPing (int argc, char **argv)
 Constructor. More...
 
virtual ~MpiPing ()
 Destructor. More...
 
virtual Result initialize ()
 Initialize the application. More...
 
virtual Result exec ()
 Execute the application. 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...
 

Private Member Functions

Result sendNumber (const Size coreId, const int number) const
 Send a message containing a number. More...
 
Result receiveNumber (const Size coreId, const int expectedNumber) const
 Receive a message containing a number. More...
 

Private Attributes

int m_mpiInitResult
 Result of MPI initialization. More...
 
int m_id
 MPI core identifier (rank) of the current process. More...
 

Static Private Attributes

static const int PingMagicNumber = 0xaabbccdd
 Magic number to send as ping message. More...
 
static const int PongMagicNumber = 0x12345678
 Magic number send for the pong message. More...
 

Additional Inherited Members

- Public Types inherited from Application
enum  Result {
  Success, NotFound, IOError, InvalidArgument,
  ShowUsage, TimedOut, OutOfMemory
}
 Result codes. More...
 
- 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...
 
ArgumentParserparser ()
 Get program arguments parser. More...
 
const ArgumentParserparser () const
 Get constant program arguments parser. More...
 
const ArgumentContainerarguments () 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...
 

Detailed Description

Send a ping message via MPI to all available nodes.

Definition at line 31 of file MpiPing.h.

Constructor & Destructor Documentation

◆ MpiPing()

MpiPing::MpiPing ( int  argc,
char **  argv 
)

Constructor.

Parameters
argcArgument count
argvArgument values

Definition at line 22 of file MpiPing.cpp.

References Application::parser(), and ArgumentParser::setDescription().

◆ ~MpiPing()

MpiPing::~MpiPing ( )
virtual

Destructor.

Definition at line 30 of file MpiPing.cpp.

References DEBUG.

Member Function Documentation

◆ exec()

MpiPing::Result MpiPing::exec ( )
virtual

Execute the application.

Returns
Result code

Implements Application.

Definition at line 53 of file MpiPing.cpp.

References ERROR, Application::IOError, m_id, MPI_Comm_size(), MPI_COMM_WORLD, MPI_Finalize(), MPI_SUCCESS, NOTICE, PingMagicNumber, PongMagicNumber, receiveNumber(), sendNumber(), and Application::Success.

◆ initialize()

MpiPing::Result MpiPing::initialize ( )
virtual

Initialize the application.

Returns
Result code

Reimplemented from Application.

Definition at line 35 of file MpiPing.cpp.

References ERROR, Application::IOError, m_id, m_mpiInitResult, MPI_Comm_rank(), MPI_COMM_WORLD, MPI_SUCCESS, and Application::Success.

◆ receiveNumber()

MpiPing::Result MpiPing::receiveNumber ( const Size  coreId,
const int  expectedNumber 
) const
private

Receive a message containing a number.

Parameters
coreIdCore identifier to receive the message from
expectedNumberThe expected number value to receive
Returns
Result code

Definition at line 132 of file MpiPing.cpp.

References coreId, DEBUG, ERROR, Number::Hex, Application::IOError, MPI_COMM_WORLD, MPI_INT, MPI_Recv(), MPI_SUCCESS, and Application::Success.

Referenced by exec().

◆ sendNumber()

MpiPing::Result MpiPing::sendNumber ( const Size  coreId,
const int  number 
) const
private

Send a message containing a number.

Parameters
coreIdCore identifier to send the message to
numberNumber value to send
Returns
Result code

Definition at line 115 of file MpiPing.cpp.

References coreId, DEBUG, ERROR, Number::Hex, Application::IOError, MPI_COMM_WORLD, MPI_INT, MPI_Send(), MPI_SUCCESS, and Application::Success.

Referenced by exec().

Field Documentation

◆ m_id

int MpiPing::m_id
private

MPI core identifier (rank) of the current process.

Definition at line 100 of file MpiPing.h.

Referenced by exec(), and initialize().

◆ m_mpiInitResult

int MpiPing::m_mpiInitResult
private

Result of MPI initialization.

Definition at line 97 of file MpiPing.h.

Referenced by initialize().

◆ PingMagicNumber

const int MpiPing::PingMagicNumber = 0xaabbccdd
staticprivate

Magic number to send as ping message.

Definition at line 36 of file MpiPing.h.

Referenced by exec().

◆ PongMagicNumber

const int MpiPing::PongMagicNumber = 0x12345678
staticprivate

Magic number send for the pong message.

Definition at line 39 of file MpiPing.h.

Referenced by exec().


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