#include <mpi.h>
#include <vector>
Go to the source code of this file.
static double do_work |
( |
double * |
work | ) |
|
|
static |
static double* get_next_work_item |
( |
| ) |
|
|
static |
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 80 of file proc1.cpp.
References master(), and slave().
86 MPI_Init(&argc, &argv);
90 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
static void master |
( |
void |
| ) |
|
|
static |
Definition at line 106 of file proc1.cpp.
References DIETAG, get_next_work_item(), numEntries, totCalls, and WORKTAG.
Referenced by main().
116 tc * ( ( ne * (ne - 1.0) )/2.0 ) +
117 ne * ( tc * (tc - 1.0) )/2.0;
122 MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
126 for (rank = 1; rank < ntasks; ++rank) {
146 while (work != NULL) {
176 for (rank = 1; rank < ntasks; ++rank) {
177 MPI_Recv(&result, 1, MPI_DOUBLE, MPI_ANY_SOURCE,
178 MPI_ANY_TAG, MPI_COMM_WORLD, &status);
185 for (rank = 1; rank < ntasks; ++rank) {
186 MPI_Send(0, 0, MPI_INT, rank,
DIETAG, MPI_COMM_WORLD);
188 cout <<
"Tot = " << tot <<
", expected = " << expectedTot << endl;
static double * get_next_work_item()
static void slave |
( |
void |
| ) |
|
|
static |
Definition at line 193 of file proc1.cpp.
References DIETAG, do_work(), and numEntries.
Referenced by main().
203 MPI_Recv( work,
numEntries, MPI_DOUBLE, 0, MPI_ANY_TAG,
204 MPI_COMM_WORLD, &status);
208 if (status.MPI_TAG ==
DIETAG) {
218 MPI_Send(&result, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
static double do_work(double *work)
const int numEntries = 10 |
const int totCalls = 1000 |