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

Consider an environment variable for exposing DirectX WARP as GPU or CPU device #58

Closed
BlohoJo opened this issue Feb 9, 2024 · 6 comments

Comments

@BlohoJo
Copy link

BlohoJo commented Feb 9, 2024

Hi!

I use MESA with OpenCLon12 / DirectX WARP.

I need it to expose DirectX WARP as a GPU device so that I can use it with some applications that only allow OpenCL GPU devices.

For some years, I was never able to get it to work... it just crashed. See here: pal1000/mesa-dist-win#88

It started working with MESA version 23.0.0. However, due to this posted issue, OpenCLon12 was changed to expose DirectX WARP as a CPU device. So it now works, but I still can't use it! :(

In the above issue, the developer implies that they will implement an environment variable so that the user can select how OpenCLon12 exposes DirectX WARP (CPU or GPU). But I can't find any info about if this environment variable even exists, or what it is and how to set it if it does exist.

If there's currently no way to select CPU or GPU for OpenCLon12/DirectX WARP, please consider implementing one.

(By the way, the current version of MESA - 24.0.0 - exposes WARP as an unknown device. I'm not sure if this is a problem with openclon12.dll or clon12compiler.dll. This means that it will not work with any application that expects to see an OpenCL CPU and/or an OpenCL GPU device type.)

@BlohoJo BlohoJo changed the title Please re-designate OpenCL as a GPU type, or give a user configuration option Consider an environment variable for exposing DirectX WARP as GPU or CPU device Feb 12, 2024
@jenatali
Copy link
Member

This looks like a LuxMark bug, but given that, I'll probably want to work around it.

The relevant code in LuxMark is https://github.com/LuxCoreRender/LuxCore/blob/a061ca97e1aa91de5da451baae940cd7f485cbf3/src/luxrays/devices/ocldevice.cpp#L53. They switch on the cl_device_type retrieved from clGetDeviceInfo for CL_DEVICE_TYPE, but the spec for CL says:

Please see the Device Types table for supported device types and device type combinations.

Emphasis on "combinations." Per the link in the spec:

Some devices may be more than one type. For example, a CL_DEVICE_TYPE_CPU device may also be a CL_DEVICE_TYPE_GPU device, or a CL_DEVICE_TYPE_ACCELERATOR device may also be some other, more descriptive device type. CL_DEVICE_TYPE_CUSTOM devices must not be combined with any other device types.

One device in the platform should be a CL_DEVICE_TYPE_DEFAULT device. The default device should also be a more specific device type, such as CL_DEVICE_TYPE_CPU or CL_DEVICE_TYPE_GPU.

The change that likely caused issues is e1e0cba, adding in CL_DEVICE_TYPE_DEFAULT into the first device in the list based on that spec language above.

FYI @bashbaug (just as someone who works on the CL spec and related tests) that it seems nothing is verifying this spec wording (which I guess makes sense since it only says "should") otherwise apps in the ecosystem wouldn't be taking that kind of dependency...

@jenatali
Copy link
Member

And yes, while I'm in this area I'll probably add an environment variable or something so that WARP can be reported as a GPU device again (FYI @MathiasMagnus)

@BlohoJo
Copy link
Author

BlohoJo commented Feb 15, 2024

Oh, thank you so much! 😆 😃

@bashbaug
Copy link

There's some background discussion describing why the current spec text is phrased the way that it is in this issue here: KhronosGroup/OpenCL-Docs#224

In short, there is a lot of code in the wild like that checks for specific CL_DEVICE_TYPE values, like that linked above, so we need to be careful not to mandate a behavior that will cause lots of shipping applications to break.

@jenatali
Copy link
Member

Thanks for that link, that's exactly what I was looking for. I'll chime in on that issue with my opinion.

@jenatali
Copy link
Member

jenatali commented Mar 4, 2024

Fixed by 989a95f (addressing the "unknown" device type) and 3486370 (adding an environment variable that can force WARP to enumerate as a GPU)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants