Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ИНСАЙД ИНФА MPI.pdf
Скачиваний:
15
Добавлен:
15.04.2015
Размер:
3.3 Mб
Скачать

1

2

3

4

138

CHAPTER 5. COLLECTIVE COMMUNICATION

5.4 Broadcast

5

6

7

8

9

10

11

12

13

MPI_BCAST( bu er, count, datatype, root, comm )

INOUT

bu er

starting address of bu er (choice)

IN

count

number of entries in bu er (non-negative integer)

IN

datatype

data type of bu er (handle)

IN

root

rank of broadcast root (integer)

IN

comm

communicator (handle)

int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root,

14

MPI_Comm comm )

15

16MPI_BCAST(BUFFER, COUNT, DATATYPE, ROOT, COMM, IERROR)

17<type> BUFFER(*)

18INTEGER COUNT, DATATYPE, ROOT, COMM, IERROR

19

fvoid MPI::Comm::Bcast(void* buffer, int count,

20

const MPI::Datatype& datatype, int root) const = 0 (binding

21

deprecated, see Section 15.2) g

22

23If comm is an intracommunicator, MPI_BCAST broadcasts a message from the process

24with rank root to all processes of the group, itself included. It is called by all members of

25the group using the same arguments for comm and root. On return, the content of root's

26bu er is copied to all other processes.

27General, derived datatypes are allowed for datatype. The type signature of count,

28datatype on any process must be equal to the type signature of count, datatype at the root.

29This implies that the amount of data sent must be equal to the amount received, pairwise

30between each process and the root. MPI_BCAST and all other data-movement collective

31routines make this restriction. Distinct type maps between sender and receiver are still

32allowed.

33The \in place" option is not meaningful here.

34If comm is an intercommunicator, then the call involves all processes in the intercom-

35municator, but with one group (group A) de ning the root process. All processes in the

36other group (group B) pass the same value in argument root, which is the rank of the root

37in group A. The root passes the value MPI_ROOT in root. All other processes in group A

38pass the value MPI_PROC_NULL in root. Data is broadcast from the root to all processes

39in group B. The bu er arguments of the processes in group B must be consistent with the

40bu er argument of the root.

41

42

5.4.1 Example using MPI_BCAST

 

43

The examples in this section use intracommunicators.

44

45

46

47

Example 5.1 Broadcast 100 ints from process 0 to every process in the group.

MPI_Comm comm;

48