0
votes

I am quite new in using MPI parallel process.

I am dealing with the following problem related to the MASTER/SLAVE approach.

I have a 2D-squared array of SIZE=500, and I need to break it into several blocks of dimension:

D < SIZE.

I should implement a Master/Slave MPI where each processor receives, and sends back to the master N blocks, where N depends on the number of processors involved and the dimension D of the subblocks.

I managed to solve the problem by dividing the original array in stripes, but I don't know how to deal with squares!

2

2 Answers

0
votes

In order to simplify your problem, D must be a divider of 500. Now, the total number of blocks should be blocks = sqr(500/D). and N should be something along the lines n = blocks/cpus.

IMHO simplest way would be to create a square of DxD elements from the array and send that chunk of data to the client. Depending on the language and method, you can build small objects and send them to the client or just replicate the full matrix and send the coordinates for the chunk.

0
votes

An other option is to use MPI_Type_create_subarray() in order to create a derived datatype for a given (sub) square/rectangle of your array.

On the down side, this derived datatype cannot be used with collective operations such as MPI_Scatter[v]() and MPI_Gather[v](), which is usually the "natural" MPI way of distributing / re-assembling data.