HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_JobInfo Class Reference

#include <UT_ThreadedAlgorithm.h>

Public Member Functions

 UT_JobInfo (int jobidx, int numjobs, UT_Lock *lock, SYS_AtomicInt32 *aint=0)
 
int job () const
 
int numJobs () const
 
int32 nextTask () const
 
void resetTasks () const
 
void divideWork (int units, int &start, int &end) const
 
void divideWork (exint units, exint &start, exint &end) const
 
void lock () const
 
void unlock () const
 

Protected Attributes

int myJob
 
int myNumJobs
 
UT_LockmyLock
 
SYS_AtomicInt32myTask
 
int myLocalTask
 

Detailed Description

Defines the work required for each invocation of *Partial to complete.

Examples:
SIM/SIM_GasAdd.C, and SIM/SIM_GasAdd.h.

Definition at line 92 of file UT_ThreadedAlgorithm.h.

Constructor & Destructor Documentation

UT_JobInfo::UT_JobInfo ( int  jobidx,
int  numjobs,
UT_Lock lock,
SYS_AtomicInt32 aint = 0 
)
inline

Definition at line 95 of file UT_ThreadedAlgorithm.h.

Member Function Documentation

void UT_JobInfo::divideWork ( int  units,
int start,
int end 
) const

Given "units" work, report which units you are responsible for with this JobInfo. The resulting interval is [start, end), Appropriate for loop: for (info.divideWork(total, i, end); i < end; i++)

void UT_JobInfo::divideWork ( exint  units,
exint start,
exint end 
) const
int UT_JobInfo::job ( ) const
inline

The number of jobs is the total number of threads that is running and job() is your thread #, starting at 0 and going up to numJobs()-1

Examples:
SIM/SIM_GasAdd.C.

Definition at line 107 of file UT_ThreadedAlgorithm.h.

void UT_JobInfo::lock ( ) const
inline

lock and unlock a lock shared by all the jobs. This lock is special cased to a no-op in the threadless case to avoid overhead.

Definition at line 136 of file UT_ThreadedAlgorithm.h.

int32 UT_JobInfo::nextTask ( ) const

These control a shared AtomicInt32 so you can split tasks among jobs using load balancing. The total number is in this case up to you to detect. The JobIds will start with 0 and each call will get a unique higher number. Example: for (i = info.nextTask(); i < maxtask; i = info.nextTask())

int UT_JobInfo::numJobs ( ) const
inline
Examples:
SIM/SIM_GasAdd.C.

Definition at line 108 of file UT_ThreadedAlgorithm.h.

void UT_JobInfo::resetTasks ( ) const

Resets the task list. You are responsible for creating a barrier to ensure that all the other threads have hit the end of the tasks! This is not required for your first loop as you will already start at task 0.

void UT_JobInfo::unlock ( ) const
inline

Definition at line 141 of file UT_ThreadedAlgorithm.h.

Member Data Documentation

int UT_JobInfo::myJob
protected

Definition at line 148 of file UT_ThreadedAlgorithm.h.

int UT_JobInfo::myLocalTask
mutableprotected

Definition at line 151 of file UT_ThreadedAlgorithm.h.

UT_Lock* UT_JobInfo::myLock
protected

Definition at line 149 of file UT_ThreadedAlgorithm.h.

int UT_JobInfo::myNumJobs
protected

Definition at line 148 of file UT_ThreadedAlgorithm.h.

SYS_AtomicInt32* UT_JobInfo::myTask
protected

Definition at line 150 of file UT_ThreadedAlgorithm.h.


The documentation for this class was generated from the following file: