Skip to content

Add thread-safety support #294

@bonachea

Description

@bonachea

Problem

Fortran's do concurrent offers (the potential for) within-image multi-threaded parallelism. The do concurrent construct greatly restricts allowable actions that are relevant to PRIF, in particular prohibiting all image control statements (F23 C1141, C1143, C15109), collective subroutines (F23 C1602) and atomic subroutines (F23 16.1-5).

Here are the PRIF entry points whose corresponding language-level feature is permitted for invocation within do concurrent:

RMA communication:

  • RMA get prif_get_*
  • RMA put prif_put_* (provided the access does not violate the rules against concurrent access to variables with SHARED or unspecified locality, F23 11.1.7.5)

Termination:

  • prif_error_stop
  • prif_fail_image

State Queries:

  • All image queries
  • All coarray queries
  • prif_get_team, prif_team_number

State Modifiers:

  • prif_allocate/prif_deallocate
  • prif_notify_wait
  • prif_alias_{create,destroy}

Proposal

In order to support PRIF clients who wish to translate do concurrent into multi-threading (e.g. by targeting OpenMP), we should offer a build of the Caffeine library that ensures all the PRIF operations above are thread-safe.

Analysis

The RMA communication and Termination PRIF subroutines in Caffeine can be made thread-safe by simply linking the thread-safe version of GASNet.

The State Queries (with the exception of prif_set_context_data) do not mutate any internal state, they only read state that is invariant within do concurrent, and thus are trivially thread-safe. prif_set_context_data does not have a directly analogous language operation, but the expected use case is MOVE_ALLOC on coarray arguments, which is an image control statement (and thus forbidden in do concurrent). Clients are free to use the coarray context data for some other purpose, but the context state is owned by the client and thus they are responsible for managing their own concurrent access to that shared state.

The State Modifier PRIF subroutines listed above will need some amount of concurrency control within the library to ensure correctness in the presence of concurrent calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions