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

Disallow timing calls in leaf tasks #966

Open
manopapad opened this issue Jan 23, 2025 · 5 comments
Open

Disallow timing calls in leaf tasks #966

manopapad opened this issue Jan 23, 2025 · 5 comments
Assignees

Comments

@manopapad
Copy link
Contributor

Bug report due to @elliottslaughter

Timing calls ends up doing a Legion runtime call, that are presumably not allowed in leaf tasks. E.g. the following program will hang:

import cupy as np
from legate.core.task import task, InputArray, OutputArray
from legate.core import get_machine, TaskTarget, VariantCode
import cupynumeric as cpn
from legate.timing import time

@task(variants=(VariantCode.GPU,))
def foo_in_out(in_store: InputArray, out_store: OutputArray, start_time: int) -> None:
    in_store = np.asarray(in_store)
    out_store = np.asarray(out_store)
    out_store[:] = in_store[:]
    print((time() - start_time)/1e6)

with get_machine().only(TaskTarget.GPU):
    start_time = time()
    in_store = cpn.array([1, 2, 3])
    out_store = cpn.array([1, 2, 3])
    foo_in_out(in_store, out_store, int(start_time))
    print(out_store)

We should not allow timing calls (or most runtime calls for that mater) in leaf tasks.

@manopapad manopapad changed the title Disallow Disallow timing calls in leaf tasks Jan 23, 2025
@manopapad
Copy link
Contributor Author

Actually @lightsighter will do the right thing at the Legion level, i.e. emit a timing op if on a non-leaf task, and just do the timing eagerly if in a leaf task.

@manopapad manopapad assigned lightsighter and unassigned Jacobfaib Jan 23, 2025
@lightsighter
Copy link

@manopapad
Copy link
Contributor Author

Note to self: before we can close this, we also need to make sure the timing operation is launched using the appropriate context for the current task.

@lightsighter
Copy link

Yes, that is still required otherwise bad things could happen (will be checked for you in what is probably the next Legion release).

@lightsighter
Copy link

Merged.

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

3 participants