dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22499
Re: [Bug 747318] Re: Python: Make algebra faster by using pool of vectors
This code is already in cbc.block via code injection (aka monkey patching).
Just trying to move the good stuff upstream. I don't see how your examples
differ (except for cache behaviour) - either way a new vector must be
created, no?
Den 5. apr. 2011 23.41 skrev "Johan Hake" <747318@xxxxxxxxxxxxxxxxxx>
følgende:
> Looks like a nice thing to have but I am not sure it is appropriate to
> expand DOLFIN with this functionality. It would be more natural to
> extend libraries using this, such as cbc.block, for this functionality.
>
> Also, using:
> D = A.copy()
> A += B
>
> instead of:
>
> D = A+B
>
> In this particular case it does not matter but in general it will.
>
> Johan
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> 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.)
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/dolfin/+bug/747318/+subscribe
--
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.)
Follow ups
References