Pakman
pakman_mpi_worker.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <mpi.h>
Include dependency graph for pakman_mpi_worker.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PAKMAN_EXIT_SUCCESS   0
 
#define PAKMAN_EXIT_FAILURE   1
 

Functions

int pakman_run_mpi_worker (int argc, char *argv[], int(*simulator)(int argc, char *argv[], const char *input_string, char **p_output_string))
 

Detailed Description

Since MPI simulators cannot be forked directly when using MPIMaster, the MPI function MPI_Comm_spawn is used instead to spawn MPI Workers. As a consequence, the communication between Pakman and MPI Workers does not happen through system pipes, but through the MPI intercommunicator obtained with MPI_Comm_get_parent.

Most importantly, the MPI simulator can no longer be considered a black box at the systems-level. Instead, the simulator must be implemented as a function in C (see PakmanMPIWorker.hpp for C++). Its function pointer is then passed to the pakman_run_mpi_worker(), which will then communicate with Pakman and execute the given simulator function to perform the received simulation tasks.

Note that MPI_Init() should be called before calling pakman_run_mpi_worker(). Also, after pakman_run_mpi_worker() returns, MPI_Finalize() should be called.

For more information, see Implementing an MPI simulator.

Definition in file pakman_mpi_worker.h.

Macro Definition Documentation

◆ PAKMAN_EXIT_FAILURE

#define PAKMAN_EXIT_FAILURE   1

Exit code indicating Worker encountered an error.

Definition at line 37 of file pakman_mpi_worker.h.

◆ PAKMAN_EXIT_SUCCESS

#define PAKMAN_EXIT_SUCCESS   0

Exit code indicating Worker ran successfully.

Definition at line 34 of file pakman_mpi_worker.h.

Function Documentation

◆ pakman_run_mpi_worker()

int pakman_run_mpi_worker ( int  argc,
char *  argv[],
int(*)(int argc, char *argv[], const char *input_string, char **p_output_string)  simulator 
)

Run the Pakman MPI Worker with the given simulator function.

The simulator function must accept four arguments;

  • argc number of command-line arguments.
  • argv array of command-line arguments.
  • input_string input to simulator.
  • p_output_string pointer to output from simulator.

The returned *p_output_string must have been allocated using malloc(). After sending the contents of *p_output_string to Pakman, the MPI Worker will call free() on *p_output_string.

In addition, the simulator function must return an error code.

Parameters
argcnumber of command-line arguments.
argvarray of command-line arguments.
simulatorfunction pointer to simulator function.
Returns
exit code.

Definition at line 143 of file pakman_mpi_worker.h.