The C compiler accepts legacy pragmas for explicit parallelization. These are described in the C User’s Guide. As with the Fortran directives, these are only suggestions.
The legacy parallelization pragmas are:
Table B–5 Converting Legacy C Parallelization Pragmas to OpenMP
Legacy C Pragma |
Equivalent OpenMP Pragma |
---|---|
#pragma MP taskloop [clauses] |
#pragma omp parallel for [clauses] |
#pragma MP serial_loop |
No exact equivalent. You can use #pragma omp master loop |
#pragma MP serial_loop_nested |
No exact equivalent. You can use #pragma omp master loopnest |
The taskloop pragma can take on one or more of the following optional clauses.
Table B–6 taskloop Optional Clauses and OpenMP Equivalents
taskloop Clause |
OpenMP parallel for Equivalent Clause |
---|---|
maxcpus(n) |
No exact equivalent. Use num_threads(n) |
private(v1,v2,...) |
private(v1,v2,...) |
shared(v1,v2,...) |
shared(v1,v2,...) |
readonly(v1,v2,...) |
No exact equivalent. You can achieve the same effect by using firstprivate(v1,v2,...). |
storeback(v1,v2,...) |
You can achieve the same effect by using lastprivate(v1,v2,...). |
savelast |
No exact equivalent. You can achieve the same effect by using lastprivate(v1,v2,...). |
reduction(v1,v2,...) |
reduction(operator:v1,v2,...). Must supply the reduction operator as well as the list of variables. |
schedtype(spec) |
schedule(spec) (See Table B–7) |
The schedtype(spec) clause accepts the following scheduling specifications.
Table B–7 SCHEDTYPE Scheduling and OpenMP schedule Equivalents
schedtype(spec) |
OpenMP schedule( spec) Clause Equivalent |
---|---|
SCHEDTYPE(STATIC) |
schedule(static) |
SCHEDTYPE(SELF(chunksize)) |
schedule(dynamic,chunksize) Note: Default chunksize is 1. |
SCHEDTYPE(FACTORING(m)) |
No exact equivalent. |
SCHEDTYPE(GSS(m)) |
schedule(guided, m) Default m is 1. |
OpenMP scopes variables declared within a parallel construct as private. A default(none) clause on a #pragma omp parallel for directive causes the compiler to flag variables not scoped explicitly.
Since there is no serial_loop directive, mixing automatic and explicit OpenMP parallelization may have different effects: some loops may be automatically parallelized that would not have been with legacy C directives.
Because OpenMP provides a richer parallelism model, it is often possible to get better performance by redesigning the parallelism strategies of a program that uses legacy C directives to take advantage of these features.