← Back to team overview

ffc team mailing list archive

Re: [Ufl] [Bug 769811] [NEW] JIT cache problem with id(form)

 

On Tuesday April 26 2011 08:32:24 Anders Logg wrote:
> Is no one listening???

I am.
 
> Look at preprocess.py in UFL. It caches the preprocessed form and the
> preprocessed form holds the form data. This is the same as Martin's
> original design as far as I can tell.
> 
> The difference is that a call to preprocess is necessary but that just
> returns the cached form.

I think preprocess should return the form_data and _not_ the preprocessed 
form. The preprocessed form should be (and are) attached to form_data. The 
form_data method should then be update to:

 def form_data(self):
     if self._form_data is None:
         self._form_data = preprocessed(self)
     return self._form_data

then in jit_compile() we just do:

  form_data = form.form_data()
  preprocessed_form = form_data._form

removing all logic from jit_compile.

Johan

> --
> Anders
> 
> On Tue, Apr 26, 2011 at 08:18:01AM -0700, Johan Hake wrote:
> > Why can't we just go with the original design of Martin?
> > 
> > In jit_compiler() we just call:
> > 
> > form_data = form.form_data()
> > 
> > This will generate the form data, including the preprocessed form
> > attached to it, if the form_data is not already generated.
> > 
> > Then we get the preprocessed form by:
> >   form_data.form
> > 
> > We need to add a call to preprocess within Form.form_data(), (if it is
> > not already generated), and we need to remove the reference stored by
> > the preprocessed form to the form_data to avoid circular dependency. We
> > also need to make preprocess return the form_data instead of the
> > preprocessed form.
> > 
> > Johan
> > 
> > On Tuesday April 26 2011 07:55:44 Anders Logg wrote:
> > > On Tue, Apr 26, 2011 at 03:45:22PM +0100, Garth N. Wells wrote:
> > > > On 26/04/11 13:51, Anders Logg wrote:
> > > > > On Tue, Apr 26, 2011 at 02:00:50PM +0200, Anders Logg wrote:
> > > > >> It feels good that you trust me enough to handle it. ;-)
> > > > >> 
> > > > >> Will add it sometime this afternoon and then we can revisit the
> > > > >> JIT compiler caching.
> > > > > 
> > > > > I'm getting confused here... Looking at preprocess.py in UFL, I see
> > 
> > this:
> > > > It is confusing. Does the function 'preprocess' do anything that the
> > > > old FormData class didn't? It would be easier to follow if Form just
> > > > had a member function form_data() that computes and stores data
> > > > (like it used to), or if Form had a 'preprocess' function. Having
> > > > the function preprocess return a new form is really confusing.
> > > 
> > > I don't find that particularly confusing. It's the same as
> > > 
> > >   refined_mesh = refine(mesh)



References