Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACC] Handle !$acc declare #8

Open
4 of 14 tasks
domcharrier opened this issue May 4, 2021 · 1 comment
Open
4 of 14 tasks

[ACC] Handle !$acc declare #8

domcharrier opened this issue May 4, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@domcharrier
Copy link
Collaborator

domcharrier commented May 4, 2021

!$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:

    • Track function/subroutine begin and declarations in scanner tree & indexer
    • 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

    • Track module and declarations in scanner tree & indexer
    • 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
      • Emit unstructured enter data routine call or equivalent shortcut where appropriate

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.
@sael9740
Copy link

sael9740 commented May 4, 2021

FYI @domcharrier - We use !$acc declare very frequently in our code.

@domcharrier domcharrier self-assigned this May 6, 2021
@domcharrier domcharrier changed the title [ACC][indexer] Handle !$acc declare [ACC] Handle !$acc declare May 6, 2021
@domcharrier domcharrier added the enhancement New feature or request label May 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants