Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

parallel / 7-2010

.pdf
Скачиваний:
39
Добавлен:
31.05.2015
Размер:
1.31 Mб
Скачать

if (myrank == root){ printf("Enter a, b, and n\n"); scanf("%f %f %i", &a, &b, &n); position = 0;

MPI_Pack(&a, 1, MPI_FLOAT, &buffer, 100, &position, MPI_COMM_WORLD);

MPI_Pack(&b, 1, MPI_FLOAT, &buffer, 100, &position, MPI_COMM_WORLD);

MPI_Pack(&n, 1, MPI_INT, &buffer, 100, &position, MPI_COMM_WORLD);

MPI_Bcast(&buffer, 100, MPI_PACKED, root, MPI_COMM_WORLD);

}

2008

else {

MPI_Bcast(&buffer, 100, MPI_PACKED, root, MPI_COMM_WORLD); position = 0;

MPI_Unpack(&buffer, 100, &position, &a, 1, MPI_FLOAT, MPI_COMM_WORLD);

MPI_Unpack(&buffer, 100, &position, &b, 1, MPI_FLOAT, MPI_COMM_WORLD);

MPI_Unpack(&buffer, 100, &position, &n, 1, MPI_INT, MPI_COMM_WORLD);

printf("Process %i received a=%f, b=%f, n=%i\n", myrank, a, b, n);

}

MPI_Finalize(); return 0;

}

2008

0 % a, b n.

* " ,

MPI_Unpack a, b, n %. ' ,

MPI_Bcast MPI_PACKED.

' MPI_BYTE C Fortran.

« » %, "

"

. ! *,

. ' MPI_BYTE ! ,

!

.

2008

2008

. #

!

%.

! * %

. MPI

, ! " ,

* .

' " MPI ,

%

. (

MPI *

".

2008

' -

. 4

, ",

, %, , "

.

0

. ' ,

, ,

* ( ). ) !

* %% , !

.

2 ! ,

%% !

.

2008

MPI " : —

*

( ! ,

" ).

2008

. ! . $ * ! " ,

. $ !

*. !

.

.

2008

$ , *

MPI_COMM_WORLD, " :

* ( 2, ,

*);

* ! ( {10, 5},

, *,

! x 10 - ,

y 5 );

! (* !

, , " !

, ! ).

MPI ! !

% "

.

2008

. MPI_Cart_create

comm_cart,

comm_old:

int MPI_Cart_create(MPI_Comm comm_old, int ndims, int *dims, int *periods, int reorder, MPI_Comm *comm_cart)

MPI_Cart_create(comm_old, ndims, dims, periods, reorder, comm_cart, ierr)

:

comm_old ;

ndims *;

dims , " ndims ,

" ! ;

2008

Соседние файлы в папке parallel