Search code examples
parallel-processingmpidistributed-computing

Return value of MPI_Dims_create()


Assuming I have 64 processes and I want to create an MPI Cartesian Topology in 3-D, the default topology returned by MPI_Dims_create() is 4x4x4. Why is it 4x4x4 and why not 8x4x2 or 4x8x2 or 16x2x2 or any other combination that is possible ?


Solution

  • MPI_Dims_create is specifically made as convenience function to create a balanced topology.

    A balanced topology, i.e. ideally cube has a certain optimal properties. Consider you are doing a simulation on a 160x160x160 grid with your processes.

    • With 4x4x4 each processor gets 40x40x40 to work on and in case of a simple border exchange has to send 40x40 to each of the 6 neighbors (9600 in total)

    • With 8x4x2 each processor gets 20x40x80, the border is 2x20x40 + 2x20x80 + 2x40x80 = 11200

    • With 16x2x2 each processor gets 10x80x80, the border is 4x10x80 + 2x80x80 = 16000

    As you can see, the border size that needs to be exchanged is the smallest for the cube. Generally, a balanced topology is a good default.

    You can also set constraints with MPI_Dims_create or use MPI_Cart_create to create flexible Cartesian topologies.