Add procedure-boundary analysis tests (C++ lambdas, member functions, Fortran internal procedures)#123
Open
Ryanpadrone wants to merge 1 commit intoOpenACCUserGroup:masterfrom
Open
Conversation
…r functions, Fortran internal procedures)
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
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 acceleratorOccurred 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.