![]() |
VR-Forces 4.3 Class Documentation
|
DtParallelExecutionContainer is implementation of DtExecutionContainer which executes methods on all contained objects in parallel on multiple threads. More...

Classes | |
| class | ExecutableItem |
| This class is used by TBB to manage the work units to perform. More... | |
Public Types | |
| typedef std::vector< Texec * > | PecContainerType |
| Container is a vector because that is simple to divide into ranges. | |
| typedef PecContainerType::iterator | PecIteratorType |
Public Member Functions | |
| DtParallelExecutionContainer (bool parallel=true) | |
| Construct a new container, default to parallel execution and grain_size of 10. | |
| virtual | ~DtParallelExecutionContainer () |
| Virtual destructor does NOT destroy contents. | |
| virtual void | add (Texec *item) |
| Add a reference to the container. | |
| virtual void | remove (Texec *item) |
| Remove a reference from the container. | |
| virtual void | clear () |
| Clear the container. | |
| virtual void | deleteAndClear () |
| Delete all referenced objects and then clear the container. | |
| virtual bool | empty () const |
| Check if container is empty. | |
| virtual bool | contains (Texec *item) |
| Check if container contains item. | |
| virtual PecIteratorType | begin () |
| Note: linux toolchain doesn't support const_iterator. | |
| virtual PecIteratorType | end () |
| End iterator over the container. | |
| virtual void | executeMethod (void(Texec::*theMethodPtr)()) |
| Execute method on all contained objects. | |
| virtual void | setParallel (bool parallel) |
| Set execution to either parallel or serial. | |
| virtual bool | isParallel () const |
| Get execution mode. | |
| virtual void | setGrainSize (int theGrainSize) |
| Set the number of serial executions within one parallel execution. | |
| virtual int | getGrainSize () const |
| Get the number of serial executions within one parallel execution. | |
Protected Member Functions | |
| virtual void | executeMethodParallel (void(Texec::*theMethodPtr)()) |
| Execute method on all contained objects in parallel using multiple threads. | |
| virtual void | executeMethodSerial (void(Texec::*theMethodPtr)()) |
| Execute method on all contained objects sequentially in a single thread. | |
Protected Attributes | |
| PecContainerType | myExecVec |
| The execution container. | |
Private Attributes | |
| bool | myUseParallel |
| true if using parallel execution, false for serial | |
| int | myGrainSize |
| grainSize to use for parallel execution. | |
DtParallelExecutionContainer is implementation of DtExecutionContainer which executes methods on all contained objects in parallel on multiple threads.
Note that DtParallelExecutionContainer objects are not themselves threadsafe, so you can't add items to, or remove items from the collection in different threads. Intel Thread Building Blocks (TBB) provide the parallel execution mechanism. Execution may be set to either parallel (default) or serial. Order of execution is not guaranteed in parallel mode, but is guaranteed to be order-as-added in serial execution (some derived classes require this, don't change this). In paralell execution only, contained objects are divided into groups of grainSize. Items within each group are executed sequentially, but in parallel with other groups. As recommened by TBB, each group should represent 100,000 machine cycles. For very short methods, consider a larger grainSize.
| typedef std::vector<Texec *> DtParallelExecutionContainer< Texec >::PecContainerType |
Container is a vector because that is simple to divide into ranges.
| typedef PecContainerType::iterator DtParallelExecutionContainer< Texec >::PecIteratorType |
|
inline |
Construct a new container, default to parallel execution and grain_size of 10.
|
inlinevirtual |
Virtual destructor does NOT destroy contents.
Call deleteAndClear explicitly to delete contents.
|
inlinevirtual |
Add a reference to the container.
| item | the item to add to the container. |
Implements DtExecutionContainer< Texec >.
|
inlinevirtual |
Remove a reference from the container.
| item | the item to remove from the container. |
Implements DtExecutionContainer< Texec >.
|
inlinevirtual |
Clear the container.
Implements DtExecutionContainer< Texec >.
|
inlinevirtual |
Delete all referenced objects and then clear the container.
Items are deleted sequentially, not in parallel, so item's destructor isn't required to be thread safe.
Implements DtExecutionContainer< Texec >.
|
inlinevirtual |
Check if container is empty.
|
inlinevirtual |
Check if container contains item.
| item | the item to check. |
|
inlinevirtual |
Note: linux toolchain doesn't support const_iterator.
:( Begin iterator over the container.
Referenced by DtParallelExecutionContainer< DtPreprocessor >::contains().
|
inlinevirtual |
End iterator over the container.
Referenced by DtParallelExecutionContainer< DtPreprocessor >::contains().
|
inlinevirtual |
Execute method on all contained objects.
Serial or parallel execution determined by setParallel(bool parallel).
| theMethodPtr | the method to execute. |
Implements DtExecutionContainer< Texec >.
|
inlinevirtual |
Set execution to either parallel or serial.
| parallel | true for parallel execution, false for serial execution. |
|
inlinevirtual |
Get execution mode.
|
inlinevirtual |
Set the number of serial executions within one parallel execution.
|
inlinevirtual |
Get the number of serial executions within one parallel execution.
|
inlineprotectedvirtual |
Execute method on all contained objects in parallel using multiple threads.
| theMethodPtr | the method to execute. |
|
inlineprotectedvirtual |
Execute method on all contained objects sequentially in a single thread.
| theMethodPtr | the method to execute. |
|
protected |
The execution container.
Referenced by DtParallelExecutionContainer< DtPreprocessor >::add(), DtParallelExecutionContainer< DtPreprocessor >::begin(), DtParallelExecutionContainer< DtPreprocessor >::clear(), DtParallelExecutionContainer< DtPreprocessor >::empty(), DtParallelExecutionContainer< DtPreprocessor >::end(), and DtParallelExecutionContainer< DtPreprocessor >::remove().
|
private |
true if using parallel execution, false for serial
Referenced by DtParallelExecutionContainer< DtPreprocessor >::isParallel(), and DtParallelExecutionContainer< DtPreprocessor >::setParallel().
|
private |
grainSize to use for parallel execution.
Referenced by DtParallelExecutionContainer< DtPreprocessor >::getGrainSize(), and DtParallelExecutionContainer< DtPreprocessor >::setGrainSize().