pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
NAME
setLoad, getLoad, balance, getWork, setVal, getVal, setNumActive, return
- Set and get pfLoadBalance definition parameters.
FUNCTION SPECIFICATION
void setLoad(int index,
float load) {newLoad[index] = load; };
float getLoad(int index) {return newLoad[index]; };
void balance(void);
float getWork(int index)
void setVal(int what, float val);
float getVal(int what);
void setNumActive(int num) { numActive = num; }
int getNumActive(void) {
return(numActive); }
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. This is also true
for ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
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.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
Page 1
pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
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:
setNumActive() /* set the number of servants to balance this frame */
foreach child
setLoad() /* tell the load balancer what the
* current load is on the child */
end
balance()
foreach child
getWork() /* get the percentage of the work
* this child should perform */
end
Page 2
pfLoadBalance(3pf) OpenGL Performer 3.2.2 libpf C++ Reference Pages
pfLoadBalance::setLoad() sets what the load is on a specified servant.
This is the load that'll be used during the load balancing calculations
in balance().
pfLoadBalance::getLoad() returns the load that was set by
pfLoadBalance::setLoad() for a specified servant.
pfLoadBalance::balance() takes the new load values specified by
pfLoadBalance::setLoad() and figures out the desired work load for each
servant. Then pfLoadBalance::balance() takes the the load coefficient
(PFLOAD_COEFF) into account while calculating what the percentage of the
work load this servant should perform.
pfLoadBalance::getWork() returns the percentage of work (a value from 0
to 1) to be done by the specified servant.
pfLoadBalance::setVal() and pfLoadBalance::getVal() 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.
pfLoadBalance::setNumActive() and pfLoadBalance::getNumActive() set and
get the number of servants to balance.
SEE ALSO
pfCompositor
Page 3