Loop iteration executes more then one OpenMP* ORDERED construct

A single loop iteration must not execute more than one ORDERED construct.

The ORDERED clause and the ORDERED construct are used to sequentially order the results of work done in parallel. It is legal for a single loop region to contain more than one ORDERED construct, but a single iteration is not allowed to execute more than one of them. This diagnostic indicates that that constraint was (or may be) violated.

ID

Observation

Description

1

OpenMP usage error

The place the second ORDERED directive is executed

2

OpenMP declaration

Location of the ordered loop

2

OpenMP declaration

The place the first ORDERED directive is executed

Examples


// Example A.24.3c from OpenMP 3.0 Specification
// Copyright (C) 1997-2008 OpenMP Architecture Review Board
// This example is legal because each iteration of the loop will
// execute only one ORDERED construct.
void work(int i) { }

void a24_good(int n)
{
    int i;
    
#pragma omp for ordered
    for (i = 0; i < n; i++) {
        if (i <= 10) {
            #pragma omp ordered
            work (i);
        }

        if (i > 10) {
            #pragma omp ordered
            work (i + 1);
        }
    }
}
        
Here is the same example in FORTRAN:

! Example A.24.3f from OpenMP 3.0 Specification
! Copyright (C) 1997-2008 OpenMP Architecture Review Board
SUBROUTINE A24_GOOD(N)
INTEGER N
!$OMP DO ORDERED
    DO I = 1,N
        IF I <= N THEN
!$OMP ORDERED
            CALL WORK(I)
!$OMP END ORDERED
        END IF
        
        IF I > N THEN
!$OMP ORDERED
            CALL WORK(I+1)
!$OMP END ORDERED
        END IF
    END DO
END SUBROUTINE A24_GOOD
        

Note iconNote

These examples, adapted from OpenMP 3.0 Specification, are covered by the following:

Copyright © 1997-2008 OpenMP Architecture Review Board.

Permission to copy without fee all or part of this material is granted, provided the OpenMP Architecture Review Board copyright notice and the title of this document appear. Notice is given that copying is by permission of OpenMP Architecture Review Board.

Copyright © 2010, Intel Corporation. All rights reserved.