Skip to content

nowait option could stop adding barriers after Directives that imply implicit barriers #3306

@sergisiso

Description

@sergisiso

On lfric_atm, a script adds first the OMPParallelDirectiveTrans followed by adding OMPLoopTrans (Do) with nowaits.

The nowait logic starts adding barriers before each dependency in the loop, but it does not consider that OMPParallelDirective already finishes with a implicit barrier.

This is a problem because this will end up with barriers outside the parallel region which then we rightfully refuse to generate with:
Generation Error: OMPBarrierDirective must be inside an OMP parallel region but could not find an ancestor OMPParallelDirective node

For the time being I suggested adding:

for barrier in psyir.walk(OMPBarrierDirective):
    if barrier.ancestor(OMPParallelDirective):
        # If a Barrier is outside a OMPParallel Region it can be deleted as each Parallel
        # region ends with an implicit barrier, and therefor all wait dependencies will be
        # satisfied at that point
        barrier.detach()

in their script. But @LonelyCat124 would it be feasible to consider the existing OMPParallelDirective as "satisfying the dependencies" when adding nowaits? Alternatively (or in addition), could OMPMinimiseSyncTrans remove these (doing something similar to what is done)?

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