Reference counted init and finalize
This presentation is the property of its rightful owner.
Sponsored Links
1 / 10

Reference-counted INIT and FINALIZE PowerPoint PPT Presentation


  • 46 Views
  • Uploaded on
  • Presentation posted in: General

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

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Reference counted init and finalize

Reference-countedINIT and FINALIZE

Jeff Squyres and Brian Barrett


The problem

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


Simple solution init reference count

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)


Init safe barrier

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


Finalize safe

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


Solves the problem

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


Definitions

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”


Mixing safe and not

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

    • …?


Mixing safe and not1

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


Thoughts questions

Thoughts? Questions?


  • Login