Skip to content

[L0 V2] USM advice flags translation is incorrect #19146

Open
@Bensuo

Description

@Bensuo

It appears as if the L0 V2 adapter is not correctly translating ur_usm_advice_flags_t to ze_memory_advice_t, as a modified example of this code from ur_command_list_manager::appendUSMAdvise()

  advice = UR_USM_ADVICE_FLAG_SET_READ_MOSTLY;
  auto zeAdvice = ur_cast<ze_memory_advice_t>(advice);

This cast results in a zeAdvice value of ZE_MEMORY_ADVICE_SET_PREFERRED_LOCATION because the UR type is defined as bitfield values and the ZE type is just an enum with incremental values. There are also more UR values for memory advice than in L0, so this straight cast can result in invalid values for options which have no mapping to L0.

The V1 adapter does not have this problem because it handles and translates the bitfield flags specifically:

if (Advice & UR_USM_ADVICE_FLAG_SET_READ_MOSTLY)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions