mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-08 07:32:12 +01:00
35 lines
1.9 KiB
TeX
35 lines
1.9 KiB
TeX
%\pagebreak
|
|
\section{Assumption Directives}
|
|
\label{sec:assumption}
|
|
%\index{assumption!assume directive@\kcode{assume} directive}
|
|
%\index{assumption!assumes directive@\kcode{assumes} directive}
|
|
\index{directives!assume@\kcode{assume}}
|
|
\index{directives!assumes@\kcode{assumes}}
|
|
\index{assume directive@\kcode{assume} directive}
|
|
\index{assumes directive@\kcode{assumes} directive}
|
|
|
|
\index{directives!begin assumes@\kcode{begin assumes}}
|
|
\index{begin assumes directive@\kcode{begin assumes} directive}
|
|
|
|
\index{no_parallelism clause@\kcode{no_parallelism} clause}
|
|
\index{clauses!no_parallelism@\kcode{no_parallelism}}
|
|
\index{holds clause@\kcode{holds} clause}
|
|
\index{clauses!holds@\kcode{holds}}
|
|
|
|
Assumption directives provide additional information about the expected properties of
|
|
the program that may be used by an implementation for optimization.
|
|
Ignoring this information should not alter the behavior of the program. The C/C++ example
|
|
shows the use of delimited scope (Case 1) and block-associated (Case 2) assumption directives.
|
|
A similar effect is shown for Fortran where the \kcode{assumes} directive is used in the module (Case 1)
|
|
and the block-associated directive uses an \kcode{end assume} termination (Case 2).
|
|
The function \ucode{fun} is annotated with the \kcode{no_parallelism} clause, using the \kcode{begin assumes}
|
|
(C) or \kcode{assumes} (Fortran) directive, to indicate that no implicit/explicit tasks are generated and no
|
|
SIMD constructs are encountered during execution of the function. If the function \ucode{fun} contains
|
|
task-generating or SIMD constructs then the behavior would be undefined. The block-associated
|
|
\kcode{assume} directive is used to indicate that \ucode{N} is a multiple of 8 and
|
|
will always be equal to or greater than 1. This information, if used for optimization,
|
|
could eliminate additional checks.
|
|
|
|
\cexample[5.1]{assumption}{1}
|
|
\ffreeexample[5.1]{assumption}{1}
|