source: CIVL/examples/mpi/c_ex03.c

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <mpi.h>
4#include <math.h>
5
6/************************************************************
7This is a simple isend/ireceive program in MPI
8************************************************************/
9
10int main(argc,argv)
11int argc;
12char *argv[];
13{
14 int myid, numprocs;
15 int tag,source,destination,count;
16 int buffer;
17 MPI_Status status;
18 MPI_Request request;
19
20 MPI_Init(&argc,&argv);
21 MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
22 MPI_Comm_rank(MPI_COMM_WORLD,&myid);
23 tag=1234;
24 source=0;
25 destination=1;
26 count=1;
27 request=MPI_REQUEST_NULL;
28 if(myid == source){
29 buffer=5678;
30 MPI_Isend(&buffer,count,MPI_INT,destination,tag,MPI_COMM_WORLD,&request);
31 }
32 if(myid == destination){
33 MPI_Irecv(&buffer,count,MPI_INT,source,tag,MPI_COMM_WORLD,&request);
34 }
35 MPI_Wait(&request,&status);
36 if(myid == source){
37 printf("processor %d sent %d\n",myid,buffer);
38 }
39 if(myid == destination){
40 printf("processor %d got %d\n",myid,buffer);
41 }
42 MPI_Finalize();
43}
44
Note: See TracBrowser for help on using the repository browser.