-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixed parser of OpenCL 3.0 for NVIDIA GPU #2001
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate on the reasoning behind this PR?
Adding 3.0 to the list of OpenCL version makes sense. We are still looking for your comments on the rationale for remaining changes. |
@vpirogov @densamoilov Because this code successfully detect version of OpenCL library, but this one with CMAKE_CHECK_SYMBOLS cannot, even with defined variables to include dirs and link libraries: ...
function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
include(CMakePushCheckState)
set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
set(CMAKE_REQUIRED_INCLUDES ${OpenCL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OpenCL_LIBRARY})
CMAKE_PUSH_CHECK_STATE()
foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
if(APPLE)
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/Headers/cl.h"
OPENCL_VERSION_${VERSION})
else()
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/CL/cl.h"
OPENCL_VERSION_${VERSION})
endif()
message(STATUS "OPENCL_VERSION_${VERSION} = ${OPENCL_VERSION_${VERSION}}")
if(OPENCL_VERSION_${VERSION})
string(REPLACE "_" "." VERSION "${VERSION}")
set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
list(GET version_components 0 major_version)
list(GET version_components 1 minor_version)
set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
break()
endif()
endforeach()
CMAKE_POP_CHECK_STATE()
endfunction()
... For |
CL_VERSION_${VERSION} | ||
"${OpenCL_INCLUDE_DIR}/Headers/cl.h" | ||
OPENCL_VERSION_${VERSION}) | ||
foreach(VERSION "3_0" "2_2" "2_1" "2_0" "1_2" "1_1" "1_0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(random place)
There are a few things that look suspicious to me:
- We didn't implement FindOpenCL.cmake module, we've taken it from CMake (see here) and it still uses
CHECK_SYMBOL_EXISTS
and the community seems to be fine with it - The version macros are standardized by the OpenCL specification so if the macros are missing then it likely means that there is something wrong with the OpenCL implementation you use
- It should be fine to check
cl.h
header as it includescl_version.h
header andCHECK_SYMBOL_EXISTS
does perform a preprocessing
Given all this, I think the issue you encounter is somewhere on your end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@densamoilov Here is my OpenCL files for NVIDIA GPU:
cl_files.zip
It looks fine for me
Considering the discussion the best way forward is updating FindOpenCL.cmake from upstream. |
@densamoilov @vpirogov The CMake version says that it supports (Detection of OpenCL 2.1 and 2.2), also I've found that already someone implemented the similar version of FindOpenCL by trying to compile example project |
@redradist, if FindOpenCL.cmake from upstream CMake works in your scenario please update oneDNN copy accordingly. Be mindful of SYCL related changes that are local to oneDNN copy though. |
@vpirogov |
Is this conclusion based on the comment in the file or actual testing? I see the comment comment that says 'Detection of OpenCL 2.1 and 2.2.', however commit history for the file includes patch indicating 3.0 support: Kitware/CMake@587d194. We would like to avoid creating and maintaining completely new FindOpenCL.cmake. |
It is based on actual testing. You could verify it by yourself, just install OpenCL driver for NVIDIA GPU on Ubuntu and you'll see what the problem. |
a8904c7
to
b048e70
Compare
b048e70
to
27f99d5
Compare
@vpirogov One additional comment, previously this |
Could you please indicate which NVIDIA OpenCL driver package you are testing with? I'm running Ubuntu 22.04 with the latest NVIDIA driver, but FindOpenCL.cmake from this PR fails:
Environment details:
FindOpenCL.cmake from upstream works fine in this environment. |
I'm using the following OpenCL packages: $ apt list --installed | grep opencl
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
ocl-icd-libopencl1/jammy,now 2.2.14-3 amd64 [installed,automatic]
ocl-icd-libopencl1/jammy,now 2.2.14-3 i386 [installed,automatic]
ocl-icd-opencl-dev/jammy,now 2.2.14-3 amd64 [installed]
opencl-c-headers/jammy,jammy,now 3.0~2022.01.04-1 all [installed,automatic]
opencl-clhpp-headers/jammy,jammy,now 3.0~2.0.15-1ubuntu1 all [installed,automatic]
opencl-headers/jammy,jammy,now 3.0~2022.01.04-1 all [installed] It is very strange that your version failed to compile ... I use CUDA 11.8 and there are not packages like |
This is Kronos standard OpenCL loader and headers. It's vendor neutral and works perfectly fine with current FindOpenCL.cmake as tested on clean Ubuntu 22.04 image. This PR fails though:
Looks like the problem you are trying to address is somewhere else. |
No description provided.