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

Disable whitespace disrupting CUDA chevrons #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Feb 8, 2024

  1. Disable whitespace disrupting CUDA chevrons

    Previously, fprettify did not understand CUDA fortran's triple-chevron syntax
    for calling kernel functions, e.g.
    ```fortran
    call example_kernel<<<1, 1>>>(args)
    ```
    As a result, each symbol in the chevrons `<<<` would have whitespace added, resulting
    in the incorrect syntax:
    ```fortran
    call example_kernel <  <  < 1, 1 >  >  > (args)
    ```
    
    This problem only occurs when adding whitespace around relational operators
    is enabled.
    
    This commit adds an escape hatch to the function that handles whitespace
    around operators `add_whitespace_context` which disables the whitespace
    handling for any line that matches the REGEX "<<<.*>>>":
    
    ```python
    CUDA_CHEVRONS_RE = re.compile(r"<<<.*>>>", RE_FLAGS)
    
    ...
    
    if not ( ... or CUDA_CHEVRONS_RE.search(line) ):
    ```
    
    This change should not break any Fortran syntax, however any relational
    operator that appears in a line that *also* features a triple-chevron
    will not be formatted, e.g.
    
    ```fortran
    call example_kernel<<<1, 1>>>(3< 4, var1 ==var2)
    ```
    JamieJQuinn committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    7b5cc21 View commit details
    Browse the repository at this point in the history