UT_JobInfo Class Reference

#include <UT_ThreadedAlgorithm.h>

List of all members.

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 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 94 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 97 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++)

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 109 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 137 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 110 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 142 of file UT_ThreadedAlgorithm.h.


Member Data Documentation

int UT_JobInfo::myJob [protected]

Definition at line 149 of file UT_ThreadedAlgorithm.h.

int UT_JobInfo::myLocalTask [mutable, protected]

Definition at line 152 of file UT_ThreadedAlgorithm.h.

Definition at line 150 of file UT_ThreadedAlgorithm.h.

int UT_JobInfo::myNumJobs [protected]

Definition at line 149 of file UT_ThreadedAlgorithm.h.

Definition at line 151 of file UT_ThreadedAlgorithm.h.


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

Generated on Mon Jan 28 00:30:11 2013 for HDK by  doxygen 1.5.9