gpufort
gpufort copied to clipboard
[ACC] Handle !$acc declare
!$acc declare
is not handled yet.
-
"A declare directive is used in the declaration section of a Fortran subroutine, function, or module."
-
"In a Fortran module declaration section, only create, copyin, device_resident, and 2084 link clauses are allowed."
For more details on the directive, see "2.13. Declare Directive" in the specification
Implementation approach:
-
[ ] Host functions & subroutines:
- [x] Track function/subroutine begin and declarations in scanner tree & indexer
- [x] Consider
!$acc declare
in indexer - [ ] Track return statements in scanner tree as child node of function/procedure (begin)
- [ ] Track function/subroutine end in scanner tree as child node of function/procedure (begin)
- [ ] Emit unstructured enter data routine call or equivalent shortcut after declaration section of function/subroutine
- [ ] Emit unstructured exit data routine call or equivalent shortcut before function/subroutine end or return statement
-
[ ] Modules / Program
- [x] Track module and declarations in scanner tree & indexer
- [x] Consider
!$acc declare
in indexer - [ ] Assumed-size arrays * [x] Track allocate statements in in scanner tree * [ ] Emit unstructured enter data routine call or equivalent shortcut after allocate
- [ ] Explicit-size arrays
- [ ] ??? - not totally sure where to put the allocation
- if no save keyword:
- body of function/subroutine/program that uses the module
- else if save keyword and not already present in global scope (scope 0):
- body of function/subroutine/program that uses the module
- if no save keyword:
- [ ] Emit unstructured enter data routine call or equivalent shortcut where appropriate
- [ ] ??? - not totally sure where to put the allocation
Accelerator routines use "acc-declared" variables
Some thoughts:
- Device routines can use variables that are mapped to the device via
acc declare
statements. - When we generate HIP code, we need to pass the respective device pointers as kernel parameters.
- Hence, we would need to add a use statement with the respective module to the caller's (assuming loopnest) parent so that it is available in this scope. In case of gang, worker, vector accelerator routines, this must be done recursively.
FYI @domcharrier - We use !$acc declare
very frequently in our code.