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

end pragma with curly braces #300

Closed
ecossevin opened this issue Apr 25, 2024 · 3 comments
Closed

end pragma with curly braces #300

ecossevin opened this issue Apr 25, 2024 · 3 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@ecossevin
Copy link

ecossevin commented Apr 25, 2024

  1. ACDC PARALLEL TARGET [...] works but not ACDC PARALLEL,TARGET [...] (see fcode2 vs fcode3)
    2)loki doesn't recognize curly braces to define pragma region (see fcode2 vs fcode4)
from loki import * 

fcode1 = """
    SUBROUTINE TEST

    !$loki parallel TARGET=OpenMP/OpenMPSingleColumn/OpenACCSingleColumn,NAME=CPPHINP 
    PRINT *, "loki"
    !$loki end parallel

    END SUBROUTINE"""


routine = Sourcefile.from_source(fcode1)["TEST"]
with pragma_regions_attached(routine):
    for region in FindNodes(PragmaRegion).visit(routine.body):
        print(f"{region=}")
        print("region = ", fgen(region.body))
        assert fgen(region.body) == 'PRINT *, "loki"'

fcode2 = """
    SUBROUTINE TEST

    !$ACDC PARALLEL TARGET=OpenMP/OpenMPSingleColumn/OpenACCSingleColumn,NAME=CPPHINP 
    PRINT *, "ACDC_endparallel"
    !$ACDC END PARALLEL


    END SUBROUTINE"""

routine = Sourcefile.from_source(fcode2)["TEST"]
with pragma_regions_attached(routine):
    for region in FindNodes(PragmaRegion).visit(routine.body):
        print(f"{region=}")
        print("region = ", fgen(region.body))
        assert fgen(region.body) == 'PRINT *, "ACDC_endparallel"'

fcode3 = """
    SUBROUTINE TEST

    !$ACDC PARALLEL,TARGET=OpenMP/OpenMPSingleColumn/OpenACCSingleColumn,NAME=CPPHINP 
    PRINT *, "ACDC_coma"
    !$ACDC END PARALLEL


    END SUBROUTINE"""
routine = Sourcefile.from_source(fcode3)["TEST"]
with pragma_regions_attached(routine):
    for region in FindNodes(PragmaRegion).visit(routine.body):
        print(f"{region=}")
        print("region = ", fgen(region.body))
        assert fgen(region.body) == 'PRINT *, "ACDC_coma"'

fcode4 = """
    SUBROUTINE TEST

    !$ACDC PARALLEL TARGET=OpenMP/OpenMPSingleColumn/OpenACCSingleColumn,NAME=CPPHINP {
    PRINT *, "ACDC_curly_brace"
    !$ACDC }


    END SUBROUTINE"""
routine = Sourcefile.from_source(fcode4)["TEST"]
with pragma_regions_attached(routine):
    for region in FindNodes(PragmaRegion).visit(routine.body):
        print(f"{region=}")
        print("region = ", fgen(region.body))
        assert fgen(region.body) == 'PRINT *, "ACDC_curly_brace"'
@mlange05 mlange05 self-assigned this Apr 25, 2024
@ecossevin
Copy link
Author

Hi,
Can someone please fix this ?
Thanks in advance for your help.

@mlange05
Copy link
Collaborator

Hi @ecossevin , apologies for the delay. I started to look into this, and then realised where the hidden complexities come from, and had to drop it due to time constraints. The basic problem with this notation is that our PragmaRegion matching is based on explicit keyword matching between start and end-pragma, so that we can support nesting different pragma types.
For example, we can support

!$loki foo
...
!$loki bar
...
!$loki end bar
!$loki end foo

The particular matching code is here:
https://github.com/ecmwf-ifs/loki/blob/main/loki/ir/pragma_utils.py#L467

Unfortunately, re-writing the logic itself to match by order, rather than keyword is tedious. We, of course, accept PRs if you manage to keep this backward compatible yourself. Is there any specific reason why this non-standard pragma notation is required over more standard (eg. similar to OpenACC/OpenMP) notation based on 'end' keywords and spaces over commas?

@ecossevin
Copy link
Author

Hi,

Thanks for your answer.

Anyway, I don't need this to work, I have a work around.

There isn't any fondamental reason for that, but we want to keep it like that for the moment.

@mlange05 mlange05 added the wontfix This will not be worked on label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants