1 / 10

Reference-counted INIT and FINALIZE

Reference-counted INIT and FINALIZE. Jeff Squyres and Brian Barrett. The Problem. INIT and FINALIZE can only be called once Problematic for nested software layers that use MPI …especially when the layers are unrelated …especially in multi-threaded scenarios MPI_INITIALIZED is not enough

kert
Download Presentation

Reference-counted INIT and FINALIZE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Reference-countedINIT and FINALIZE Jeff Squyres and Brian Barrett

  2. The Problem • INIT and FINALIZE can only be called once • Problematic for nested software layers that use MPI • …especially when the layers are unrelated • …especially in multi-threaded scenarios • MPI_INITIALIZED is not enough • Race condition between checking INITIALIZED and calling INIT • How to determine who calls MPI_FINALIZE? • FINALIZED does not help

  3. Simple solution:INIT reference count • MPI_INIT_SAFE(argc, argv, required, provided) • Essentially the same as INIT_THREAD • But it can safely be called multiple times • Will initialize MPI exactly once the first time it is invoked • Implementation choice what to return in “provided” after the 1st call • Guaranteed safe if multiple threads call it simultaneously • Will not return until MPI is initialized • (replace _SAFE with a better name)

  4. INIT_SAFE Barrier Keep barrier-like semantics of MPI_INIT_SAFE Application’s responsibility to make sure the barrier from MPI_INIT_SAFE calls “match” as desired

  5. FINALIZE_SAFE • MPI_FINALIZE_SAFE(finalized) • Analogous to MPI_INIT_SAFE • After FINALIZE_SAFE has been invoked as many times as INIT_SAFE, MPI is actually finalized • finalized returns whether MPI was actually finalized • May also be desirable to make FINALIZE_SAFE return a non-fatal error if MPI has already been finalized • Prevent thread races trying to guarantee MPI finalization

  6. Solves the problem Software layer A MPI_INIT_SAFE . . . . . MPI_FINALIZE_SAFE This INIT_SAFE is after the FINALIZE_SAFE in layer A. w00t! Software layer B MPI_INIT_SAFE . . . . . MPI_FINALIZE_SAFE Time Software layer C MPI_INIT_SAFE . . . . . MPI_FINALIZE_SAFE

  7. Definitions • Still not allowing MPI to be initialized after it has been finalized • Amend INITIALIZED definition: • Current: “returns true if MPI_INIT has been called” • Change: “returns true if MPI has been initialized” • Amend FINALIZED definition: • Current: “returns true if MPI_FINALIZE has completed” • Change: “returns true if MPI has been finalized”

  8. Mixing SAFE and (not) • What if one thread calls INIT[_THREAD] and another calls INIT_SAFE? • Similar issue for FINALIZE / FINALIZE_SAFE • Several choices: • Error (i.e., do not allow mixing) • If INIT called, it must be first. INIT_SAFE is OK after that • If INIT_SAFE invoked first, INIT / INIT_THREAD behaves just like INIT_SAFE (for legacy middleware) • If INIT_SAFE invoked at all, INIT / INIT_THREAD behaves just like INIT_SAFE • …?

  9. Mixing SAFE and (not) • Finalize choices: • FINALIZE ignores ref count and finalizes everything • If initialized refcount > 1, FINALIZE acts like FINALIZE_SAFE • No notification is provided via FINALIZE as to whether MPI is actually finalized

  10. Thoughts? Questions?

More Related