1.5. Render Engines

class raysect.core.workflow.RenderEngine[source]

Provides a common rendering workflow interface.

This is a base class, its functionality must be implemented fully by the deriving class.

This class provides a rendering workflow that abstracts away the underlying system performing the work. It is intended that render engines may be built that provide rendering on single cores, multi-cores (SMP) and clusters.

The basic workflow is as follows. The render task is split into small, self-contained chunks of work - ‘tasks’. These tasks are passed to the render engine which distributes the work to the available computing resources. These discrete computing resources are know as “workers”. Workers process one task at a time and return their result to the render engine. When results are received the render engine assembles them into the final result.

This workflow is implemented by supplying a set of tasks and two methods to the render engines’ run() method which processes those tasks. The functions supplied to the run() method may be given additional args and kwargs.

A worker calls render for each task object received. render has the following signature:

def render(task, *render_args, **render_kwargs)

where args and kwargs are additional arguments supplied by the user.

Similarly, the worker calls update() for the results generated by a call to render(). Update() has the following signature:

def update(results, *update_args, **update_kwargs)

where args and kwargs are additional arguments supplied by the user.

The render() function must return an object representing the results, this must be a picklable python object.

run(tasks, render, update, render_args=(), render_kwargs={}, update_args=(), update_kwargs={})[source]

Starts the render engine executing the requested tasks.

Parameters:
  • tasks (list) – List of user defined tuples that describe the task to execute.
  • render (object) – Callable python object that executes the tasks.
  • update (object) – Callable python object that is called following a render task and must be used to update the internal state of the object requesting work.
  • render_args (tuple) – Additional arguments to pass to user defined render function.
  • render_kwargs (tuple) – Additional keyword arguments to pass to user defined render function.
  • update_args (tuple) – Additional arguments to pass to user defined update function.
  • update_kwargs (tuple) – Additional keyword arguments to pass to user defined update function.
worker_count()[source]

Returns the number of workers in use by this engine.

class raysect.core.workflow.SerialEngine[source]

Bases: raysect.core.workflow.RenderEngine

Render engine for running on a single CPU processor.

This engine is useful for debugging.

class raysect.core.workflow.MulticoreEngine(processes=None)[source]

Bases: raysect.core.workflow.RenderEngine

A render engine for distributing work across multiple CPU cores.

The number of processes spawned by this render engine is controlled via the processes attribute. This can also be set at object initialisation.

If the processes attribute is set to None (the default), the render engine will automatically set the number pf processes to be equal to the number of CPU cores detected on the machine.

Parameters:processes – The number of worker processes, or None to use all available cores (default).