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:
966 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * This program has an error because not all processes
|
|---|
| 3 | * execute MPI_Barrier and MPI_Scatter in the same order.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | #include<mpi.h>
|
|---|
| 7 | #include<stdio.h>
|
|---|
| 8 | #include<stdlib.h>
|
|---|
| 9 |
|
|---|
| 10 | int main(int argc, char* argv[]){
|
|---|
| 11 | int rank;
|
|---|
| 12 | int procs;
|
|---|
| 13 | int* sendbuf, *rcvbuf;
|
|---|
| 14 |
|
|---|
| 15 | MPI_Init(&argc,&argv);
|
|---|
| 16 | MPI_Comm_size(MPI_COMM_WORLD, &procs);
|
|---|
| 17 | MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|---|
| 18 |
|
|---|
| 19 | sendbuf = (int*)malloc(sizeof(int)*procs);
|
|---|
| 20 | rcvbuf = (int*)malloc(sizeof(int));
|
|---|
| 21 | if(rank == 0)
|
|---|
| 22 | {
|
|---|
| 23 | for(int i=0; i<procs; i++){
|
|---|
| 24 | sendbuf[i] = procs - i;
|
|---|
| 25 | }
|
|---|
| 26 | MPI_Scatter(sendbuf, 1, MPI_INT, rcvbuf, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|---|
| 27 | MPI_Barrier(MPI_COMM_WORLD);
|
|---|
| 28 | }else{
|
|---|
| 29 | MPI_Barrier(MPI_COMM_WORLD);
|
|---|
| 30 | MPI_Scatter(sendbuf, 1, MPI_INT, rcvbuf, 1, MPI_INT, 0, MPI_COMM_WORLD);
|
|---|
| 31 | printf("process %d receivs %d\n", rank, *rcvbuf);
|
|---|
| 32 | }
|
|---|
| 33 | free(sendbuf);
|
|---|
| 34 | free(rcvbuf);
|
|---|
| 35 | MPI_Finalize();
|
|---|
| 36 | return 0;
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.