OpenCL is currently broken in two ways on main branch

Thomas “illwieckz” Debesse dev at illwieckz.net
Tue Apr 19 08:05:31 UTC 2022


OpenCL is currently broken in two ways:

- Mesa doesn't build OpenCL code any more,
- Mesa itself cannot be built any more.

Those two breakages occurred on the last week and followed some changes
being merged in LLVM main branch. Those two issues can be addressed in
Mesa, while on the second one Mesa, I don't know if the issue is on Mesa
or on LLVM side.

On a side note:

- OpenCL amdgcn now produces garbage when compiled with -cl-fast-relaxed-math,
- OpenCL r600 compiled code does not run anymore.

They are likely to be LLVM issues.

Maybe it's also good to have a quick glance on OpenCL status in Mesa,
as Mesa OpenCL is still the only hope for OpenCL on AMD.

## Mesa doesn't build OpenCL code any more

LLVM commit 702d5de4 committed on 2022-04-11 broke OpenCL compilation:
https://github.com/llvm/llvm-project/commit/702d5de4380b1e1554e5b90863093c3a57f76f70

It is possible to build Mesa but OpenCL applications are not able to compile
OpenCL code any more.

The issue surfaced when the Clang build option CLANG_ENABLE_OPAQUE_POINTERS
was turned on by default.

Issue on Mesa side: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6342
Issue on LLVM side: https://github.com/llvm/llvm-project/issues/54970

Here is an example of workaround on Mesa side:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/6342#note_1344480

The workaround works by making Clover passes -no-opaque-pointers to Clang.

I did not make a merge request for such workaround because I have no idea
about what's happening, maybe there is a clean way to do it instead. Maybe
there was a dormant bug in Mesa that should be fixed instead, I don't know.

## Mesa itself cannot be built any more

LLVM commit 93471e65d committed on 2022-04-13 broke Mesa compilation:
https://github.com/llvm/llvm-project/commit/93471e65df48372ee59bd0c2f8ba58a254ba1ca5

It is not possible to build Mesa main branch against LLVM main branch any more,
this is because an LLVM function used by Clover was moved to another class
in LLVM: setLangDefaults was moved from CompilerInvocation to LangOptions
and the signature was modified.

Issue on Mesa side: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6333
Merge request for proposed fix on Mesa side: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16002

## OpenCL amdgcn now produces garbage when compiled with -cl-fast-relaxed-math

The root cause of the bug is probably living on LLVM side, it would be hard
to bisect because the version I know to be working is almost two years old,
the regression can have been introduced months or years ago.

Issue on Mesa side: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5671
Issue on LLVM side: https://github.com/llvm/llvm-project/issues/54947

## OpenCL r600 compiled code does not run any more

The root cause of the bug is probably living on LLVM side, it produces an
“ALU clause is too big” assertion, it worked before. Like the other issue,
I don't know when it started to fails, the regression can have been
introduced days or years ago.

Issue on LLVM side: https://github.com/llvm/llvm-project/issues/54942

## Mesa OpenCL is still the only hope for OpenCL on AMD

Mesa OpenCL is very precious and is still the only hope for the years to come,
as stated in the following article, state of OpenCL drivers on Linux for AMD
hardware is now worse than it was back in the days of fglrx, and even ROCm
doesn't look like a relevant option for the years to come as it only works
on an handful of lucky combination of very selective hardware that gets
phased out very quickly:

https://rebatir.fr/post/2022-01-25-OpenCL_on_Linux_state_of_AMD_drivers_is_now_worse_than_it_was_back_in_the_days_of_fglrx/

For most people, once the issues above are fixed, the only remaining thing
needed in Mesa OpenCL to forget about obsolete and now removed fglrx,
removed PAL and removed Orca, and not-usable ROCm is the lack of image
support:

https://gitlab.freedesktop.org/mesa/mesa/-/issues/130

Note: I can provide testing on TeraScale 1, 2, 3, GCN 1, 2, 3, 5 hardware
if needed. I know TeraScale 1 isn't supported in Mesa for OpenCL but some
later chips had OpenCL support provided by ATI/AMD at the time, so if needed
I can also provide testing on such hardware.

I cannot provide testing on GCN 4 neither RDNA hardware for now but I can
provide testing on a wide range of hardware of the other families.

-- 
Thomas “illwieckz” Debesse


More information about the mesa-dev mailing list