Add tests for evaluation of expressions in directive arguments #122
Open
Ryanpadrone wants to merge 3 commits intoOpenACCUserGroup:masterfrom
Open
Add tests for evaluation of expressions in directive arguments #122Ryanpadrone wants to merge 3 commits intoOpenACCUserGroup:masterfrom
Ryanpadrone wants to merge 3 commits intoOpenACCUserGroup:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature Under Test
OpenACC 3.4 (Feb 2026), Section 2.1
Clarified user-visible behavior of evaluation of expressions in directive arguments.
This clarification states that expressions appearing in directive arguments (e.g., num_gangs(expr), if(expr), async(expr), array section bounds, etc.):
•May be evaluated in any order
•May be evaluated more than once
•May possibly not be evaluated at all (if the implementation determines they are not needed)
•Must not have user-visible behavior that depends on side effects from those evaluations
A conforming program must not rely on side effects (e.g., ++i global state updates) occurring during evaluation of directive argument expressions.
Files
•acc_expr_eval_directive_args.c
•acc_expr_eval_directive_args.cpp
•acc_expr_eval_directive_args.F90
Each file contains 3 tests
Test Design
T1–Pure Expression in Directive Arguments
uses nontrivial but side-effect-free expressions inside directive arguments:
•if((cond == 1) && ((n / 2) > 0))
•num_gangs(foo_pure(...))
•vector_length((n % 128) + 1) (C/C++)
•async(MOD(...)) (Fortran)
Purpose: Validates that directive arguments may contain arbitrary expressions and still produce correct program behavior.
T2-Elidable Expression in update ... if_present
Executes:
#pragma acc update device(a[0:size_maybe_elided(n)]) if_presentwhere a is intentionally not present on the device.
The section length expression calls a function with a side effect (size_maybe_elided), but the test:
•Does not assert how many times it is called
•Only checks that host data remains unchanged
•Ensures no runtime failure occurs
Purpose: Validates that directive argument expressions may be elided and that user-visible behavior remains correct.
T3–Side-Effecting Expressions in Directive Arguments
Uses side-effecting expressions inside directive arguments:
C/C++:
Fortran:
The program does not rely on the final value of the side-effect variable. Only numeric correctness of c[i] = a[i] + b[i] is verified
Purpose: Confirms that correctness does not depend on evaluation order or count of side-effecting directive argument expressions.
Compilers:
•NVC 25.11 PASS
•GCC 15.2.0 PASS
•CCE 18.0.0 PASS
Notes:
When compiling with GCC, the C and C++ tests showed
warning: using ‘vector_length (32)’, ignoring runtime settingThis warning indicates that GCC'c OpenACC implementation may treat vector_length(...) as a compile-time or implementation-defined setting rather than honoring it dynamically at runtime.
Importantly:
•The test does not depend on the runtime scheduling behavior of vector_length
•The test only verifies numerical correctness of the kernel computation
•The program executes successfully and returns 0
So this warning does not indicate a failure of section 2.1 behavior and does not affect correctness.