grale.renderers

This module describes the ‘renderers’ you can use. By default, calculating a lens plane mapping or a mass density on a grid, will only use a single processor core. Functions in the plotutil module take a renderer argument, with which you can specify an external process to be used for this purpose. Depending on the type selected, this can use multiple threads, distributed processes using MPI, or the GPU using OpenCL, each of which can lead to a significant speedup.

A specified renderer can either be one of the objects that are present in this module, or it can simply be a string that describes the kind of renderer to use. For a lens plane renderer these strings (case insensitive) and objects can be:

For a mass density renderer these strings (case insensitive) and objects can be:

Defaults

grale.renderers.setDefaultMassRenderer(x)

Sets the default mass renderer, see the module documentation for allowed values.

grale.renderers.getDefaultMassRenderer()

Returns the default mass renderer that was set using setDefaultMassRenderer().

grale.renderers.setDefaultLensPlaneRenderer(x)

Sets the default lens plane renderer, see the module documentation for allowed values.

grale.renderers.getDefaultLensPlaneRenderer()

Returns the default lens plane renderer that was set using setDefaultLensPlaneRenderer().

Lens plane renderers

class grale.renderers.ThreadsLensPlaneRenderer(numProcesses=None, feedbackObject=None)

Renderer that uses multiple threads to speed up the calculation of a lens plane.

__init__(numProcesses=None, feedbackObject=None)

If numProcesses is set, a specific number of threads will be requested. A specific feedback object can be specified for status and progress updates.

class grale.renderers.MPILensPlaneRenderer(numProcesses=None, feedbackObject=None)

Renderer that uses multiple processes (using MPI) to speed up the calculation of a lens plane.

__init__(numProcesses=None, feedbackObject=None)

If numProcesses is set, a specific number of threads will be requested by passing the -np option to mpirun. A specific feedback object can be specified for status and progress updates.

class grale.renderers.OpenCLLensPlaneRenderer(feedbackObject=None)

Renderer that uses OpenCL to use your GPU to speed up the calculation of a lens plane.

__init__(feedbackObject=None)

A specific feedback object can be specified for status and progress updates.

class grale.renderers.NetcatLensPlaneRenderer(port, feedbackObject=None)

Forward rendering commands to another process over a TCP connection using the netcat (nc) tool.

On the other machine, you can use socat to redirect stdout/stdin of one of the render programs over the connection. For example

export GRALE_NUMTHREADS=36
socat TCP4-LISTEN:9999,reuseaddr,fork EXEC:grale_lensplane_threads

would wait for incoming TCP connections on port 9999, and start the thread based lens plane renderer when an incoming connection was detected.

To run one of the MPI based renderers, socat cannot be used (pipes are used for the communication instead of stdin/stdout). Instead, there’s a helper program grale_socket_to_mpi.py, for example:

grale_socket_to_mpi.py 9998 mpirun grale_massdens_mpi
__init__(port, feedbackObject=None)

Connect to localhost (127.0.0.1) on the specified port number. The idea is to use SSH tunnels to connect to another machine.

Mass density renderers

class grale.renderers.ThreadsMassDensityRenderer(numProcesses=None, feedbackObject=None)

Renderer that uses multiple threads to speed up the calculation of a mass density map.

__init__(numProcesses=None, feedbackObject=None)

If numProcesses is set, a specific number of threads will be requested. A specific feedback object can be specified for status and progress updates.

class grale.renderers.MPIMassDensityRenderer(numProcesses=None, feedbackObject=None)

Renderer that uses multiple processes (using MPI) to speed up the calculation of a mass density map.

__init__(numProcesses=None, feedbackObject=None)

If numProcesses is set, a specific number of threads will be requested by passing the -np option to mpirun. A specific feedback object can be specified for status and progress updates.

class grale.renderers.NetcatMassDensityRenderer(port, feedbackObject=None)

Forward rendering commands to another process over a TCP connection using the netcat (nc) tool. See NetcatLensPlaneRenderer for examples.

__init__(port, feedbackObject=None)

Connect to localhost (127.0.0.1) on the specified port number. The idea is to use SSH tunnels to connect to another machine.