Hello everyone, I am trying to scatter 3d array in tetragonal prisma format. I hope this picture will clarify what I mean.
Think of the big cube is 3d array(lets say 4x4x4 dimensions) and P0..3 is processors. (P0 will take [0..1][0..1][0..3] part of big array). I am using datatypes in order to do this, I created 2 datatypes;
MPI_Datatype dtype1, surface,dtype2,tetragonal;
MPI_Type_vector((N)/sqrt(size),
(N),
(N),
MPI_FLOAT,
&dtype1);
MPI_Type_commit(&dtype1);
MPI_Type_create_resized(dtype1, 0, 1*sizeof(float), &surface);
MPI_Type_commit(&surface);
MPI_Type_vector(N/sqrt(size),
1,
sqrt(size),
surface,
&dtype2);
MPI_Type_commit(&dtype2);
MPI_Type_create_resized(dtype2, 0, 1*sizeof(float), &tetragonal);
MPI_Type_commit(&tetragonal);
However, I am getting very strange results, I am new on MPI environment so I need some help on this issue to understand how datatypes actually work. Thank you.
(Assume processor size is squared number and N is evenly divisible by sqrt(size) )
You cannot use MPI_Scatter()
with this derived datatype, but you can use MPI_Scatterv()
(all the counts are equal, but you need to manually calculate the displacements).