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

[L0] UR_PROGRAM_INFO_DEVICES is unimplementable for urProgramCreateWithNativeHandle #1384

Closed
pbalcer opened this issue Feb 26, 2024 · 8 comments · Fixed by #1393
Closed

[L0] UR_PROGRAM_INFO_DEVICES is unimplementable for urProgramCreateWithNativeHandle #1384

pbalcer opened this issue Feb 26, 2024 · 8 comments · Fixed by #1393
Labels
level-zero L0 adapter specific issues specification Changes or additions to the specification

Comments

@pbalcer
Copy link
Contributor

pbalcer commented Feb 26, 2024

enumerator UR_PROGRAM_INFO_DEVICES
[ur_device_handle_t[]] Return list of devices associated with Program.

This is currently unimplementable for programs that are created using urProgramCreateWithNativeHandle because there doesn't appear to be a way to retrieve a list of devices from L0 for a module (see L0 docs) nor does this function take a list of devices we could just store.

As far as I can tell, we don't even have device information in SYCL. Instead, SYCL relies on exactly UR_PROGRAM_INFO_DEVICES to populate its list of devices in the program_impl class.

I don't think there are any user-visible issues, performance or functional, related to this in SYCL right now, but we might want to consider returning 0 devices or some error status for this case.

@pbalcer pbalcer added the level-zero L0 adapter specific issues label Feb 26, 2024
@kbenzie
Copy link
Contributor

kbenzie commented Feb 26, 2024

urProgramCreateWithNativeHandle takes a ur_context_handle_t which could be used to populate the device list.

@kbenzie
Copy link
Contributor

kbenzie commented Feb 26, 2024

If that's not the desired set of devices, then we'd likely need to require the user to provide the device list when calling urProgramCreateWithNativeHandle.

@pbalcer
Copy link
Contributor Author

pbalcer commented Feb 26, 2024

But can't a module be built for a subset of devices in a context? @nrspruit can you chime in?

@pbalcer
Copy link
Contributor Author

pbalcer commented Feb 26, 2024

If that's not the desired set of devices, then we'd likely need to require the user to provide the device list when calling urProgramCreateWithNativeHandle.

I think that would require the SYCL API to change.

@kbenzie
Copy link
Contributor

kbenzie commented Feb 26, 2024

But can't a module be built for a subset of devices in a context?

It can, that's different to the list of devices associated with the program though. The list of associated devices is all the devices the program can be built for.

@pbalcer
Copy link
Contributor Author

pbalcer commented Feb 26, 2024

But can't a module be built for a subset of devices in a context?

It can, that's different to the list of devices associated with the program though. The list of associated devices is all the devices the program can be built for.

Gotcha, I was misled by this comment "return true number of devices this program exists for." in the current L0 implementation. So, generally, is UR_PROGRAM_INFO_DEVICES just a shorthand for UR_PROGRAM_INFO_CONTEXT -> UR_CONTEXT_INFO_DEVICES ?

We found this with @nrspruit in a real application when SYCL was hitting this assert: https://github.com/intel/llvm/blob/sycl/sycl/source/detail/program_impl.cpp#L164

The problem ended up being that MContext->getPlatformImpl()->get_devices(); didn't return the correct devices, but this code seems to suggest that there might be some difference between the set of devices in the platform, the devices in the context (which makes sense), and finally the devices associated with the program. Otherwise, why not just use MContext->get_devices() and skip the whole remove_if ?

@pbalcer
Copy link
Contributor Author

pbalcer commented Feb 26, 2024

CL_PROGRAM_DEVICES

cl_device_id[]

Return the list of devices associated with the program object. This can be the devices associated with context on which the program object has been created or can be a subset of devices that are specified when a program object is created using clCreateProgramWithBinary.

from https://registry.khronos.org/OpenCL/sdk/3.0/docs/man/html/clGetProgramInfo.html

OpenCL has better docs than UR :-)

Based on this, I believe UR_PROGRAM_INFO_DEVICES should return all devices in the context for urProgramCreateWithNativeHandle.

@kbenzie kbenzie added the specification Changes or additions to the specification label Feb 28, 2024
@kbenzie
Copy link
Contributor

kbenzie commented Feb 28, 2024

We will clarify the UR spec to align with the OpenCL spec on this.

kbenzie added a commit to kbenzie/unified-runtime that referenced this issue Feb 28, 2024
Fixes oneapi-src#1384 by clarifying what the *list of devices associated with a
program* means when the program is created in various ways.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level-zero L0 adapter specific issues specification Changes or additions to the specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants