[firedrake] tracking write accesses to dats/functions
Lawrence Mitchell
lawrence.mitchell at imperial.ac.uk
Sun Nov 23 21:01:05 GMT 2014
On 23 Nov 2014, at 12:11, Eike Mueller <eike.h.mueller at googlemail.com> wrote:
> Dear firedrakers,
>
> can I somehow check whether a dat/function has been written to since I last performed a given operation on it?
>
> I have a banded matrix A stored in each cell on mesh, and whenever I solve the equation A.x = b (separately in each column, of course) I want to do this in two steps:
>
> (1) calculate the LU decomposition (lapack dgbtrf)
> (2) solve based on that LU decomposition (lapack dgbtrs)
>
> I have to do a lot of solves, so for efficiency I want to only do (1) if my matrix A has changed. So when I do a solve, I check if a flag lu_decomp is True (and this flag is set to False upon matrix creation). If it is, then I go straight to (2), otherwise I do (1) first. But I need to make sure that whenever my banded matrix has been written to lu_decomp is set back to False.
So there are two things you can do here.
1. keep track of the flag yourself, on the assumption that the state will only be modified by your public API functions. I.e., when you do the LU decomposition, set a flag to indicate that the decomposition is valid. Then when you call an assemble (or similar) into your banded matrix invalidate that flag.
2. Not part of the public API, but Dats (and indeed Mats) are versioned objects. You can inspect the Dat._version slot. This is a state counter that gets bumped every time the Dat is modified (either by using the public data accessor, or through a par_loop of some kind). So in this case, when you do the LU decomp you record the _version slot in your object, next time through you check if this has changed.
Cheers,
Lawrence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mailman.ic.ac.uk/pipermail/firedrake/attachments/20141123/6af794e7/attachment.sig>
More information about the firedrake
mailing list