Possible memory leak when assembling ufl form in C++ Expression's eval (using pybind11 and MPI)

Issue #1031 closed
Geert Buckinx created an issue

Dear Fenics Community,

I am trying to assemble a ufl form within the eval method of a C++ Expression subclass, which I interface with python through pybind11. However, depending on the mesh size and the number of MPI processes, my program seems to hang, perhaps due to a memory leakage which I could not identify.

I have included a minimal working example below, which runs successfully in FEniCS docker version 2018.1.0 (stable release ) via "mpirun -np NP python3 minworkexample.py", if NP=1,2 or 4, and fails if NP=3.

Could you help me identify what goes wrong?

Kind regards, Geert

Comments (7)

  1. Francesco Ballarin

    One issue I see is that

    values[0] =  assemble(*_integralform);
    

    is a collective operation on mesh.mpi_comm(). However, the call to eval is not collective.

  2. Geert Buckinx reporter

    Dear Francesco, thanks for your reply, in that case it is not a bug, but rather a programming mistake. Do you have any advice on how I could proceed to call assemble collectively (over the entire mesh) from within eval?

    Kind regards,

    Geert

  3. Francesco Ballarin

    Since we believe now that this is not a bug, it might be best to close this and re-open as a question on the allanswered forum. I would suggest to add some more background on what you are trying to do, because without that I cannot understand why you would be trying to evaluate an integral (i.e., something that will result in a number that does not depend on the provided coordinate) inside eval.

    Francesco

  4. Geert Buckinx reporter

    Dear Francesco,

    You are right indeed, thanks for your time though! Before re-opening the issue as a question on the allanswered forum, I will give it some more thought.

    Kind regards,

    Geert

  5. Log in to comment