Skip to content

Add integral-constant-expression validation for collapse, tile, cache, and gang clauses.#119

Open
Ryanpadrone wants to merge 15 commits intoOpenACCUserGroup:masterfrom
Ryanpadrone:integralConstant
Open

Add integral-constant-expression validation for collapse, tile, cache, and gang clauses.#119
Ryanpadrone wants to merge 15 commits intoOpenACCUserGroup:masterfrom
Ryanpadrone:integralConstant

Conversation

@Ryanpadrone
Copy link
Copy Markdown

@Ryanpadrone Ryanpadrone commented Jan 28, 2026

Feature:

– This PR adds validation and verification tests for the OpenACC 3.4 clarification that introduces the term integral-constant-expression and aligns its meaning with the base languages (see §1.6).
– An integral constant expression is a compile-time constant integer expression as defined by the host language (C, C++, Fortran), and is required by the specification in several clauses and directives

What the tests validate:

The tests ensure that valid compile-time integer constants are accepted by compilers when used in positions where the OpenACC specification explicitly requires an integral constant expression, and that the associated constructs execute correctly at runtime.

Coverage includes the following spec locations:

  • Collapse clause (§2.9.1)
    Argument must be a positive, non-zero integral constant expression
  • Tile clause (§2.9.8)
    Each tile size must be a positive, non-zero integral-constant-expression (or *).
  • Cache directive (§2.10)
    Array element indices, lower bounds, and lengths may include integral-constant-expressions.
  • Gang clause – dim: argument (§2.9.2)
    The dim argument must be an integral-constant-expression evaluating to 1, 2, or 3.

Test design:

Each language file contains seven tests (T1-T6) that:

  • Use language appropriate forms of ICE
    •C: integer macros and enum constants
    • C++: constexpr values and (scoped) enums
    • Fortran: integer PARAMETER expressions
  • Place ICE values directly into spec-mandated positions
  • perform a runtime computation check (vector add / scale) to confirm the construct executes correctly, not just parse

Test mapping

  • T1: collapse clause (arithmetic ICE forms)
  • T2: tile clause (single tile ICE)
  • T3: tile clause (multi-dimensional ICE lists)
  • T4: cache directive (ICE used in element index)
  • T5: cache directive (ICE used in lower/length ranges)
  • T6: gang(dim: ICE)

Notes on cache behavior

cache is a performance hint and may be ignored by implementations. The tests primarily validate syntax acceptance of integral-constant-expressions in cache subscript/range forms. In all three language versions (C, C++, and Fortran), the cache directive is placed inside the actual parallel loop body to maintain consistent structure across implementations. The cached array section or element uses integral-constant-expressions exactly where permitted by §2.10.

Expected compiler behavior and results

•NVHPC 25.5: Passes T1-T6
•GCC 15.2.0: Passes T1-T5; fails T6 (parser rejects "dim:" keyword form)
•Cray 18.0.0: Passes T1-T5 (may emit cache warnings); fails T6 (parser rejects "dim:" keyword form)

Failures in T6 occur at directive parse time, before ICE semantic checking, and indicate incomplete support for the dim: keyword syntax—not an invalid test or misuse of ICE.

@ajarmusch ajarmusch added the v3.4 label Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants