OpenACC 3.4 Directive and Clause Restrictions
This digest enumerates every rule, restriction, and mandatory condition attached to OpenACC 3.4 directives and clauses. Entries are grouped by the section that defines the constraint. Page references match the official specification pagination so each item can be cross-checked word-for-word.
Compute constructs (§2.5.4, p.36)
- Programs must not branch into or out of a compute construct.
- Only the
async,wait,num_gangs,num_workers, andvector_lengthclauses may follow adevice_typeclause on any compute construct. - At most one
ifclause may appear on a compute construct. - At most one
defaultclause may appear and its value must be eithernoneorpresent. - A
reductionclause must not appear on aparallelconstruct whosenum_gangsclause has more than one argument.
Compute construct errors (§2.5.5, p.37)
- Errors raised by violating compute construct semantics follow §2.5.5; implementations must signal
acc_error_host_only,acc_error_invalid_compute_region,acc_error_invalid_parallelism, oracc_error_invalid_matrix_shapeas described in the specification when these conditions are detected.
Enter/exit data directives (§2.6.6, p.46)
enter datadirectives must include at least one of:copyin,create, orattach.exit datadirectives must include at least one of:copyout,delete, ordetach.- Only one
ifclause may appear on either directive. finalizeonexit dataresets dynamic and attachment counters to zero for the listed variables; without it the counters are decremented normally.
Data environment (§2.6, pp.43–47)
- Implicit data lifetime management must obey the reference counter semantics in §§2.6.3–2.6.8; structured and dynamic counters must never become negative.
- Pointer attachments must respect the attach/detach counter pairing in §§2.6.7–2.6.8.
Host_data construct (§2.8, pp.62–63)
use_devicelists must reference variables that are present on the device; otherwise behavior is undefined.- Host pointers aliased inside
host_dataregions must not be dereferenced on the host while mapped to device addresses.
Loop construct (§2.9, pp.64–71)
- Only
collapse,gang,worker,vector,seq,independent,auto, andtileclauses may follow adevice_typeclause. workerandvectorclause arguments must be invariant within the surroundingkernelsregion.- Loops without
seqmust satisfy: loop variable is integer/pointer/random-access iterator, iteration monotonicity, and constant-time trip count computation. - Only one of
seq,independent, orautomay appear. gang,worker, andvectorclauses are mutually exclusive with an explicitseqclause.- A loop with a gang/worker/vector clause must not lexically enclose another loop with an equal or higher parallelism level unless the parent compute scope differs.
- At most one
gangclause may appear per loop construct. tileandcollapsemust not be combined on loops associated withdo concurrent.- Each associated loop in a
tileconstruct (except the innermost) must contain exactly one loop or loop nest. privateclauses on loops must honor Fortran optional argument rules (§2.17.1, p.100).
Cache directive (§2.10, p.75)
- References within the loop iteration must stay inside the index ranges listed in the
cachedirective. - Fortran optional arguments used in
cachedirectives must follow §2.17.1.
Combined constructs (§2.11, p.76)
- Combined constructs inherit all restrictions from their constituent
parallel,serial,kernels, andloopcomponents.
Atomic construct (§2.12, pp.77–81)
- All atomic accesses to a given storage location must use the same type and type parameters.
- The storage location designated by
xmust not exceed the hardware’s maximum native atomic width. - At most one
ifclause may appear on an atomic construct.
Declare directive (§2.13, pp.81–84)
declaremust share scope with the declared variables (or enclosing function/module scope for Fortran).- At least one clause is required.
- Clause arguments must be variable names or Fortran common block names; each variable may appear only once across
declareclauses within a program unit. - Fortran assumed-size dummy arrays cannot appear; pointer arrays lose association on the device.
- Fortran module declaration sections allow only
create,copyin,device_resident, andlink; C/C++ global scope allows onlycreate,copyin,deviceptr,device_resident, andlink. - C/C++ extern variables are limited to
create,copyin,deviceptr,device_resident, andlink. linkclauses must appear at global/module scope or reference extern/common-block entities.declareregions must not containlongjmp/setjmpmismatches or uncaught C++ exceptions.- Fortran optional dummy arguments in data clauses must respect §2.17.1.
Init directive (§2.14.1, p.85)
- May appear only in host code.
- Re-initializing with different device types without shutting down is implementation-defined.
- Initializing a device type not used by compiled accelerator regions yields undefined behavior.
Shutdown directive (§2.14.2, p.85)
- May appear only in host code.
Set directive (§2.14.3, p.87)
- Host-only directive.
default_asyncaccepts only valid async identifiers;acc_async_novalhas no effect,acc_async_syncforces synchronous execution on the default queue, andacc_async_defaultrestores the initial queue.- Must include at least one of
default_async,device_num, ordevice_type. - Duplicate clause kinds are forbidden on the same directive.
Update directive (§2.14.4, pp.88–90)
- Requires at least one of
self,host, ordeviceclauses. - If
if_presentis absent, all listed variables must already be present on the device. - Only
asyncandwaitclauses may followdevice_type. - At most one
ifclause may appear; it must evaluate to a scalar logical/integer value (Fortran vs C/C++ rules). - Noncontiguous subarrays are permitted; implementations may choose between multiple transfers or pack/unpack strategies but must not transfer outside the minimal containing contiguous region.
- Struct/class and derived-type member restrictions follow §2.14.4; parent objects cannot simultaneously use subarray notation with member subarrays.
- Fortran optional arguments in
self,host, anddevicefollow §2.17.1. - Directive must occupy a statement position (cannot replace the body after conditional headers or labels).
Wait directive (§2.16.3, p.100)
devnumvalues in wait-arguments must identify valid devices; invalid values trigger runtime errors (§2.16.3).- Queue identifiers must be valid async arguments or errors result (§2.16.3).
Routine directive (§2.15.1, pp.91–97)
- Implicit routine directives derive from usage; implementations must propagate relevant clauses to dependent procedures and avoid infinite recursion when determining implicit attributes.
gangdimension argument must be an integer constant expression in {1,2,3}.workerroutines cannot be parents of gang routines;vectorroutines cannot be parents of worker or gang routines;seqroutines cannot be parents of parallel routines.- Procedures compiled with
nohostmust not be called from host-only regions; enclosing procedures must also carrynohostwhen they call such routines.
Do concurrent integration (§2.17.2, pp.102–103)
- When mapping Fortran
do concurrentlocality specs to OpenACC clauses, users must ensure host/device sharing matches the specified locality (e.g.,localtoprivate,local_inittofirstprivate).
Data clauses (§§2.7–2.7.14, pp.48–60)
- Clause arguments must reference contiguous array sections or pointer references as defined in §2.7.1.
- Overlapping array sections in data clauses yield unspecified behavior (§2.7.1).
- Modifier keywords (
always,alwaysin,alwaysout,capture,readonly,zero) enforce the transfer behaviors in §2.7.4 and must not contradict device pointer semantics. deviceptrvariables cannot appear in other data clauses in the same region (§2.7.5).presentclauses require existing device data; absence triggers runtime errors (§2.7.6).no_createforbids allocation and therefore requires prior presence (§2.7.11).attach/detachmust pair with pointer lifetimes and respect attachment counters (§§2.7.13–2.7.14).
Cache clause (§2.10, p.75)
- Array references must remain within the listed cache ranges per iteration; violations are undefined.
Clause argument rules (§2.16, p.98)
async-argumentvalues are limited to nonnegative integers or the special constantsacc_async_default,acc_async_noval,acc_async_sync.wait-argumentsyntax[devnum:int-expr:][queues:]async-argument-listrequires valid device numbers and async identifiers.