Skip to content

Add procedure-boundary analysis tests (C++ lambdas, member functions, Fortran internal procedures)#123

Open
Ryanpadrone wants to merge 1 commit intoOpenACCUserGroup:masterfrom
Ryanpadrone:internalProcedure
Open

Add procedure-boundary analysis tests (C++ lambdas, member functions, Fortran internal procedures)#123
Ryanpadrone wants to merge 1 commit intoOpenACCUserGroup:masterfrom
Ryanpadrone:internalProcedure

Conversation

@Ryanpadrone
Copy link
Copy Markdown

Feature Under Test

Sections 2.6.2 (Implicit Data Attributes), 2.9 (Loop Construct), and 2.15.1 (Routine Directive)

This PR adds runtime and compile-time conformance tests targeting the OpenACC 3.4 clarification regarding:
• Implicit data attribute analysis
• Parallelism (loop directive) analysis
across boundaries of procedures that appear within other procedures, including:
• C++ lambdas
• C++ class member functions
• Fortran internal (contained) procedures
OpenACC 3.4 clarified how implementations must analyze implicit data attributes and loop association when procedure calls occur within compute regions, including cases where those procedures are nested (e.g., C++ lambdas and Fortran contained subprograms).

Tests Added

C++ (acc_nested_internal_procedure.cpp):
T1 – Lambda Called Inside parallel loop
• Executes a #pragma acc parallel loop
• Calls a C++ lambda from inside the loop
• Lambda references device arrays and a captured scalar
Tests:
• Proper implicit data handling (default(present))
• Correct scalar capture behavior
• Generation of device-callable code for lambdas

T2 – Class Member Function Inside parallel loop
• Calls w.work(i) from inside a parallel loop
• Object contains device pointers and a scalar member
Tests:
• Correct firstprivate transfer of objects
• Proper handling of pointer members on device
• Member function device code generation

T3 – #pragma acc loop Inside Lambda
• Enters a parallel region
• Calls a lambda containing #pragma acc loop
Tests:
• Correct association of loop directives across procedure boundaries
• Proper handling of orphaned loop constructs
• Parallelism analysis inside nested procedures

Fortran (acc_nested_internal_procedure.F90):
T1 – Internal Procedure Called From parallel loop
• Calls a contained subroutine inside a parallel loop
• Subroutine accesses outer-scope variables (host association)
Tests:
• Internal procedure device-callability
• Host-associated variable analysis
• Implicit data attribute preservation across boundaries

T2 – !$acc loop Inside Internal Procedure
• Enters a parallel region
• Calls an internal subroutine containing !$acc loop
Tests:
• Loop directive association across procedure boundaries
• Parallelism context preservation in internal procedures

Compiler Results

NVHPC 25.11 (nvc++ / nvfortran)
•C++
T1: ✅ Passed
T2: ❌Executable returned non-zero exit code (indicating test failure)
T3: ❌ Executable returned non-zero exit code (indicating test failure)

•Fortran
❌ Compile-time error (S-0155): acc routine cannot be used for contained subprograms that refer to host subprogram data
--Internal procedures referencing outer variables are rejected.

GCC 15.2.0(g++ / gfortran with -fopenacc)
•C++
T1: ✅ Passed
T2: ✅ Passed
T3: ❌ Compile-time error: OpenACC loop directive must be associated with an OpenACC compute region: GCC does not associate the loop inside the lambda with the surrounding parallel region.

•Fortran
-Compilation succeeded
–Runtime execution encountered GPU initialization errors in test environment (cuCtxCreate failure), likely unrelated to procedure-boundary analysis.

Cray 18.0.0
•Fortran
❌ Internal compiler error: found dereference of host pointer on accelerator
Occurred when lowering contained subprogram accessing outer-scope data.

Summary of Observed Behavior

• Basic lambda boundary handling (C++ T1) is implemented in NVHPC and GCC.
• Member-function boundary handling (C++ T2) exposes runtime issues under NVHPC.
• Loop directives inside nested lambdas (C++ T3) are rejected by GCC and fail under NVHPC.
• Fortran internal procedures referencing host-associated variables are rejected (NVFORTRAN) or cause internal compiler errors (Cray).
• These results demonstrate inconsistent support across compilers for the clarified procedure-boundary semantics introduced in OpenACC 3.4.

@ajarmusch ajarmusch changed the title Add OpenACC 3.4 procedure-boundary analysis tests (C++ lambdas, member functions, Fortran internal procedures) Add procedure-boundary analysis tests (C++ lambdas, member functions, Fortran internal procedures) Feb 26, 2026
@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