Public bug reported:

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.)

** Affects: dolfin
     Importance: Undecided
         Status: New

-- 
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.)

_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to     : dolfin@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dolfin
More help   : https://help.launchpad.net/ListHelp

Reply via email to