Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::ParallelProcess Class Referenceabstract

Abstract parallelizable task. More...

#include <mitsuba/core/sched.h>

+ Inheritance diagram for mitsuba::ParallelProcess:

Public Types

enum  EStatus { EUnknown, EPause, ESuccess, EFailure }
 Return codes used by generateWork() and getReturnStatus() More...
 
typedef std::map< std::string,
int > 
ResourceBindings
 Binding from local resource names to global resource IDs. More...
 

Public Member Functions

virtual EStatus generateWork (WorkUnit *unit, int worker)=0
 Generate a piece of work. More...
 
virtual void processResult (const WorkResult *result, bool cancelled)=0
 Called whenever a work unit has been completed. More...
 
virtual void handleCancellation ()
 Called when the parallel process is canceled by Scheduler::cancel(). More...
 
EStatus getReturnStatus () const
 Query the return status of a process after its execution has finished. More...
 
virtual ref< WorkProcessorcreateWorkProcessor () const =0
 Create an instance of the algorithm responsible for executing the work units of this parallel process. More...
 
virtual void bindResource (const std::string &name, int id)
 Bind a resource to this parallel process. More...
 
virtual bool isLocal () const
 Is this process strictly local? More...
 
ELogLevel getLogLevel () const
 Return the log level for events associated with this process. More...
 
const ResourceBindingsgetResourceBindings () const
 Return a list of all bound resources. More...
 
virtual std::vector< std::string > getRequiredPlugins ()
 Return a list of plugins required by this parallel process. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 
virtual std::string toString () const
 Return a human-readable string representation of the object's contents. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

 ParallelProcess ()
 Protected constructor. More...
 
virtual ~ParallelProcess ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

ResourceBindings m_bindings
 
EStatus m_returnStatus
 
ELogLevel m_logLevel
 

Friends

class Scheduler
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Detailed Description

Abstract parallelizable task.

Instances of this class model a larger piece of work that can be split into independent `units' and subsequently farmed out over a cluster or processed locally. After the work units have been completed, the results are pieced back together to a solution of the original large-scale problem.

This class implements the core logic running on the central scheduling server, i.e. the part that is responsible for generating work units and accepting their results. The module that performs the actual computation is an instance of WorkProcessor, which is also specified here. Finally, the this class references `resources', which denote chunks of globally shared read-only data required during execution.

Member Typedef Documentation

typedef std::map<std::string, int> mitsuba::ParallelProcess::ResourceBindings

Binding from local resource names to global resource IDs.

Member Enumeration Documentation

Return codes used by generateWork() and getReturnStatus()

Enumerator
EUnknown 

Unknown return status.

EPause 

Temporarily, no work units can be created.

ESuccess 

The process finished / a piece of work was generated.

EFailure 

The process failed / no more work is available.

Constructor & Destructor Documentation

mitsuba::ParallelProcess::ParallelProcess ( )
inlineprotected

Protected constructor.

virtual mitsuba::ParallelProcess::~ParallelProcess ( )
inlineprotectedvirtual

Virtual destructor.

Member Function Documentation

virtual void mitsuba::ParallelProcess::bindResource ( const std::string &  name,
int  id 
)
virtual

Bind a resource to this parallel process.

Takes a resource ID as given by the scheduler and associates it with a name. This name can later be used by the work processor to access the resource data.

Parameters
nameProcess-specific name of the resource
idResource ID as returned by Scheduler::registerResource()
See Also
WorkProcessor::getResource

Reimplemented in mitsuba::BlockedRenderProcess.

virtual ref<WorkProcessor> mitsuba::ParallelProcess::createWorkProcessor ( ) const
pure virtual

Create an instance of the algorithm responsible for executing the work units of this parallel process.

Implemented in mitsuba::RemoteProcess, mitsuba::GatherPhotonProcess, and mitsuba::BlockedRenderProcess.

virtual EStatus mitsuba::ParallelProcess::generateWork ( WorkUnit unit,
int  worker 
)
pure virtual

Generate a piece of work.

Takes a pre-allocated WorkUnit instance of the appropriate sub-type and size (as specified by ParallelProcess::getWorkUnitName()) and fills it with the appropriate content. Returns ESuccess on success and EFailure or EPause when no more work is left – in that case, the work unit will be ignored and the process completed (EFailure) or temporarily paused (EPause). When EPause was used, resubmission via Scheduler::schedule() will be required once more work is available. In some cases, it is useful to distribute 'nearby' pieces of work to the same processor – the worker parameter can be used to implement this. This function should run as quickly as possible, since it will be executed while the scheduler mutex is held. A thrown exception will lead to the termination of the parallel process.

Parameters
unitWork unit data structure to be filled
workerID of the worker executing this function

Implemented in mitsuba::RemoteProcess, mitsuba::GatherPhotonProcess, mitsuba::ParticleProcess, mitsuba::BlockedRenderProcess, and mitsuba::BlockedImageProcess.

virtual const Class* mitsuba::ParallelProcess::getClass ( ) const
virtual
ELogLevel mitsuba::ParallelProcess::getLogLevel ( ) const
inline

Return the log level for events associated with this process.

By default, this is set to EDebug

virtual std::vector<std::string> mitsuba::ParallelProcess::getRequiredPlugins ( )
virtual

Return a list of plugins required by this parallel process.

This is required so that remote machines can load the plugins before they accept work from this process. The default implementation just returns all plugins that are loaded in the current application.

const ResourceBindings& mitsuba::ParallelProcess::getResourceBindings ( ) const
inline

Return a list of all bound resources.

EStatus mitsuba::ParallelProcess::getReturnStatus ( ) const
inline

Query the return status of a process after its execution has finished.

Returns one of Success, Failure or Unknown. (EUnknown means that the process is either still running or has never been scheduled).

virtual void mitsuba::ParallelProcess::handleCancellation ( )
virtual

Called when the parallel process is canceled by Scheduler::cancel().

The default implementation does nothing.

Reimplemented in mitsuba::RemoteProcess.

virtual bool mitsuba::ParallelProcess::isLocal ( ) const
virtual

Is this process strictly local?

If a process is marked as local, it shouldn't be distributed to remote processing nodes. The default implementation returns false.

Reimplemented in mitsuba::GatherPhotonProcess.

virtual void mitsuba::ParallelProcess::processResult ( const WorkResult result,
bool  cancelled 
)
pure virtual

Called whenever a work unit has been completed.

Note that this function may concurrently be executed by multiple threads. Also, processing of work results will generally be out of order with respect to the creation in generateWork().

When a work unit is only partially completed due to a call to Scheduler::cancel(), the second parameter is set to true. A thrown exception will lead to the termination of the parallel process.

Parameters
resultWork result to be processed
cancelledWas the associated work unit not fully completed

Implemented in mitsuba::RemoteProcess, mitsuba::GatherPhotonProcess, and mitsuba::BlockedRenderProcess.

Friends And Related Function Documentation

friend class Scheduler
friend

Member Data Documentation

ResourceBindings mitsuba::ParallelProcess::m_bindings
protected
ELogLevel mitsuba::ParallelProcess::m_logLevel
protected
EStatus mitsuba::ParallelProcess::m_returnStatus
protected
Class* mitsuba::ParallelProcess::m_theClass
static

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