You will need to use Broadcast because you want to send a copy of the same message to each process. Scatter breaks the message and distributes the pieces between the processes.
How to send data: HIndexed for you.
Suppose your 2d array is defined as follows:
int N;
int sizes[N];
int* arrays[N];
, , :
MPI_Aint base;
MPI_Address(arrays[0], &base);
MPI_Aint* displacements = new int[N];
for (int i=0; i<N; ++i)
{
MPI_Address(arrays[i], &displacements[i]);
displacements[i] -= base;
}
:
MPI_Datatype newType;
MPI_Type_hindexed(N, sizes, displacements, MPI_INTEGER, &newType);
MPI_Type_commit(&newType);
, , . , :
MPI_Bcast(arrays, 1, newType, root, comm); // 'root' and 'comm' is whatever you need
. : , ( int). N, sizes arrays , , , , - , ( , ), :
MPI_Bcast(arrays, 1, newType, root, comm); // 'root' and 'comm' must have the same value as in the sender code
! .
, , 2- 2d- M. int[N*M]: ++ , , , :
MPI_Bcast(arrays, N*M, MPI_INTEGER, root, comm);
: Indexed HIndexed. , Indexed displacements , HIndexed - (H ). Indexed, , displacements, sizeof(int). , , , , "" ++, HIndexed () .