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

Feature Request: Doctrings for workunits #272

Closed
kennykos opened this issue Jul 2, 2024 · 1 comment
Closed

Feature Request: Doctrings for workunits #272

kennykos opened this issue Jul 2, 2024 · 1 comment

Comments

@kennykos
Copy link
Contributor

kennykos commented Jul 2, 2024

For development purposes, I think that it would be nice if PyKokkos workunits/functions/workloads/functors supported docstrings for documentation.

For example, when trying to document this hello world script with a docstring,

import pykokkos as pk

@pk.workunit
def hello(i: int):
    """CUDA Kernel to print hello world in parallel.

    Args:
        i (int): thread id
    """
    pk.printf("Hello, World! from i = %d\n", i)

def main():
    pk.set_default_space(pk.Cuda)
    pk.parallel_for(10, hello)

main()

PyKokkos throws the following error:

Error on line 5 : Only function calls are allowed as standalone statements
DEBUG AST:
Expr(
    value=Constant(value='CUDA Kernel to print hello world in parallel.\n\n    Args:\n        i (int): thread id\n    '))
    """CUDA Kernel to print hello world in parallel.
    ^^^
Translation of <ast.FunctionDef object at 0x14c44b774d90> hello failed

Without knowing much about the inner-workings of PyKokkos, I think the fix would revolve around having the parser ignore standalone strings that come a line after the function deceleration.

I can give the fix a shot if anyone wants to point me in the right direction (and, of course, if it is as easy as I think) :)

@NaderAlAwar
Copy link
Contributor

Fixed in #276. Closing this for now, let me know if run into any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants