Distribute blocks amongst computing nodes

Version: 2.5 (20/09/2017)

Author: Onera

Download pdf version.


This module provides functions to distribute blocks on a given number of processors. At the end of the process, each block will have a number corresponding to the processor it must be affected to for a balanced computation, depending on given criterias. This module doesn't perform splitting (see the Transform module for that).

This module is part of Cassiopee, a free open-source pre- and post-processor for CFD simulations.

To use the module with the Converter array interface, you must import it as:
import Distributor2 as D2
To use the module with the pyTree interface, you must import it as:
import Distributor2.PyTree as D2

Automatic load balance

D2.distribute: distribute automatically the blocks amongst N processors.
With the array interface, where A is a list of blocks:
- prescribed is a list of blocks that are forced to be on a given processor. prescribed[2] = 0 means that block 2 MUST be affected to processor 0.
- perfo is a tuple or a tuple list for each processor. Each tuple describes the relative weight of solver CPU time regarding the communication speed and latence (solverWeight, latenceWeight, comSpeedWeight).
- weight is a list of weight for each block indicating the relative cost for solving each block.
- com is a ixj matrix describing the volume of points exchanged between bloc i and bloc j.
Algorithm can be chosen in: 'gradient', 'genetic', 'fast'.

The function output is a stats dictionary. stat['distrib'] is a vector describing the attributed processor for each block, stats['meanPtsPerProc'] is the mean number of points per proc, stats['varMin'] is the minimum variation of number of points, stats['varMax'] is the maximum variation of number of points, stats['varRMS'] is the mean variation of number of points, stats['nptsCom'] is the number of points exchanged between processors for communication, stats['comRatio'] is the ratio of points exchanged between processors in this configuration divided by the total number of points needed in communications, stats['adaptation'] is the value of the optimized function:
stats = D2.distribute(A, NProc, prescribed=[], perfo=[], weight=[], com=[], algorithm='gradient', nghost=0)
With the pyTree interface, the user-defined node .Solver#Param/proc is updated with the attributed processor number.
If useCom=0, only the grid number of points is taken into account.
If useCom='all', matching and overlap communications are taken into account.
If useCom='match', only match connectivity are taken into account.
if useCom='overlap', only overlap connectivity are taken into account.
if useCom='bbox', overlap between zone bbox is taken into account.
When using distributed trees, prescribed must be a dictionary containing the zones names as key, and the prescribed proc as value. weight is also a dictionary where the keys are the zone names and the weight as the value. It is not mandatory to assign a weight to all the zones of the pyTree. Default value is assumed 1, only different weight values can be assigned to zones. t can be either a skeleton or a loaded skeleton pyTree for useCom=0 or useCom='match', but must be a loaded skeleton tree only for the other settings:
t, stats = D2.distribute(t, NProc, prescribed={}, perfo=[], weight={}, useCom='all', algorithm='gradient')
Example of use: block distribution (array), block distribution (pyTree).

Various operations

D2.addProcNode: add a "proc" node to all zones of A with given value:
B = D2.addProcNode(A, 12)
Example of use: add a proc node (pyTree).

D2.getProc: get the proc node of a zone or a list of zones:
proc = D2.getProc(a) .or. [proc1,proc2,...] = D2.getProc(A)
Example of use: get proc of a zone (pyTree).

D2.getProcList: return procList where procList[proc] is a list of zone names attributed to the proc processor:
procList = D2.getProcList(A, NProc=None)
Example of use: return the list of zones attributed to a proc (pyTree).

D2.copyDistribution: copy the distribution of B to A matching zones by their name:
A = D2.copyDistribution(A, B)
Example of use: copy distribution from one tree to another (pyTree).

D2.redispatch: redispatch a tree where a new distribution is defined in the node 'proc':
B = D2.redispatch(A)
Example of use: redispatch a tree (pyTree).

Return to main userguide