← Back to team overview

dolfin team mailing list archive

Re: Compile time of forms and linear algebra operators

 

Let's wait with this patch until we have decided on what the options
should look like (arguments to assemble or global parameters).

-- 
Anders


On Mon, Jun 30, 2008 at 04:27:51PM +0200, Johan Hake wrote:
> On Monday 30 June 2008 13:28:11 Martin Sandve Alnæs wrote:
> > 2008/6/30 Anders Logg <logg@xxxxxxxxx>:
> > > On Mon, Jun 30, 2008 at 12:50:39PM +0200, Martin Sandve Alnæs wrote:
> > >> 2008/6/28 Anders Logg <logg@xxxxxxxxx>:
> > >> > On Sat, Jun 28, 2008 at 08:55:44PM +0200, Johan Hake wrote:
> > >> >> Hello!
> > >> >>
> > >> >> I tried to compile an advection diffusion form using Streamline
> > >> >> Upwind Petrow Galerkin stabilazing method, similar to the one
> > >> >> introduced in DOLFIN 0.6.4. Using 3 dimensional and first degree
> > >> >> Lagrange elements, FFC/g++ chokes when the produced code is
> > >> >> compiling. It wont finish compile... Is this a known problem and a
> > >> >> limitation of FFC/g++?
> > >> >
> > >> > Try compiling with the -r quadrature option. I guess this is not
> > >> > supported in the JIT compiler yet, but could easily be added. There
> > >> > should be an option
> > >> >
> > >> >  dolfin_set("form representation", "quadrature");
> > >> >
> > >> > in the same way as there is an option "optimize". See if you can
> > >> > figure it out and send a patch, or else file a bug report.
> > >> >
> > >> > Options are added in DefaultParameters.h in DOLFIN and the JIT
> > >> > compiler is in jit.py in FFC.
> 
> The jit compiler allready a kwarg for the representation. The only thin I had 
> to add was a dolfin_set("form representation",value). The value of this 
> parameter is checked if an uncompiled form is sent to the assemble function. 
> The value is then just passed to jit, without checkes. I also added a 
> dolfin_set("quadrature points",value) which is also just passed to the jit 
> compiler. 
> 
> The changes is only done in the python interface, i.e., in assemble.py. Maybee 
> you freek on this Anders? I thought the changes would not have any meaning 
> for the c++ interface and therefore I did not add the parameters in 
> DefaultParameters.h.
> 
> > >> > Possible options for "form representation" are "tensor", "quadrature"
> > >> > and (unsupported at the moment) "symbolic" (for SyFi).
> 
> As it is now ffc check if the string is "tensor" if not it assume it is 
> quadrature. A more thorough check would be nice.
> 
> > >> > The quadrature representation generates much less code than the tensor
> > >> > representation.
> 
> It did, and it compiled nicely!
> 
> > >> SFC also does quadrature (in fact most users (me) mainly use that),
> > >> and there are many possible compilation options. I don't think it's a
> > >> good idea to mix form compiler details into dolfin. We should talk about
> > >> this to find a solution that doesn't discriminate form compilers :-)
> > >
> > > I think we need have to. It is DOLFIN that sends the form to the form
> > > compiler so DOLFIN needs to make a choice which form compiler to use.
> > >
> > > But I agree we should not discriminate form compilers. Any form
> > > compiler that handles UFL/UFC should be possible to use.
> >
> > Then we should at least have an options system that doesn't
> > need every possible form compiler option pre-registered.
> >
> > And setting form compiler options globally for all jit calls may not
> > be enough, different forms may call for different compilation options.
> >
> > As I see it, dolfin doesn't need to know more than the option "form
> > compiler". Compiler-specific options should be applied to the particular
> > compiler.
> >
> > Like:
> > dolfin_set("form compiler", "ffc")
> > ffc_set("form representation", "quadrature")
> > A = assemble(ufl_form, ...)
> >
> > or:
> > dolfin_set("form compiler", "sfc")
> > A = assemble(ufl_form, ..., options=sfc_options_dict)
> 
> I like this. 
> 
> For now one could just get around all this parameter settings by just send a 
> precompiled form to assemble. I assume that this is what you do Martin?
> 
> Johan
> 
> 
> 

> # HG changeset patch
> # User "Johan Hake <hake@xxxxxxxxx>"
> # Date 1214813815 -7200
> # Node ID dc59b16c6b0174f1a59ca7a4102169e21cb5c32d
> # Parent  6f19d6b94b9ffc0391f42453cdcb4439c26a73e9
> Added functionality to assemble forms using quadrature representation in pyDOLFIN.
> 
> Usage:
>   dolfin_set("form representation", "quadrature")
>   dolfin_set("quadrature points",2)
> 
>   A = assemble(A_form, mesh)
> 
> diff -r 6f19d6b94b9f -r dc59b16c6b01 site-packages/dolfin/assemble.py
> --- a/site-packages/dolfin/assemble.py	Sun Jun 29 19:47:59 2008 +0100
> +++ b/site-packages/dolfin/assemble.py	Mon Jun 30 10:16:55 2008 +0200
> @@ -35,6 +35,11 @@ _dof_map_cache = {}
>  # Cache for tensors
>  _tensor_cache = {}
>  
> +# Add parameters for form representation.
> +# Used when the jit compiler is called in assemble
> +dolfin_add("form representation",common.constants.FFC_REPRESENTATION)
> +dolfin_add("quadrature points",0)
> +
>  # JIT assembler
>  def assemble(form, mesh, coefficients=None, dof_maps=None,
>      cell_domains=None, exterior_facet_domains=None, interior_facet_domains=None, reset_tensor=None,
> @@ -44,6 +49,8 @@ def assemble(form, mesh, coefficients=No
>      # Create empty list of coefficients, filled below
>      _coefficients = ArrayFunctionPtr()
>  
> +    # FIXME: We need to check the rank and dimension of any provided coeffisient function,
> +    # so they corresponds with the one in the form, see bug #45.
>      # Extract coefficients
>      if not coefficients is None: 
>          # Compile all strings as dolfin::Function
> @@ -69,8 +76,15 @@ def assemble(form, mesh, coefficients=No
>      # Check if we need to compile the form (JIT)
>      if not hasattr(form, "create_cell_integral"):
>          # FFC form, call JIT compile
> -        optimize = dolfin_get("optimize form") or dolfin_get("optimize")
> -        (compiled_form, module, form_data) = jit(form, optimize=optimize)
> +        
> +        # Collect parameters that will be passed to the jit compiler
> +        optimize       = dolfin_get("optimize form") or dolfin_get("optimize")
> +        representation = dolfin_get("form representation")
> +        options        = common.constants.FFC_OPTIONS.copy()
> +        options["quadrature_points="] = int(dolfin_get("quadrature points"))
> +
> +        (compiled_form, module, form_data) = jit(form, representation = representation,\
> +                                                 optimize=optimize, options=options)
>          
>          # Extract coefficients from form if no coefficients are provided
>          if coefficients is None:

> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev

Attachment: signature.asc
Description: Digital signature


References