-
Notifications
You must be signed in to change notification settings - Fork 797
[SYCL][UR] Improve support for preinstalled OpenCL deps #19649
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,4 @@ endif() | |
target_link_libraries(${OPENCL_AOT_PROJECT_NAME} | ||
PRIVATE | ||
OpenCL-Headers | ||
OpenCL-ICD) | ||
${OpenCL_LIBRARY}) |
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Finds or fetches OpenCL Headers and the ICD loader. | ||
if(TARGET OpenCL-Headers) | ||
# If we already ran this module (so the OpenCL-Headers target exists), | ||
# everything is already set up, nothing to do. | ||
return() | ||
endif() | ||
|
||
# Repo URLs | ||
|
||
set(OCL_HEADERS_REPO | ||
"https://github.com/KhronosGroup/OpenCL-Headers.git") | ||
set(OCL_LOADER_REPO | ||
"https://github.com/KhronosGroup/OpenCL-ICD-Loader.git") | ||
|
||
# Repo tags/hashes | ||
|
||
set(OCL_HEADERS_TAG 6eabe90aa7b6cff9c67800a2fe25a0cd88d8b749) | ||
set(OCL_LOADER_TAG ddf6c70230a79cdb8fcccfd3c775b09e6820f42e) | ||
|
||
find_package(OpenCL 3.0 QUIET) | ||
if(OpenCL_FOUND) | ||
# The OpenCL-Headers CMake files don't provide granular info | ||
# on what is and isn't supposed, just the overall OpenCL version. | ||
# The current tag we are using happens to define an extension, so just check | ||
# if that extension exists to make sure the system install is not | ||
# too old. | ||
set(OPENCL_TEST_PROGRAM "#define CL_TARGET_OPENCL_VERSION 300 | ||
#include <CL/cl_ext.h> | ||
#ifndef cl_khr_spirv_queries | ||
#error Unsupported header version | ||
#endif | ||
int main(int, char*[]) { return 0; }" | ||
) | ||
include(CheckCXXSourceCompiles) | ||
set(CMAKE_REQUIRED_INCLUDES ${OpenCL_INCLUDE_DIRS}) | ||
set(CMAKE_REQUIRED_LIBRARIES ${OPENCL_Library}) | ||
check_cxx_source_compiles("${OPENCL_TEST_PROGRAM}" OPENCL_HEADERS_VERSION_SUPPORTED) | ||
if(NOT OPENCL_HEADERS_VERSION_SUPPORTED) | ||
message(WARNING "Preinstalled OpenCL-Headers are not supported, " | ||
"use commit ${OCL_HEADERS_TAG} or later. Will fetch OpenCL.") | ||
set(OpenCL_FOUND FALSE CACHE BOOL "" FORCE) | ||
endif() | ||
endif() | ||
|
||
# Ideally we could use the FIND_PACKAGE_ARGS argument to FetchContent_Declare to avoid | ||
# the conditonals, but that was added in CMake 3.24 and the current minimum we require is | ||
# 3.20. | ||
|
||
# OpenCL Headers | ||
if(NOT OpenCL_FOUND) | ||
FetchContent_GetProperties(ocl-headers) | ||
|
||
if(NOT ocl-headers_POPULATED) | ||
message(STATUS "Will fetch OpenCL headers from ${OCL_HEADERS_REPO}") | ||
FetchContent_Declare(ocl-headers | ||
GIT_REPOSITORY ${OCL_HEADERS_REPO} | ||
GIT_TAG ${OCL_HEADERS_TAG} | ||
) | ||
FetchContent_MakeAvailable(ocl-headers) | ||
endif() | ||
set(OpenCL_INCLUDE_DIR ${ocl-headers_SOURCE_DIR} CACHE PATH "" FORCE) | ||
else() | ||
message(STATUS "Using OpenCL headers at ${OpenCL_INCLUDE_DIR}") | ||
endif() | ||
|
||
# OpenCL Library (ICD Loader) | ||
|
||
set(BUILD_SHARED_LIBS ON) | ||
|
||
if(NOT OpenCL_FOUND) | ||
|
||
FetchContent_GetProperties(ocl-icd) | ||
if(NOT ocl-icd_POPULATED) | ||
message(STATUS "Will fetch OpenCL ICD Loader from ${OCL_LOADER_REPO}") | ||
FetchContent_Declare(ocl-icd | ||
GIT_REPOSITORY ${OCL_LOADER_REPO} | ||
GIT_TAG ${OCL_LOADER_TAG} | ||
) | ||
|
||
FetchContent_MakeAvailable(ocl-icd) | ||
endif() | ||
set(OpenCL_LIBRARY OpenCL::OpenCL CACHE PATH "" FORCE) | ||
else() | ||
message(STATUS | ||
"Using OpenCL ICD Loader at ${OpenCL_LIBRARY}") | ||
endif() | ||
|
||
add_library(OpenCL-Headers INTERFACE) | ||
target_include_directories(OpenCL-Headers INTERFACE ${OpenCL_INCLUDE_DIR}) | ||
target_compile_definitions(OpenCL-Headers INTERFACE -DCL_TARGET_OPENCL_VERSION=300 -DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1) | ||
|
||
set(OpenCL_FOUND ${OpenCL_FOUND} CACHE BOOL INTERNAL) |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.