source: CIVL/examples/mpi/collective/c_ex04.c@ e34d3e8

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since e34d3e8 was b28f397, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

added more mpi examples

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

  • Property mode set to 100644
File size: 780 bytes
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <mpi.h>
4#include <math.h>
5
6/************************************************************
7This is a simple broadcast program in MPI
8************************************************************/
9
10int main(argc,argv)
11int argc;
12char *argv[];
13{
14 int i,myid, numprocs;
15 int source,count;
16 int buffer[4];
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 source=0;
24 count=4;
25 if(myid == source){
26 for(i=0;i<count;i++)
27 buffer[i]=i;
28 }
29 MPI_Bcast(buffer,count,MPI_INT,source,MPI_COMM_WORLD);
30 for(i=0;i<count;i++)
31 printf("%d ",buffer[i]);
32 printf("\n");
33 MPI_Finalize();
34}
35
Note: See TracBrowser for help on using the repository browser.