62 static void slave(
void);
67 static unsigned int numCalls = 0;
68 for (
unsigned int i = 0; i <
numEntries; ++i )
69 ret[i] = i + numCalls;
72 if ( numCalls > 1000 )
77 static double do_work(
double* work);
79 int main(
int argc,
char **argv)
85 MPI_Init(&argc, &argv);
89 MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
116 MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
120 for (rank = 1; rank < ntasks; ++rank) {
140 while (work != NULL) {
170 for (rank = 1; rank < ntasks; ++rank) {
171 MPI_Recv(&result, 1, MPI_DOUBLE, MPI_ANY_SOURCE,
172 MPI_ANY_TAG, MPI_COMM_WORLD, &status);
179 for (rank = 1; rank < ntasks; ++rank) {
180 MPI_Send(0, 0, MPI_INT, rank,
DIETAG, MPI_COMM_WORLD);
182 cout <<
"Tot = " << tot << endl;
197 MPI_Recv( work,
numEntries, MPI_DOUBLE, 0, MPI_ANY_TAG,
198 MPI_COMM_WORLD, &status);
202 if (status.MPI_TAG ==
DIETAG) {
212 MPI_Send(&result, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD);
static double * get_next_work_item()
int main(int argc, char **argv)
static double do_work(double *work)