-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Disable system OpenCL by default, pass the current cmake generator/command to build OpenCL #528
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
Merged
Merged
[SYCL] Disable system OpenCL by default, pass the current cmake generator/command to build OpenCL #528
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Couple notes.
There are dedicated CMake variables for library prefixes/suffixes:
https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables
CMAKE_ARGS accepts generator expressions. I believe it would be better way to set OPENCL_ICD_LOADER_REQUIRE_WDK that way.
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.
Valery, I suppose you mentioned the vars like CMAKE_STATIC_LIBRARY_SUFFIX.
This case is non-standard and those CMAKE vars will not work. CMAKE_STATIC_LIBRARY_SUFFIX does not work on Linux because it is lowered to ".a", while I need ".so".
CMAKE_SHARED_LIBRARY_SUFFIX does not work on Windows as it is lowered to ".dll", while I need ".lib".
Also, CMAKE_LINK_LIBRARY_SUFFIX does not work on Linux, it is simply empty there.
For some reasons using expr generator for OPENCL_ICD_LOADER_REQUIRE_WDK did not work for me. Also, in a separate e-mail thread you mentioned that you skip your requirement for using expr generator in this case.
Thus, this block of code remains the same. The only difference after your last review was the definition of OpenCL_VERSION_STRING. It was needed to avoid cmake errors when OpenCL_INCLUDE_DIR is not set AND it is not available in system.
Without that fix the expression:
"if( NOT OpenCL_INCLUDE_DIRS OR ${OpenCL_VERSION_STRING} VERSION_LESS 2.2)"
was lowered to this one with syntax error:
"if( NOT OpenCL_INCLUDE_DIRS OR VERSION_LESS 2.2)"
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.
I second @valerydmit here.
It looks like we are trying to link with OpenCL library differently depending on the platform.
IIRC, dynamic linking on Windows is slightly different from Linux, but it also should be handled by the cmake just fine. We just need communicate to cmake that "OpenCL is a library" and it shouldn't require low level manipulations with file extensions and compiler flags to link the library.
Uh oh!
There was an error while loading. Please reload this page.
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.
Here are some reasons why find_package(OpenCL) is needed when those 2 vars are set:
If I remove '(OpenCL_INCLUDE_DIR AND OpenCL_LIBRARY) OR ' then OpenCL is NOT FOUND
even if I manually set -DOpenCL_INCLUDE_DIR=$OPENCL_HEADERS -DOpenCL_LIBRARY=$OPENCL_LOADER
OpenCL_INCLUDE_DIR is missed. Will try to download OpenCL headers from github.com
OpenCL_LIBRARY is missed. Will try to download OpenCL ICD Loader from github.com
That happens because we set OpenCL_INCLUDE_DIR and then check OpenCL_INCLUDE_DIRS below (DIR vs DIRS). find_package(OpenCL) sets OpenCL_INCLUDE_DIRS.
find_package(OpenCL) initializes some other useful vars like OPENCL_FOUND, etc.
Regarding your concern "their values might be reset(!) by this function".
I tried that. It does NOT re-define what you explicitly defined. OpenCL_INCLUDE_DIR has the highest priority:
a) "-DOpenCL_INCLUDE_DIR=garbage -DOpenCL_LIBRARY=garbage" ==> OpenCL is FOUND, not even checked.
-- Looking for CL_VERSION_2_2
-- Looking for CL_VERSION_2_2 - not found
-- Looking for CL_VERSION_2_1
-- Looking for CL_VERSION_2_1 - not found
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - not found
-- Looking for CL_VERSION_1_2
-- Looking for CL_VERSION_1_2 - not found
-- Looking for CL_VERSION_1_1
-- Looking for CL_VERSION_1_1 - not found
-- Looking for CL_VERSION_1_0
-- Looking for CL_VERSION_1_0 - not found
-- Found OpenCL: D:/iusers//ws/gs_public/build_ninja/garbage
b) "-DBUILD_WITH_SYSTEM_OPENCL=ON -DOpenCL_INCLUDE_DIR=garbage -DOpenCL_LIBRARY=garbage" ==> SAME OUTPUT AS IN (a) above).
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.
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.
I used the name 'BUILD_WITH_SYSTEM_OPENCL' suggested by you. Should I change it to OpenCL_BUILD_WITH_SYSTEM_SDK ?
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.
If OpenCL_INCLUDE_DIR and OpenCL_LIBRARY are not set, then
a) if BUILD_WITH_SYSTEM_OPENCL unset, then nothing is found, and they are downloaded/built from github.
b) if BUILD_WITH_SYSTEM_OPENCL is set then SYSTEM SDK may be found. I have OpenCL headers 2.1 on my lab machine, it is found and tried to be used.
BTW, currently SYCL compiler cannot be built with 2.1 headers because we include both files cl_ext.h and cl_ext_intel.h and they define same structures in 2.1, but not in 2.2.
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.
No.
Sorry I wasn't clear enough. I was talking about OpenCL_INCLUDE_DIR/OpenCL_INCLUDE_DIRS and OpenCL_LIBRARY/DOpenCL_LIBRARIES.
Anyway. Let's fix more important issues first and refactor it later.