Skip to content

Clarification on command list semantics #323

@manuelmohr

Description

@manuelmohr

The current spec provides the following flags when creating a command list:

  • ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING: commands in the list may be reordered within certain limits by the driver before executing.
  • ZE_COMMAND_LIST_FLAG_IN_ORDER: commands in the list must be executed in the given order.

Interestingly, while the spec points out that it is not allowed to set both flags on the same list, it does allow to set neither of the flags. I don't think a command list with none of the two flags set is explicitly named anywhere in the spec, so I'll just call it a "default command list" here.

Let's say I'm working with a device that has one compute engine and one copy engine, exposed via one command queue group of type COMPUTE | COPY. So internally, this device is able to execute a copy command in parallel to a compute command.

Let's assume I have the following code (where E is an event):

cmdList.appendMemoryCopy(..., signal=None, wait=[])    // Command A
cmdList.appendLaunchKernel(..., signal=E, wait=[])     // Command B
cmdList.appendLaunchKernel(..., signal=None, wait=[E]) // Command C
cmdList.appendMemoryCopy(..., signal=None, wait=[])    // Command D
cmdQueue.executeCommandLists([cmdList])

Are the following statements true?

  • If cmdList was created with ZE_COMMAND_LIST_FLAG_IN_ORDER:
    • The only allowed execution order is A, B, C, D.
    • Each command must finish execution before the next one starts execution.
  • If cmdList was created with ZE_COMMAND_LIST_FLAG_RELAXED_ORDERING:
    • The only restriction is that B must finish before C starts execution, all other orderings are legal.
    • Legal execution: D, A, B, C.
    • Legal execution: D, B, C, A.
    • Some commands may also execute in parallel but there is no guarantee that they do, e.g., A may execute in parallel to B. And if B takes some time but A is quick is quick to finish, both A and D may execute in parallel to B.
  • If cmdList was created with neither of the flags (a "default command list"):
    • The order in which commands start execution is always A, B, C, D, but some commands may execute in parallel.
    • Legal execution: A executes in parallel to B, then C executes once B finishes, then D executes in parallel to C.
    • Illegal execution: D, A, B, C
    • Illegal execution: B, C, D, A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions