|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
*
|
|
Packit |
0848f5 |
* (C) 2006 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 |
#include "mpithreadtest.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
static char MTEST_Descrip[] = "Send to self in a threaded program";
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTEST_THREAD_RETURN_TYPE send_thread(void *p);
|
|
Packit |
0848f5 |
MTEST_THREAD_RETURN_TYPE send_thread(void *p)
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int rank;
|
|
Packit |
0848f5 |
char buffer[100];
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Send(buffer, sizeof(buffer), MPI_CHAR, rank, 0, MPI_COMM_WORLD);
|
|
Packit |
0848f5 |
return MTEST_THREAD_RETVAL_IGN;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int rank, size;
|
|
Packit |
0848f5 |
int provided;
|
|
Packit |
0848f5 |
char buffer[100];
|
|
Packit |
0848f5 |
MPI_Status status;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit |
0848f5 |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (provided != MPI_THREAD_MULTIPLE) {
|
|
Packit |
0848f5 |
if (rank == 0) {
|
|
Packit |
0848f5 |
printf
|
|
Packit |
0848f5 |
("MPI_Init_thread must return MPI_THREAD_MULTIPLE in order for this test to run.\n");
|
|
Packit |
0848f5 |
fflush(stdout);
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return -1;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Start_thread(send_thread, NULL);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_Recv(buffer, sizeof(buffer), MPI_CHAR, rank, 0, MPI_COMM_WORLD, &status);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Join_threads();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MTest_Finalize(0);
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|