[UR][CMake] Fix detection of preinstalled OpenCL#21531
Conversation
52d9143 to
0561ef0
Compare
Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
lukaszstolarczuk
left a comment
There was a problem hiding this comment.
besides that, LGTM
Signed-off-by: Nick Sarnie <nick.sarnie@intel.com>
|
heh, funny thing, we test opencl adapter on ubuntu22.04 image and it has perhaps a next step should be to bump docker images...? I'm not sure if we have any requirement on min. version of Ubuntu to use...? perhaps only one of two opencl jobs...? |
|
That's expected since we only support system installed with CMake 3.25 or later, so I can just bump the CMake version used in the Docker image, will do that in a separate PR now. |
|
Actually it seems the OpenCL install there is for the CPU runtime, not the headers/ICD loader, but I can bump the version anyway |
ohh, I see, that makes sense |
|
thanks for the review! |
There were a couple problems with the OpenCL detection.
System install detection didn't work because I had to add the
NO_CMAKE_PACKAGE_REGISTRYargument tofind_packageto prevent it finding theFetchContentcheckout on subsequent calls. This CMake module is called at least twice, one foropencl-aotand once for the UR OpenCL adapter.If we remove
NO_CMAKE_PACKAGE_REGISTRYto fix system install detection, then we hit a problem where if there is a system install, but it fails thecheck_cxx_source_compilescheck because it doesn't supportcl_khr_spirv_queries, we had no way to not use the system install it found, so we can't usefind_packageat all. Usefind_pathandfind_library, whcih is whatfind_package(OpenCL)does internally anyway. Those two functions have nice validator functions we can use that do exactly what we need, to determine if the found OpenCL install is suitable, and if not, don't use it. However, this function is only available with CMake 3.25 (released in 2022) or later, and we currently require3.20, but I think saying we don't support system installs with older CMake is reasonable, it still fetches and builds OpenCL from upstream fine.Also do some minor cleanup like making sure there is always a target named
OpenCLthat callers can rely on.Tested the following 3 cases manually:
a) No system OpenCL install
b) System OpenCL install that's too old
c) Working system OpenCL install
and all work as expected.
Closes: #21513