main
test-branch
|
Last change
on this file since bb03188 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:
784 bytes
|
| Line | |
|---|
| 1 | #include <mpi.h>
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 | #include <civl-mpi.cvh>
|
|---|
| 4 |
|
|---|
| 5 | int size, rank;
|
|---|
| 6 | int root = 0;
|
|---|
| 7 |
|
|---|
| 8 | void recv() {
|
|---|
| 9 | int x;
|
|---|
| 10 |
|
|---|
| 11 | for(int i = 1; i < size; i++)
|
|---|
| 12 | MPI_Recv(&x, 1, MPI_INT, MPI_ANY_SOURCE, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
|
|---|
| 13 | MPI_Barrier(MPI_COMM_WORLD);
|
|---|
| 14 | CMPI_Coassert(MPI_COMM_WORLD, $true);
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | void send(int msg) {
|
|---|
| 18 | int x;
|
|---|
| 19 |
|
|---|
| 20 | MPI_Send(&msg, 1, MPI_INT, root, 0, MPI_COMM_WORLD);
|
|---|
| 21 | printf("Process %d sends %d to root.\n", rank, msg);
|
|---|
| 22 | MPI_Barrier(MPI_COMM_WORLD);
|
|---|
| 23 | CMPI_Coassert(MPI_COMM_WORLD, root@x == msg);
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | int main(int argc, char * argv[]) {
|
|---|
| 27 | MPI_Init(&argc, &argv);
|
|---|
| 28 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 29 | MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|---|
| 30 | for(int i = 0; i < 2; i++)
|
|---|
| 31 | if(!rank)
|
|---|
| 32 | recv();
|
|---|
| 33 | else
|
|---|
| 34 | send(i);
|
|---|
| 35 | MPI_Finalize();
|
|---|
| 36 | return 0;
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.