← Back to team overview

dolfin team mailing list archive

Re: [Bug 747318] Re: Python: Make algebra faster by using pool of vectors

 

As I said, this example won't make a difference as it start of with a
copy. But for a longer algorithm it might be worth while instantiating
some tmp vectors and use imul. Imul does not generate additional
vectors.

Johan

On Apr 7, 2011, at 12:07, Joachim Haga <jobh@xxxxxxxxx> wrote:

> This code is already in cbc.block via code injection (aka monkey
patching)

-- 
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/747318

Title:
  Python: Make algebra faster by using pool of vectors

Status in DOLFIN:
  New

Bug description:
  In Python, the natural way to write matrix algebra involves a lot of
  temporary vector creation. By implementing a pool of vectors, I see a
  15-20% performance improvement in a matrix-algebra heavy workload. The
  basic idea is to add a method to the GenericMatrix interface (Python
  only, probably). Then Matrix.__mul__ (and everywhere else a vector is
  needed) can use this method whenever they need to create a vector, and
  they are transparently re-used whenever they go out of scope.

      @vec_pool
      def create_vec(self, dim=1):
          vec = dolfin.Vector()
          self.resize(vec, dim)
          return vec

  The implementation of the vec_pool decorator is found here: http://bazaar.launchpad.net/~jobh/cbc.block/trunk/download/head:/block/object__pool.py/object_pool.py
  (code copyright me, LGPL or whatever you prefer.)



References