OP2/PyOP2 — pull request #59 by wence- (2012-09-21 17:04:42+00:00)
Title: Code caching

This branch tries to unify code caching across backends.

A base ParLoop object is created which implements __hash__. Backends can override this if necessary (as is done for opencl).
a cache for parloop objects lives in base, it's just a dict.

To put things in do:

base._parloop_cache[hash(ParLoop-object)] = whatever

To get things out:

whatever = base._parloop_cache[hash(ParLoop-object)]

As well as this, we cache references to Sparsity and Mat C-level handles and try and reuse them. This is very much needed because if we create a Mat in a loop, we leak memory because the C-level data is not cleaned up except at the exit of the program. It's also good for performance.

To make caching of Consts easier to deal with, the Const class gains a new classmethod: Const._definitions returns a canonically sorted list of known Consts.

The sequential backend now uses the parloop caching tests in test_caching.py

Buildbot pass:

http://buildbot-ocean.ese.ic.ac.uk:8080/builders/pyop2-testing/builds/209