[petsc-dev] PetscLogEventRegister() is problematic since it must be call in exactly the same order on all ranks

Jed Brown jed at jedbrown.org
Mon Sep 19 15:33:58 CDT 2022


With shared libraries, you can use __attribute__((constructor)) to run when the shared library is loaded, though this is problematic with static libraries.

In libCEED, we adopted a strategy using weak symbols to register everything (including optional dependencies) without needing any feature macros defined. Ultimately, if everything is going to be registered at program start-up, I think PetscInitialize can call all the registrations directly instead of lazily.

Barry Smith <bsmith at petsc.dev> writes:

>   PetscErrorCode  SNESCreate(MPI_Comm comm,SNES *outsnes)
> {
> ....
>   PetscCall(SNESInitializePackage());
>
> One rank creates a SNES, another one doesn't completely different order of registration hence a complete mess.
>
> With dynamic libraries 
>
> PETSC_EXTERN PetscErrorCode PetscDLLibraryRegister_petscsnes(void)
> {
>   PetscFunctionBegin;
>   PetscCall(SNESInitializePackage());
>   PetscFunctionReturn(0);
> }
>
> Everything gets initialized when the libraries are loaded so they can be in the same order.
>
> I believe Jed found some nonstandard magic that when using shared? classic? libraries triggering an initialization function in C from that library that could solve the problem but I forgot what it was. We should start using it, like Jed said we should have five years ago :-).
>
> Barry
>
>
>> On Sep 17, 2022, at 7:53 AM, Matthew Knepley <knepley at gmail.com> wrote:
>> 
>> It has to be collective, so how could it not be called in the same order?
>> 
>>    Matt
>> 
>> On Fri, Sep 16, 2022 at 9:05 PM Barry Smith <bsmith at petsc.dev <mailto:bsmith at petsc.dev>> wrote:
>> PetscLogEventRegister() is problematic since it must be call in exactly the same order on all ranks. So for any computing beyond the trivial we've been doing for 30 years -log_view is worthless
>> 
>> 
>> 
>> 
>> 
>> -- 
>> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
>> -- Norbert Wiener
>> 
>> https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>


More information about the petsc-dev mailing list