|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2009 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include <stdlib.h>
|
|
Packit |
0848f5 |
#include "mpitest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
#define MAX_MSGS 30
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
static char MTEST_Descrip[] = "One implementation delivered incorrect data when an MPI recieve uses both ANY_SOURCE and ANY_TAG";
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int wrank, wsize, master, worker, i, j, idx, count;
|
|
Packit |
0848f5 |
int errs = 0;
|
|
Packit |
0848f5 |
MPI_Request r[MAX_MSGS];
|
|
Packit |
0848f5 |
int buf[MAX_MSGS][MAX_MSGS];
|
|
Packit |
0848f5 |
MPI_Comm comm;
|
|
Packit |
0848f5 |
MPI_Status status;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &wrank);
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &wsize);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
comm = MPI_COMM_WORLD;
|
|
Packit |
0848f5 |
master = 0;
|
|
Packit |
0848f5 |
worker = 1;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* The test takes advantage of the ordering rules for messages */
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (wrank == master) {
|
|
Packit |
0848f5 |
/* Initialize the send buffer */
|
|
Packit |
0848f5 |
for (i = 0; i < MAX_MSGS; i++) {
|
|
Packit |
0848f5 |
for (j = 0; j < MAX_MSGS; j++) {
|
|
Packit |
0848f5 |
buf[i][j] = i * MAX_MSGS + j;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
for (i = 0; i < MAX_MSGS; i++) {
|
|
Packit |
0848f5 |
MPI_Send(buf[i], MAX_MSGS - i, MPI_INT, worker, 3, comm);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else if (wrank == worker) {
|
|
Packit |
0848f5 |
/* Initialize the recv buffer */
|
|
Packit |
0848f5 |
for (i = 0; i < MAX_MSGS; i++) {
|
|
Packit |
0848f5 |
for (j = 0; j < MAX_MSGS; j++) {
|
|
Packit |
0848f5 |
buf[i][j] = -1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
for (i = 0; i < MAX_MSGS; i++) {
|
|
Packit |
0848f5 |
MPI_Irecv(buf[i], MAX_MSGS - i, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, comm, &r[i]);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
for (i = 0; i < MAX_MSGS; i++) {
|
|
Packit |
0848f5 |
MPI_Waitany(MAX_MSGS, r, &idx, &status);
|
|
Packit |
0848f5 |
/* Message idx should have length MAX_MSGS-idx */
|
|
Packit |
0848f5 |
MPI_Get_count(&status, MPI_INT, &count);
|
|
Packit |
0848f5 |
if (count != MAX_MSGS - idx) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
/* Check for the correct answers */
|
|
Packit |
0848f5 |
for (j = 0; j < MAX_MSGS - idx; j++) {
|
|
Packit |
0848f5 |
if (buf[idx][j] != idx * MAX_MSGS + j) {
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
printf("Message %d [%d] is %d, should be %d\n",
|
|
Packit |
0848f5 |
idx, j, buf[idx][j], idx * MAX_MSGS + j);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
else {
|
|
Packit |
0848f5 |
MPI_Barrier(MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize(errs);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|