1.23
2.0
acw/focus-triggers
main
test-branch
|
Last change
on this file since 4de7516 was a96092d, checked in by Ziqing Luo <ziqing@…>, 12 years ago |
|
add new mpi example: mpi_pi and 2 test cases for MPI_Sys_status
some cvl programs have to be changed for new scheme of MPI_Sys_status
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1753 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | #include <stdio.h>
|
|---|
| 2 | #include <mpi.h>
|
|---|
| 3 | #include <civlmpi.cvh>
|
|---|
| 4 | #include <assert.h>
|
|---|
| 5 |
|
|---|
| 6 | $input int NPROCS;
|
|---|
| 7 | CMPI_Gcomm __MPI_COMM_WORLD;
|
|---|
| 8 | void MPI_Process(int place){
|
|---|
| 9 | MPI_Comm MPI_COMM_WORLD = CMPI_Comm_create($here, __MPI_COMM_WORLD, place);
|
|---|
| 10 | int nprocs, rank, msg;
|
|---|
| 11 | MPI_Status status;
|
|---|
| 12 | __MPI_Sys_status__ _my_status = __UNINIT;
|
|---|
| 13 |
|
|---|
| 14 | $assert _my_status == __UNINIT;
|
|---|
| 15 | __MPI_Init();
|
|---|
| 16 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 17 | MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
|
|---|
| 18 |
|
|---|
| 19 | if(rank != 0){
|
|---|
| 20 | msg = rank;
|
|---|
| 21 | MPI_Send(&msg, 1, MPI_INT, 0, 1, MPI_COMM_WORLD);
|
|---|
| 22 | }
|
|---|
| 23 | else{
|
|---|
| 24 | int source;
|
|---|
| 25 |
|
|---|
| 26 | msg = -1;
|
|---|
| 27 | for(int i=1; i<NPROCS; i++){
|
|---|
| 28 | MPI_Recv(&msg, 1, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, &status);
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | CMPI_Comm_destroy(MPI_COMM_WORLD);
|
|---|
| 33 | printf("process %d terminates\n", rank);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void main(){
|
|---|
| 37 |
|
|---|
| 38 | $proc procs[NPROCS];
|
|---|
| 39 |
|
|---|
| 40 | __MPI_COMM_WORLD = CMPI_Gcomm_create($root, NPROCS);
|
|---|
| 41 | for(int i=0; i<NPROCS; i++)
|
|---|
| 42 | procs[i] = $spawn MPI_Process(i);
|
|---|
| 43 | for(int i=0; i<NPROCS; i++)
|
|---|
| 44 | $wait(procs[i]);
|
|---|
| 45 |
|
|---|
| 46 | CMPI_Gcomm_destroy(__MPI_COMM_WORLD);
|
|---|
| 47 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.