#pragma directives are used within the source program to request certain kinds of special processing. #pragma directives are part of the C and C++ languages, but the meaning of any #pragma directive is defined by the implementation.
#pragma directives are expressed in the following form:
#pragma identifier [arguments] |
Compiler directives can also be specified in the following form, which has the advantage in that it can appear inside macro definitions:
_Pragma("identifier"); |
This form has the same effect as using the #pragma form, except that everything that appeared on the line following the #pragma must now appear inside the double quotation marks and parentheses. The expression inside the parentheses must be a single string literal, but it cannot be a macro that expands into a string literal. _Pragma is a SGI extension to the C and C++ standards.
The following is an example using the #pragma form:
#pragma ivdep #pragma parallel local(i, j, k) \ shared(a, b, c) |
The following is the same example using the alternative form:
_Pragma("ivdep") _Pragma("parallel local(i, j, k) \ shared(a, b, c)") |
Macro expansion occurs on the directive line after the directive name. (That is, macro expansion is applied only to arguments.) For example, if NUM_CHUNKS is a macro defined as the value 8, the original code is as follows:
#define NUM_CHUNKS 8 _Pragma("parallel numchunks(NUM_CHUNKS)") |
Table 1-1, is an alphabetical list of SGI supported #pragma directives, with a short description of each and a link to the chapter where the directive is discussed.
Table 1-1. SGI #pragma Directives
#pragma | Short Description | Functional Group |
---|---|---|
aggressive inner loop fission | Fission inner loops into as many loops as possible. | |
align_symbol | Specifies alignment of user variables, typically at cache-line or page boundaries. | |
blocking size | Sets the blocksize of the specified loop that is involved in a blocking for the primary (secondary) cache. | |
can_instantiate | Indicates that the specified declaration can be instantiated in the current compilation, but need not be. | |
concurrent | Tells the compiler to ignore assumed dependences in the following loop. | |
concurrent call | Tells the compiler that the function calls in the following loop are safe to execute in parallel. | |
concurrentize | Tells the compiler to parallelize the next loop, overriding any #pragma no concurrentize directive that may apply to that loop. | |
copyin | Copies the value from the master thread's version of an -Xlocal-linked global variable into the slave thread's version. | |
critical | Protects access to critical statements. | |
distribute | Specifies data distribution. | |
distribute_reshape | Specifies data distribution with reshaping. | |
do_not_instantiate | Prevents instantiation of the specific declaration in this compilation unit, even if that instance is used in the code. | |
dynamic | Tells the compiler that the specified array may be redistributed in the program. | |
enter gate | Indicates the point that all threads must clear before any threads are allowed to pass the corresponding #pragma exit gate. | |
exit gate | Stops threads from passing this point until all threads have cleared the corresponding #pragma enter gate . | |
fill_symbol | Tells the compiler to insert any necessary padding to ensure that the user variable does not share a cache-line with any other symbol. | |
fission | Fission the enclosing specified levels of loops after this directive. | |
fissionable | Disables validity testing. | |
fusable | Disables validity testing. | |
fuse | Fuse the following specified number of loops, which must be immediately adjacent. | |
hdrstop | Indicates the point at which the precompiled header mechanism snapshots the headers. If -pch is off, #pragma hdrstop is ignored. | |
hidden | Tells the compiler that the specified symbols are invisible to all executables or DSOs except the current one. | |
ident | Adds a .comment section in the object file and puts the revision string inside the .comment section. | |
independent | Tells the compiler to run an independent code section in parallel with the rest of the code in the parallel region. | |
inline {here|routine|global}] | Tells the compiler to inline the named functions. Keywords: here (next statement only), routine (rest of routine or until corresponding noinline is found), and global (entire file, or until corresponding noinline is found). | |
instantiate | Causes a specified instance of a template declaration to be immediately instantiated at that spot. | |
int_to_unsigned | Identifies the specified function name as a function whose type was int in a previous release of the compilation system, but whose type is unsigned int in the MIPSpro compiler release. | |
internal | Tells the compiler that the specified symbols are not referenced outside the current executable or DSO. | |
intrinsic | Allows certain preselected functions from math.h, stdio.h, and string.h to be inlined at a callsite for execution efficiency. | |
ivdep | Liberalizes dependence analysis. This applies only to inner loops. Given two memory references, where at least one is loop variant, ignore any loop-carried dependences between the two references. | |
local | Tells the compiler the names of all the variables that must be local to each thread. | |
mips_frequency_hint {NEVER|INIT} | Specifies the expected frequency of execution so the compiler can move exception code and initialization code into separate pages to minimize working set size. | |
no blocking | Prevents the compiler from involving this loop in cache blocking. | |
no concurrentize | Varies with placement. Tells the compiler to not parallelize any loops in a subroutine or file. | |
no_delete | Inhibits deletion of functions that are never referenced. | |
no fission | Keeps the following loop from being fissioned. Its innermost loops, however, are allowed to be fissioned. | |
no fusion | Keeps the following loop from being fused with other loops. | |
no interchange | Prevents the compiler from involving the loop directly following this directive (or any loop nested within this loop) in an interchange. | |
no side effects | Tells the compiler to assume that all of the named functions are safe to execute concurrently. | |
no_pch | Disables the precompiled header mechanism. | |
noinline {here|routine|global} | Tells the compiler not to inline the named functions. Keywords: here (next statement only), routine (rest of routine or until corresponding inline is found), and global (entire file, or until corresponding inline is found). | |
once | Ensures (in -n32 and -64 mode) that each include file is included at most one time in each compilation unit. | |
one processor | Causes next statement to be executed on only one processor. | |
optional | Tells the linker that the specified symbols are optional. This is the basic mechanism used for adding extensions to a library that can then be queried. | |
pack | Controls the layout of structure offsets, such that the strictest alignment for any structure member will be n bytes, where n is 0, 1, 2, 4, 8, or 16. When n is 0, the compiler returns to default alignment for any subsequent struct definitions. | |
page_place | Controls the placement of data on a DSM (distributed shared memory) machine. | |
permutation | The specified array is a permutation array. | |
parallel | Starts a parallel region. | |
pfor | Marks a for loop to run in parallel. | |
prefer concurrent | Tells the compiler to parallelize the following loop if it is safe. | |
prefer serial | Tells the compiler not to parallelize the following loop. | |
prefetch | Controls prefetching for each level of the cache. | |
prefetch_manual | Specifies whether manual prefetches (through #pragma directives) should be respected or ignored. | |
prefetch_ref | Generates a prefetch and connects it to the specified reference (if possible). | |
prefetch_ref_disable | Explicitly disables prefetching for the specified reference. | |
protected | Tells the compiler that the specified symbols are not preemptible. | |
pure | Tells the compiler that a call to named functions has no side effects and its return value depends on the values of its arguments. | |
redistribute | Specifies dynamic data redistribution. | |
reset woff | Resets listed warnings to the state specified in the command line. | Chapter 13, “Warning Suppression Control #pragma Directives” |
section_gp | Causes an object to be placed in a gp_relative section. | |
section_non_gp | Keeps an object from being placed in a gp_relative section. | |
serial | Forces the loop immediately following it to be serial, and restricts optimization by forcing all enclosing loops to be serial also. | |
set chunksize | Tells the compiler which values to use for chunksize. | |
set numthreads | Tells the compiler which values to use for numthreads. | |
set schedtype | Tells the compiler which values to use for schedtype. | |
set woff | Suppresses listed compiler warnings. | Chapter 13, “Warning Suppression Control #pragma Directives” |
shared | Tells the compiler the names of all the variables that the threads must share. | |
synchronize | Stops threads until all threads reach this point. This directive is a classic barrier construct. | |
unknown_control_flow | Indicates which procedures have a nonstandard control flow behavior. | |
unroll | Suggests to the compiler that n-1 copies of the loop body be added to the inner loop. If the loop following this directive is an inner loop, then it indicates standard unrolling (version 7.2 and later). If the loop following this directive is not innermost, then outer loop unrolling (unroll and jam) is performed (version 7.0 and later). | |
weak weak_symbol = strong_symbol | Sets weak_symbol to be an alias for the function or data object denoted by strong_symbol , unless a defining declaration for weak_symbol is encountered at static link time. If encountered, the defining declaration preempts the weak denotation. | |
weak weak_symbol | Tells the link editor not to issue a warning if it does not find a defining declaration of weak_symbol . Also allows the overriding of a current definition by a non-weak definition. |