pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
NAME
pfNewLoadBalance, pfGetLoadBalanceClassType, pfLoadBalanceLoad,
pfGetLoadBalanceLoad, pfLoadBalanceBalance, pfGetLoadBalanceWork,
pfLoadBalanceVal, pfGetLoadBalanceVal, pfLoadBalanceNumActive,
pfGetLoadBalanceNumActive - Set and get pfLoadBalance definition
parameters.
FUNCTION SPECIFICATION
pfLoadBalance* pfNewLoadBalance(int size);
pfType* pfGetLoadBalanceClassType(void);
void pfLoadBalanceLoad(pfLoadBalance* _loadbalance,
int index, float load);
float pfGetLoadBalanceLoad(pfLoadBalance* _loadbalance,
int index);
void pfLoadBalanceBalance(pfLoadBalance* _loadbalance);
float pfGetLoadBalanceWork(pfLoadBalance* _loadbalance,
int index);
void pfLoadBalanceVal(pfLoadBalance* _loadbalance, int what,
float val);
float pfGetLoadBalanceVal(pfLoadBalance* _loadbalance,
int what);
void pfLoadBalanceNumActive(pfLoadBalance* _loadbalance,
int num);
int pfGetLoadBalanceNumActive(pfLoadBalance* _loadbalance);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfLoadBalance is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfLoadBalance. Casting an object
of class pfLoadBalance to an object of class pfObject is taken care of
automatically. This is also true for casts to objects of ancestor
classes of class pfObject.
void pfUserDataSlot(pfObject *obj, int slot, void *data);
void pfUserData(pfObject *obj, void *data);
void* pfGetUserDataSlot(pfObject *obj, int slot);
void* pfGetUserData(pfObject *obj);
int pfGetNumUserData(pfObject *obj);
int pfGetNamedUserDataSlot(const char *name);
const char* pfGetUserDataSlotName(int slot);
int pfGetNumNamedUserDataSlots(void);
Page 1
pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
int pfDeleteGLHandle(pfObject *obj);
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfLoadBalance can also be used with these
functions designed for objects of class pfMemory.
pfType * pfGetType(const void *ptr);
int pfIsOfType(const void *ptr, pfType *type);
int pfIsExactType(const void *ptr, pfType *type);
const char * pfGetTypeName(const void *ptr);
int pfRef(void *ptr);
int pfUnref(void *ptr);
int pfUnrefDelete(void *ptr);
int pfUnrefGetRef(void *ptr);
int pfGetRef(const void *ptr);
int pfCopy(void *dst, void *src);
int pfDelete(void *ptr);
int pfIsFluxed(void *ptr);
int pfCompare(const void *ptr1, const void *ptr2);
void pfPrint(const void *ptr, uint which, uint verbose,
FILE *file);
void * pfGetArena(void *ptr);
DESCRIPTION
pfLoadBalance encapsulates an algorithm for distributing any incoming
workload among multiple servants. pfLoadBalance maintains history
information about:
Workload distribution among servants. The time it took each servant to
complete its workload allocation.
Based on this information, pfLoadBalance computes a new workload
distribution to minimize the time needed for completing the input
workload.
The provided implementation keeps track of a single frame of history.
Subclasses of pfLoadBalance could track history information through
multiple frames. Using multiple frames they can compute the rate of
change in work-allocation : work-load ratio.
The provided implementation tries to smoothen the transition as workload
allocation changes for each servant. Subclasses of pfLoadBalance could
also change the smoothening factors to match the rate of change in
workload between consecutive frames.
Typical use from pfCompositor would be something along the lines of the
following:
pfLoadBalanceNumActive() /* set the number of servants to balance this
frame */
Page 2
pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C Reference Pages
foreach child
pfLoadBalanceLoad() /* tell the load balancer what the
* current load is on the child */
end
balance()
foreach child
pfGetLoadBalanceWork() /* get the percentage of the work
* this child should perform */
end
pfLoadBalanceLoad() sets what the load is on a specified servant. This
is the load that'll be used during the load balancing calculations in
pfLoadBalanceBalance().
pfGetLoadBalanceLoad() returns the load that was set by
pfLoadBalanceLoad() for a specified servant.
pfLoadBalanceBalance() takes the new load values specified by
pfLoadBalanceLoad() and figures out the desired work load for each
servant. Then pfLoadBalanceBalance() takes the the load coefficient
(PFLOAD_COEFF) into account while calculating what the percentage of the
work load this servant should perform.
pfGetLoadBalanceWork() returns the percentage of work (a value from 0 to
1) to be done by the specified servant.
pfLoadBalanceVal() and pfGetLoadBalanceVal() currently accept
PFLOAD_COEFF as an argument. The value of PFLOAD_COEFF determines how
fast or how slow the balancer transitions from the current work load to
the desired work load.
pfLoadBalanceNumActive() and pfGetLoadBalanceNumActive() set and get the
number of servants to balance.
SEE ALSO
pfCompositor
Page 3