Add support for flexible device hierarchy model#169
Add support for flexible device hierarchy model#169wdamon-intel merged 4 commits intooneapi-src:masterfrom
Conversation
Resolves: oneapi-src#1 Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
|
@wdamon-intel , @MichalMrozek: please review |
wdamon-intel
left a comment
There was a problem hiding this comment.
LGTM, mostly, just a few minor comments to address.
scripts/core/PROG.rst
Outdated
|
|
||
| With a value of `0`, ${x}DeviceGet returns all the devices that do not have a root-device. Traversing the device hierarchy is possible by querying sub-devices with ${x}DeviceGetSubDevices and root-devices with ${x}DeviceGetRootDevice. Driver implementation may perform implicit optimizations to submissions and allocations done in the root-devices. | ||
|
|
||
| With a value of `1`, ${x}DeviceGet returns all the devices that do not have sub-devices. Traversing the device hierarchy is **not** possible, with ${x}DeviceGetSubDevices returning always a count of 0 device handles and and ${x}DeviceGetRootDevice returning nullptr. This mode allows Level Zero driver implementations to optimize execution and memory allocations by removing any overhead required to account for simultaneous use of root-devices and sub-devices in the same application. |
There was a problem hiding this comment.
[...] 0 device handles and and [...]
"andand"
scripts/core/PROG.rst
Outdated
|
|
||
| ${X}_FLAT_DEVICE_HIERARCHY allows users to select the device hierarchy model with which the underlying hardware is exposed and the types of devices returned with ${x}DeviceGet. | ||
|
|
||
| With a value of `0`, ${x}DeviceGet returns all the devices that do not have a root-device. Traversing the device hierarchy is possible by querying sub-devices with ${x}DeviceGetSubDevices and root-devices with ${x}DeviceGetRootDevice. Driver implementation may perform implicit optimizations to submissions and allocations done in the root-devices. |
There was a problem hiding this comment.
in mode 0 DeviceGetRootDevice is not allowed.
There was a problem hiding this comment.
You mean in mode 0, which is what we have currently, the application cannot query for the root device? could you elaborate on why would that be? this has been a request from some customers some times, to query for the parent device for a sub-device. From point of view of implementation, this doesnt change too much, as the Level Zero Driver implementation already has that info, it would be just a matter of returning it.
There was a problem hiding this comment.
The API was only meant for mode 2, when you start to flatten the hierarchy.
If hierarchy is not flattened (as in mode 0), then getroot is not supported.
That's the whole difference between mode 2 and other modes, it allows this new API.
There was a problem hiding this comment.
@MichalMrozek : thanks. yes, the API was originally meant for mode 2, but there's no functional or performance reason to not have it available in mode 0, would that be correct? By having it in mode 0 as well, we allow users to have more flexibility and broader set of APIs to use.
There was a problem hiding this comment.
let's say you are in mode 0
app did ZE_AFFINITY_MASK=0.0
app calls getRoot on such device, what is returned?
There was a problem hiding this comment.
@MichalMrozek it is return nullptr, but if you are in mode 0, and use ZE_AFFINITY_MASK=0, then you can call getRootDevice on any handle obtained with getSubDevices and get the parent device.
It is the same for getSubDevices. With MASK=0, getSubDevices for a root device returns a list of sub-devices, and with MASK=0.0 getSubDevices returns a count of 0. Spec doesnt forbid the use of getSubDevices with MASK=0.0, it just returns the appropriate value depending on the situation.
There was a problem hiding this comment.
but in mode 1 , we will return all sub devices as root device and getRoot will return nullptr?
There was a problem hiding this comment.
@MichalMrozek Correct. in mode 1, getRootDevice returns nullptr, and also getSubDevices will return count of 0.
scripts/core/PROG.rst
Outdated
| same system with two devices and four sub-devices. | ||
|
|
||
| - `0, 1, 2, 4`: all sub-devices are reported by ${x}DeviceGet (same as default) | ||
| - `0`: only sub-device 0 in the first device is reported |
There was a problem hiding this comment.
there are no sub devices when FLAT_DEVICE_HIERACHY is "1"
There was a problem hiding this comment.
thanks @MichalMrozek . I have expanded this section to make it clearer and added some tables showing what is being exposed. It would look something like this when rendered:
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
|
@MichalMrozek : do you have further comments or think that PR is good to go? |
|
The initial plan was that new api getRoot is only available in mode 2. |
@MichalMrozek : currently, we allow for sub-devices to share the resources from the root device, that's correct, and you are correct, the same cannot be assumed when you have created a resource in a sub-device, and then getRootDevice is called. So we could add something like this to getRootDevice: "To allow the device handle returned by getRootDevice access the resources created by the sub-device handle, these resources need to be created with a context containing explicitly both handles.". |
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
Added clarification. |

Resolves: #1