24 , m_mpiInitResult(
MPI_Init(&m_argc, &m_argv))
46 ERROR(
"failed to lookup MPI rank: result = " << result);
62 ERROR(
"failed to lookup MPI core count: result = " << result);
65 NOTICE(
"ping " << (cores - 1) <<
" cores");
68 for (
int i = 1; i < cores; i++)
73 ERROR(
"failed to send ping to core" << i <<
": result = " << (
int) pingResult);
80 ERROR(
"failed to receive pong from core" << i <<
": result = " << (
int) pongResult);
84 NOTICE(
"pong received from core" << i);
93 ERROR(
"failed to receive ping from core0: result = " << (
int) recvResult);
100 ERROR(
"failed to send message to core0: result = " << (
int) sendResult);
108 ERROR(
"failed to finalize MPI: result = " << result);
116 const int number)
const
125 ERROR(
"failed to send message to core" <<
coreId <<
": result = " << (
int) result);
133 const int expectedNumber)
const
143 ERROR(
"failed to receive message from core" <<
coreId <<
": result = " << (
int) result);
147 if (buf != expectedNumber)
150 " received from core" <<
coreId);
ArgumentParser & parser()
Get program arguments parser.
void setDescription(const String &desc)
Set program description.
int m_mpiInitResult
Result of MPI initialization.
virtual Result initialize()
Initialize the application.
virtual Result exec()
Execute the application.
static const int PingMagicNumber
Magic number to send as ping message.
Result receiveNumber(const Size coreId, const int expectedNumber) const
Receive a message containing a number.
Result sendNumber(const Size coreId, const int number) const
Send a message containing a number.
int m_id
MPI core identifier (rank) of the current process.
MpiPing(int argc, char **argv)
Constructor.
virtual ~MpiPing()
Destructor.
static const int PongMagicNumber
Magic number send for the pong message.
POSIX-compatible application.
C int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm)
C int MPI_Comm_rank(MPI_Comm comm, int *rank)
C int MPI_Comm_size(MPI_Comm comm, int *size)
C int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)
C int MPI_Init(int *argc, char ***argv)
uint MPI_Status
Status holder.
#define ERROR(msg)
Output an error message.
#define NOTICE(msg)
Output a notice message.
unsigned int Size
Any sane size indicator cannot go negative.
#define DEBUG(msg)
Output a debug message to standard output.