source: CIVL/examples/mpi/collective/c_ex04.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: 896 bytes
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <mpi.h>
4#include <math.h>
5#ifdef _CIVL
6#include <civlc.cvh>
7#endif
8
9/************************************************************
10This is a simple broadcast program in MPI
11************************************************************/
12
13int main(argc,argv)
14int argc;
15char *argv[];
16{
17 int i,myid, numprocs;
18 int source,count;
19 int buffer[4];
20 MPI_Status status;
21 MPI_Request request;
22
23 MPI_Init(&argc,&argv);
24 MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
25 MPI_Comm_rank(MPI_COMM_WORLD,&myid);
26 source=0;
27 count=4;
28 if(myid == source){
29 for(i=0;i<count;i++)
30 buffer[i]=i;
31 }
32 MPI_Bcast(buffer,count,MPI_INT,source,MPI_COMM_WORLD);
33 for(i=0;i<count;i++)
34 printf("%d ",buffer[i]);
35 printf("\n");
36#ifdef _CIVL
37 $assert($forall(int k: 0 .. count-1) buffer[k]==k);
38#endif
39 MPI_Finalize();
40}
Note: See TracBrowser for help on using the repository browser.