Loadbalancer

class quicklb.Loadbalancer(objects, algorithm, max_abs_li, max_rel_li, max_it)
__init__(objects, algorithm, max_abs_li, max_rel_li, max_it)

Create a Loadbalancer object

Parameters
  • objects (list<Cell>) – A list of objects which implement all functions specified in the mock Cell object.

  • algorithm (string) – Specifies the loadbalancing algorithm, valid values are: - “GREEDY” - “SORT” - “SORT2”

  • max_abs_li (float) – specify the maximum absolute load-imbalance for the partitioning algorithm. When this threshold is reached the partitioning concludes 0.0 would be no load imbalance, 1. would be a load imbalance of 100%

  • max_rel_li (float) – specify the maximum relative load-imbalance for the partitioning algorithm. Is not used in the GREEDY partitioning scheme. When this threshold is reached the partitioning concludes.

  • max_it (int) – Maximum number of iterations for the loadbalancing algorithm. Set this somewhere between 1 and the number of processors used (or larger, it is limited to the maximum number of processors anyway)

Returns

A very fresh loadbalancing object !

Return type

Loadbalancer

iterate()

Perform a single iteration, with computation offloading. this eventually calls compute on every single cell

Return type

None

partition()

Call this function to (re)-partition the cells over the processors, it is recommended to call this once before iterate()

Return type

None

partitioning_info(detailed=False)

Writes out partitioning info to the loadbalance.info file

Parameters

detailed (bool) – When set to True write detailed information about every cell to loadbalance.info

Return type

None

Abstract Cell Class

this is a possible implementation of a cell class that needs to be fed to the loadbalancer

import struct

class Cell():
  data: float = 42.

  def compute(self):
    self.data = 1./data

  def serialize(self):
    return struct.pack('d',self.data)

  def deserialize(self, buffer):
    self.data = struct.unpack('d',buffer.tobytes())
class quicklb.Cell

Example Cell for the Loadbalancer class that needs some work to be done

compute()

Function which is called whenever work needs to be done, as this cell can be offloaded at the time of computation, it is recommended to only use (de)serialized data for the computation, otherwise results will be undefined

deserialize(buffer)

Function which deserializes the object.

Parameters

buffer (1D numpy bytes array) –

Return type

None

serialize()

Function which serializes the object.

Return type

Bytes-like object