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:
591 bytes
|
| Rev | Line | |
|---|
| [804b9e0] | 1 | #include <stdio.h>
|
|---|
| 2 | #include <mpi.h>
|
|---|
| 3 |
|
|---|
| [db66e7f] | 4 | $input int _mpi_nprocs = 3;
|
|---|
| [804b9e0] | 5 |
|
|---|
| 6 | void main(int argc, char * argv[]){
|
|---|
| 7 | int nprocs, rank, msg;
|
|---|
| 8 | MPI_Status status;
|
|---|
| 9 |
|
|---|
| 10 | MPI_Init(&argc, &argv);
|
|---|
| 11 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 12 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 13 | if(rank != 0){
|
|---|
| 14 | msg = rank;
|
|---|
| 15 | MPI_Send(&msg, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
|
|---|
| 16 | }
|
|---|
| 17 | else{
|
|---|
| 18 | int source;
|
|---|
| 19 |
|
|---|
| 20 | msg = -1;
|
|---|
| 21 | printf("I'm process %d :\n", rank);
|
|---|
| 22 | MPI_Recv(&msg, 1, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, &status);
|
|---|
| 23 | MPI_Recv(&msg, 1, MPI_INT, 1, 1, MPI_COMM_WORLD, &status);
|
|---|
| 24 | }
|
|---|
| [598c052] | 25 | MPI_Finalize();
|
|---|
| [804b9e0] | 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.