ptypy.utils.parallel.LoadManager#

class ptypy.utils.parallel.LoadManager#

Bases: object

__init__()#

Keeps track of the amount of data managed by each process and helps keeping it balanced.

Note

A LoadManager should always be given the full range of ids, as the all-knowing power stems from the fact that it always knows how many processes there are, what rank it has and the full range of ids to distribute. Hence, please “assign” always the same list across all nodes.

Methods

__init__()

Keeps track of the amount of data managed by each process and helps keeping it balanced.

assign([idlist])

Subdivide the provided list of ids into contiguous blocks to balance the load among the processes.

reset()

Resets LoadManager to initial state.

Attributes

load

Represents the number of elements assigned to this process.

rank_of

Rank of specific id, i.e. element of idlist.

assign(idlist=None)#

Subdivide the provided list of ids into contiguous blocks to balance the load among the processes.

The elements of idlist are used as keys to subsequently identify the rank of a given id, through the dict self.rank_of. No check is done whether ids passed are unique or even hashable (they better are)

If idlist is None, increase by one the load of the least busy process. rank_of is not updated in this case.

Parameters:

idlist (list) – List of objects that can also be keys in a dict, i.e. hashable objects.

Returns:

R – A nested list, (a list of lists) such that R[rank]=list of elements of idlist managed by process of given rank.

Return type:

list

load#

Represents the number of elements assigned to this process.

rank_of#

Rank of specific id, i.e. element of idlist.

reset()#

Resets LoadManager to initial state.