1.23
2.0
acw/focus-triggers
main
test-branch
| Line | |
|---|
| 1 | #include <stdio.h>
|
|---|
| 2 | #include <stdlib.h>
|
|---|
| 3 | #include <mpi.h>
|
|---|
| 4 | #include <math.h>
|
|---|
| 5 |
|
|---|
| 6 | /************************************************************
|
|---|
| 7 | This is a simple broadcast program in MPI
|
|---|
| 8 | ************************************************************/
|
|---|
| 9 |
|
|---|
| 10 | int main(argc,argv)
|
|---|
| 11 | int argc;
|
|---|
| 12 | char *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.