[firedrake] tracking write accesses to dats/functions

Eike Mueller e.mueller at bath.ac.uk
Mon Nov 24 10:38:12 GMT 2014


Hi Lawrence,

thanks, option 2 seems to be more fool-proof since I don’t have to remember to track all writes myself. I have implemented this now and it works (all changes pushed to firedrake-helmholtzsolver).

Cheers,

Eike

--

Dr Eike Hermann Mueller
Research Associate (PostDoc)

Department of Mathematical Sciences
University of Bath
Bath BA2 7AY, United Kingdom

+44 1225 38 5803
e.mueller at bath.ac.uk
http://people.bath.ac.uk/em459/

> On 23 Nov 2014, at 21:01, Lawrence Mitchell <lawrence.mitchell at imperial.ac.uk> wrote:
> 
> 
> On 23 Nov 2014, at 12:11, Eike Mueller <eike.h.mueller at googlemail.com <mailto: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
> _______________________________________________
> firedrake mailing list
> firedrake at imperial.ac.uk <mailto:firedrake at imperial.ac.uk>
> https://mailman.ic.ac.uk/mailman/listinfo/firedrake <https://mailman.ic.ac.uk/mailman/listinfo/firedrake>
-------------- next part --------------
HTML attachment scrubbed and removed


More information about the firedrake mailing list