Skip to content

[Spec] urUSMFree is non conformant for CUDA, HIP adapters #2782

Open

Description

@hdelan

The description of urUSMFree notes:

Note that implementations are required to wait for previously enqueued commands that may be accessing pMem to finish before freeing the memory.

The CUDA and HIP adapters don't do any kind of dependency analysis to make sure that previously enqueued commands are complete before the native free is called. The OpenCL adapter seems to be the only adapter that gives blocking behaviour by using clMemBlockingFreeINTEL.

I suggest the spec is updated to not require urUSMFree to wait on previously enqueued commands to finish, and the OpenCL adapter can therefore use a simple clMemFreeINTEL, or that the CUDA and HIP adapters are updated to do some dependency analysis.

Ping @kbenzie @npmiller 😄

Activity

  1. pbalcer commented on Jun 16, 2025

    @pbalcer
    Contributor

    CUDA does blocking free for normal (non-async) allocations. @igchor verified that experimentally.

    The OpenCL adapter seems to be the only adapter that gives blocking behaviour by using clMemBlockingFreeINTEL.

    The L0 adapter does as well, it's implemented in the driver.

  2. hdelan commented on Jun 17, 2025

    @hdelan
    ContributorAuthor

    The wording in the CUDA driver API states:

    this API may perform implicit synchronization.

    Is it valid to upgrade may to will when using this to implement the UR specification?

  3. pbalcer commented on Jun 17, 2025

    @pbalcer
    Contributor

    Is it valid to upgrade may to will when using this to implement the UR specification?

    Good point. In that case we should probably change UR docs to something like:

    Note that implementations may wait for previously enqueued commands accessing pMem to finish before freeing the memory.

  4. hdelan commented on Jun 17, 2025

    @hdelan
    ContributorAuthor

    I'm happy with that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    specificationChanges or additions to the specification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions