Excessive/insfficient use of Function::update() throughout the library

Issue #263 resolved
Jan Blechta created an issue

Function::update() is used redundantly by assemblers. This may ruin scalability.

On the other hand, DirichletBC::compute_bc* lack these calls, see pull request #117.

So far suggested solutions:

  • (Garth) update lately only when necessary; vector is flagged for ghost_consistence.
  • (Martin) update early; user takes care of an update when fiddling with vector entries.

Comments (17)

  1. Jan Blechta reporter

    Here is actual MWE (run on two processes):

    from dolfin import *
    
    mesh = UnitSquareMesh(4, 5)
    V = FunctionSpace(mesh, 'CG', 1)
    
    class F(Expression):
        def eval(self, y, x):
            y[0] = 10.0
    f = project(F(), V)
    #f.update() # Uncomment to fix the problem
    
    u = Function(V)
    
    bc = DirichletBC(V, f, lambda x,onb:True)
    bc.apply(u.vector())
    
    plot(u, interactive=True)
    
  2. Prof Garth Wells

    I think the best solution is that we add a state flag to vectors to track whether or not the ghost values are up-to-date. This way we can sprinkle Function::update() without a performance hit.

  3. Martin Sandve Alnæs

    I like Garths solution, is it feasible?

    See also David Hams comment on the list: With Garths suggestion of dirty flags to vectors, access to the vector entries can mark the vector as dirty so the next time someone calls update it does the job.

  4. Prof Garth Wells

    @martinal It should be easy - we can set a flag to true after update() is called, and invalidate the flag when Generic::vector::set/get, etc is called.

    We can add a boolean argument to update() so that it can be automatic (according to the internal state flag) or forced.

  5. Jan Blechta reporter

    @garth-wells User could also have a possibility to reset a flag for the case he did not touch any ghost.

  6. Prof Garth Wells

    Fix Issue #263.

    Move calls to update vector ghost values to apply(), and after linear solves.

    Epetra implementation is flaky, but Epetra interface needs an overhaul for parallel objects.

    → <<cset 756e630ada78>>

  7. Prof Garth Wells

    Fix Issue #263.

    Move calls to update vector ghost values to apply(), and after linear solves.

    Epetra implementation is flaky, but Epetra interface needs an overhaul for parallel objects.

    → <<cset 5c29b06be35d>>

  8. Jan Blechta reporter

    @garth-wells Is it wise to remove GenericVector::update_ghost_values() which may be useful for special purpose? User would now need to downcast to PETScVector or EpetraVector.

  9. Prof Garth Wells

    @blechta I thought about keeping GenericVector::update_ghost_values(), but was swayed by not needing it in the code. I don't have a strong view either way.

  10. Jan Blechta reporter

    @garth-wells Me neither. User probably finishes every fiddling with DOFs with GenericVector::apply.

  11. Log in to comment