The following is a list of other pragmas in HP aC++:
assert Pragma
#pragma assert non-zero(constant-expression) "string"
When the compiler encounters this directive, it evaluates the expression.
If the expression is zero, the compiler generates a message that contains the specified string and the compile time constant expression.
For example:
#pragma assert non_zero(sizeof(a) == 12) "a is the wrong size"
In this example, if the compiler determines that sizeof a is not 12,
the following diagnostic message is output:
"foo.c", line 10: error #2020: The assertion "(sizeof(a) == 12)" was not true.
a is the wrong size.
Consider the following example that verifies both the size of a struct
and the offset of one of its elements:
#include <stddef.h>
typedef struct {
int a;
int b;
} s;
#pragma assert non_zero(sizeof(s) == 8) "sizeof assert failed"
#pragma assert non_zero(offsetof(s,b) == 4) "offsetof assert failed"
This pragma provides a similar behavior to that of the Tru64 C compiler.
BINDING Pragma
#pragma BINDING {hidden|protected|extern|default}
Global symbols that follow this pragma will be given a specific binding.
Command line options and binding pragmas referring to specific
symbols (ex. #pragma hidden symbol) override
this pragma. This pragma will override command line bindings that
do not refer to a specific symbol (ex. -Bprotectedd).
DEFAULT_BINDING Pragma
#pragma DEFAULT_BINDING [symbol{,symbol}]
Global symbols are assigned the default export class.
These symbols may be imported or exported outside of
the current load module. The compiler will access tentative
and undefined symbols through the linkage table.
Any symbol that is not assigned to another export class through
use of another pragma (or -B option or the
deprecated +O[no]extern option) will have the default export class.
ESTIMATED_FREQUENCY Pragma
#pragma ESTIMATED_FREQUENCY f
This block-scoped pragma allows you to tell the compiler your
estimate of how frequently the current block is
executed as compared to the immediately surrounding block.
You can indicate the average trip count in the
body of a for loop or the fraction of time a then clause is executed.
Frequency, f can be expressed
as a floating-point or integer constant. The compiler accepts
preprocessor expressions that evaluate to a
compile time constant.
EXTERN Pragma
#pragma EXTERN [symbol{,symbol}]
The specified symbols, or all undefined symbols if no list is provided, are assigned to the default export class.
Additionally, the compiler will inline the import stub for calls to these symbols. No compile time binding of
these symbols will be done. All references to these symbols will be through the linkage table, so an
unnecessary performance penalty will occur if extern is applied to a listed symbol that is resolved in the
same load module. This is the pragma equivalent of -Bextern and is global in scope.
FREQUENTLY_CALLED Pragma
#pragma FREQUENTLY_CALLED [symbol{,symbol}]
This file-scoped pragma identifies functions that are frequently called
within the application. The pragma
must be placed prior to any definition of or reference to the named function.
If not, the behavior is undefined.
FREQUENTLY_CALLED pragma is independent of +Oprofile=use
in that it overrides any dynamically obtained
profile information.
HDR_STOP Pragma
#pragma HDR_STOP
This pragma instructs the compiler to stop precompiling headers.
HIDDEN Pragma
#pragma HIDDEN [symbol{,symbol}]
The specified symbols, or all symbols (if no symbols are specified),
are assigned the hidden export class. The
hidden export class is similar to the protected export class.
These symbols will not be preempted by symbols
from other load modules, so the compiler may bypass the linkage
table for both code and data references and
bind them to locally defined code and data symbols.
In addition, hidden symbols will not be exported outside the current load module.
The linker may eliminate
them from a shared library, but in an executable, they remain accessible
to the debugger unless -Oprocelim
is also specified. This is the pragma equivalent of -Bhidden and is global in scope.
HP_DEFINED_EXTERNAL Pragma
#pragma HP_DEFINED_EXTERNAL name1[,name2,...nameN]
The specified symbols, or all undefined symbols (if no list is provided), are assigned
to the default export class. Additionally, the compiler will inline the import stub
for calls to these symbols.
No compile time binding of these symbols will be done.
All references to these symbols will be through the linkage table, so an unnecessary
performance penalty will occur if extern is applied to a listed symbol that is
resolved in the same load module. This is the pragma equivalent of the -Bextern option and
is global in scope. This pragma is equivalent to the #pragma EXTERN.
HP_DEFINED_INTERNAL Pragma
#pragma HP_DEFINED_INTERNAL name1[,name2,...nameN]
The specified symbols, or all symbols (if no symbols are specified), are assigned
the protected export class. That means these symbols will not be preempted by symbols
from other load modules, so the compiler may
bypass the linkage table for both code and data references and bind them to locally
defined code and data
symbols. This pragma is equivalent to the -Bprotected option and is global in scope.
This pragma is equivalent to #pragma PROTECTED.
IF_CONVERT Pragma
#pragma IF_CONVERT
This block-scoped pragma instructs the compiler to If-Convert the
current scope. There is no command-line
option equivalent.
If-Conversion is a compiler process that eliminates
conditional branches by the use of predicates. The
compiler is instructed to If-Convert all non-loop control flow nested within the current block.
Without this pragma, the compiler would employ its own heuristics to determine whether to perform
If-Conversion. With this pragma, If-Conversion is always performed.
If-Convert can be specified in a loop containing conditional
branches other than the loop-back branch. This
makes it more likely the compiler will modulo schedule the loop, as loops containing conditional branches
are more difficult to modulo schedule. The pragma can also be used for non-looping constructs.
POP Pragma
#pragma POP
The last pushed pragma is removed from the pragma stack and state is restored.
The binding state reverts to the binding state prior to the last "push".
This pragma can only be used with the blanket binding pragmas.
PROTECTED Pragma
#pragma PROTECTED [symbol{,symbol}]
The specified symbols, or all symbols (if no symbols are specified), are assigned
the PROTECTED export class. That means these symbols will not be preempted by symbols
from other load modules, so the compiler may bypass the linkage table for both code
and data references and bind them to locally defined code and data symbols. This
pragma is equivalent to the -Bprotected option and is global in scope.
PTRS_STRONGLY_TYPED Pragma
#pragma [NO]PTRS_STRONGLY_TYPED {BEGIN | END}
This pragma turns strong pointer type testing on and off. When turned on (BEGIN) if a
pointer typing error is detected, it will generate a warning if the typing error can be
safely ignored. If the typing error cannot be safely ignored, it will generate a warning
and flag the compilation appropriately, or if this is not possible,
it will generate an error. This feature is disabled using the END attribute.
[NO]PTRS_TO_GLOBALS Pragma
#pragma [NO]PTRS_TO_GLOBALS name
This pragma aids alias analysis. It must be specified at global scope
and immediately precede the declaration of the variable or entry named.
The pragma tells the optimizer whether the global variable or
entry "name" is accessed [is not accessed] through pointers. If NOPTRS_TO_GOBALS is specified, it is assumed that statically-allocated data (including file-scoped globals, file scoped statics, and function-scoped static variables) will not be read or written through pointers. The default is PTRS_TO_GLOBALS.
PUSH Pragma
#pragma PUSH pragma_name
This pragma will save the current state on the pragma stack for the
named pragma. All subsequent uses of the named binding pragma
will be reverted
when the "pop" is encountered. Note that this pragma can only be used with the blanket binding pragmas.
RARELY_CALLED Pragma
#pragma RARELY_CALLED [symbol{,symbol}]
This file-scoped pragma identifies functions that are rarely called within the application. The pragma must be
placed prior to any definition of or reference to the named function. If not, the behavior is undefined.
RARELY_CALLED pragma is independent of +Oprofile=use option. It overrides any dynamically
obtained profile information.
STDC CX_LIMITED_RANGE Pragma
#pragma STDC CX_LIMITED_RANGE ON
#pragma STDC CX_LIMITED_RANGE OFF
This pragma enables limited range mathematical behavior for specific blocks of code. Note that, this pragma
applies to complex arithmetic only. (See ISO/IEC 9899 Standard for more information.)
This pragma can occur outside an external declaration or within a compound statement. When outside
external declarations, the pragma takes effect from its occurrence until another STDC CX_LIMITED_RANGE
pragma is encountered or until the end of the translation unit. When within a compound statement, the
pragma takes effect from its occurrence until another STDC CX_LIMITED_RANGE pragma is encountered
within a nested compound statement, or until the end of the compound statement.
If this pragma is used in any other context, the behavior is undefined. The default state is OFF.
STDC FP_CONTRACT Pragma
#pragma STDC FP_CONTRACT ON
#pragma STDC FP_CONTRACT OFF
This pragma tells the compiler whether or not it is permitted to contract expressions. See ISO/IEC 9899
Standard for more information.
Each pragma can occur either outside external declarations or preceding all explicit declarations and
statements inside a compound statement. When outside external declarations, the pragma takes effect from
its occurrence until another FP_CONTRACT pragma is encountered, or until the end of the translation unit.
When inside a compound statement, the pragma takes effect from its occurrence until another FP_CONTRACT
pragma is encountered within a nested compound statement, or until the end of the compound statement. At
the end of a compound statement, the state for the pragma is restored to its condition before the compound
statement.
If this pragma is used in any other context, the behavior is undefined. The default state is ON.
STDC FENV_ACCESS Pragma
#pragma STDC FENV_ACCESS ON
#pragma STDC FENV_ACCESS OFF
This pragma provides a means to inform the compiler when a program might access the floating point
environment to test flags or run under non-default modes. Use of the pragma allows certain optimizations
that could subvert flag tests and mode changes such as global common sub expression elimination, code
motion, and constant folding.
The pragma can be placed either outside external declarations or preceding all explicit declarations and
statements inside a compound statement. When outside external declarations, the pragma takes effect from
its occurrence until another FENV_ACCESS pragma is encountered or until the end of the translation unit.
When inside a compound statement, the pragma is in effect from its occurrence until another FENV_ACCESS
pragma is encountered within the nested compound statement or until the end of the compound statement.
At the end of a compound statement, the state for the pragma is restored to its condition just before the
compound statement.
If the pragma is used in any other context, the behavior is undefined. If part of a program tests flags or runs
under non-default mode settings but was translated with the state for the FENV_ACCESS pragma off, then the
behavior of the program is undefined.
See ISO/IEC 9899 Standard for more information.
UNROLL_FACTOR Pragma
#pragma UNROLL_FACTOR n #pragma UNROLL n #pragma UNROLL (n)
This block-scoped pragma applies the unroll factor to loops contained in the current block. You can apply an unroll factor which you think is best for the given loop or apply no unroll factor to the loop. If this pragma is not specified, the compiler uses its own heuristics to determine the best unroll factor for the inner loop.
A user specified unroll factor will override the default unroll factor applied by the compiler. Specifying n=1 will prevent the compiler from unrolling the loop. Specifying n=0 allows the compiler to use its own heuristics to apply the
unroll factor.
Note: The UNROLL_FACTOR pragma will be ignored if it is placed in a loop other than the innermost loop. The UNROLL pragma must be immediately followed by a loop statement and will be ignored if it is not
an innermost loop.
OMP ATOMIC Pragma
#pragma omp atomic
expression-stmt
where expression stmt must have one of the following forms:
- x binop = expr
- x++
- ++x
- x--
- --x
Here, x is an lvalue expression with scalar type and expr is an
expression with scalar type that does not reference the object designated by x.
The atomic directive ensures that a specific memory location is updated atomically,
rather than exposing it to the possibility of multiple, simultaneous writing threads.
OMP BARRIER Pragma
#pragma omp barrier
The barrier pragma synchronizes all the threads in a team. When encountered, each thread waits until all
the threads in the team have reached that point.
The smallest statement to contain a barrier must be a block or a compound statement.
barrier is valid only
inside a parallel region and outside the scope of for, section, sections,
critical, ordered, and master.
OMP CRITICAL Pragma
#pragma omp critical [(name)]
structured-block
The critical pragma identifies a construct that restricts the execution of
the associated structured block to one thread at a time.
The name parameter is optional. All unnamed critical sections map to the same name.
OMP FOR Pragma
#pragma omp for [clause1,clause2, ...]
for-loop
[clause1, clause2, ...] indicates that the clauses are
optional. There can be zero or more clauses.
clause may be one of the following:
- private(list)
- firstprivate(list)
- lastprivate(list)
- ordered
- schedule(kind[,chunksize])
- nowait
See OpenMP Clauses for more information.
OMP FLUSH Pragma
#pragma omp flush [(list)]
(list) names the variables that will be synchronized.
The flush pragma, whether explicit or implied, specifies a
cross-thread sequence point at which the
implementation is required to ensure that all the threads in a team
have a consistent view of certain objects
in the memory.
A flush directive without a list is implied for the following directives:
- barrier
- an entry to and exit from critical
- at entry to and exit from ordered
- at entry to and exit from parallel
- at entry to and exit from parallel for
- at entry to and exit from parallel sections
- at exit from single
- at exit from for
- at exit from sections
Note: The directive is not implied if a nowait clause is present.
OMP MASTER Pragma
#pragma omp master
structured-block
The master pragma directs that the structured block following it
should be executed by the master thread
(thread 0) of the team. Other threads in the team do not execute
the associated block.
OMP ORDERED Pragma
#pragma omp ordered
structured-block
The ordered pragma indicates that the following structured-block should
be executed in the same order in which iterations will be executed in a sequential loop.
An ordered directive must be within the dynamic extent of a for or a parallel for
construct that has an
ordered clause. When the ordered clause is used with schedule
which has a chunksize, then the chunksize
is ignored by the compiler.
OMP PARALLEL Pragma
#pragma omp parallel [clause1, clause2,...]
structured-block
[clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.
clause can be one or more of the following:
- private(list)
- firstprivate(list)
- default(shared|none)
- shared(list)
- reduction(op:list)
- if(scalar-expression)
- copyin(list)
- num_threads
The parallel pragma defines a parallel region, which is a region of the program
that is executed by multiple threads in parallel. This is the fundamental construct that
starts parallel execution.
See OpenMP Clauses for more information.
OMP PARALLEL FOR Pragma
#pragma omp parallel for [clause1, clause2, ... ]
for-loop
[clause1, clause2, ...] indicates that the clauses are optional.
There can be zero or more clauses.
The parallel for pragma is a shortcut for a parallel region that contains a single for pragma.
parallel
for admits all the allowable clauses of the parallel pragma and the for pragma except for the nowait
clause.
OMP PARALLEL SECTIONS Pragma
#pragma omp parallel sections [clause1, clause2, ...]
{
[#pragma omp section ]
structured-block
[#pragma omp section
structured-block ]
. . .
}
[clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.
The parallel sections pragma is a shortcut for specifying a parallel clause containing a single sections
pragma.
parallel sections admits all the allowable clauses of the parallel pragma and the sections
pragma except for the nowait clause.
OMP SECTIONS Pragma
#pragma omp sections [clause1, clause2, ...]
{
#pragma omp section
[ structured-block ]
[#pragma omp section
structured-block ]
. . .
}
[clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.
clause may be one of the following:
- private(list)
- firstprivate(list)
- lastprivate(list)
- reduction(op:list)
- nowait
The section or sections pragmas identify a construct that specifies a set of constructs to be divided among
threads in a team. Each section is executed by one of the threads in the team.
See OpenMP Clauses for more information.
OMP SINGLE Pragma
#pragma omp single [clause1, clause2, . . .]
[ structured-block ]
[clause1, clause2, ...] indicates that the clauses are optional.
There can be zero or more clauses.
clause may be one of the following:
- private(list)
- firstprivate(list)
- copyprivate(list)
- nowait
The single directive identifies a construct that specifies the associated
structured block that is executed by only one thread in the team (not necessarily the master thread).
See OpenMP Clauses for more information.
OMP THREADPRIVATE Pragma
#pragma omp threadprivate (list)
(list) is a comma-separated list of variables that do not have an incomplete type.
The threadprivate directive makes the named file-scope, namescope-scope, or static block-scope variables
private to a thread.
|