main
test-branch
| 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 | /************************************************************
|
|---|
| 10 | This is a simple broadcast program in MPI
|
|---|
| 11 | ************************************************************/
|
|---|
| 12 |
|
|---|
| 13 | int main(argc,argv)
|
|---|
| 14 | int argc;
|
|---|
| 15 | char *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.