Closed dilippuri closed 1 year ago
I already have a hotfix internally, but I would suggest revamping the dependency management for various reasons. (It seems brittle and bugged to me. For eg. you expect to pick up the CLHPP headers from an install location, yet you never invoke the install target on it.)
I will elaborate in more detail once I get the time.
@krrishnarraj First of all let me congratulate you on yout project, super helpful. Then again, I wanted to reflect a little more in depth to @dilippuri's issue on building clpeak.
The OpenCL work-group would like to improve the developer UX regarding consuming OpenCL. Part of that effort is providing a more modern and robust way to detect OpenCL development packages. You can read more on the new CMake build system support in an incoming PR to the OpenCL-Guide. (I intended it as an overview to where we are and how we got here.) Another part of this effort is the 1st party, Khronos-hosted OpenCL-SDK. In essence, it is growing to be the "one stop shop" for OpenCL developers, and even in it's current incarnation it takes most of the tedium out of getting the C/C++ headers and an ICD loader. The OpenCL-SDK is a "superproject" acting as glue between the various components of the OpenCL ecosystem. The headers, the ICD Loader and other parts ideally could be one monorepo, and while other projects like LLVM have made the jump to becoming a monorepo (as nobody really builds their components in isolation), OpenCL has decided to keep it's project structure. The build instructions on the ICD-Loader for eg. do claim that it's possible to build everything in isolation, most users will be looking for the whole package built uniformly from upstream components: enter OpenCL-SDK.
Having that said, the current issue at hand is that the dep management built into BuildIcd.cmake
and BuildCLHPP.cmake
relies on some existing inconsistent behavior (our bad). While I did provide a hotfix (can be found here) I would suggest going forward to adopt in the homebrewed dep management for components to be picking up each other via the new Package Config style, as that is more robust and less prone to errors.
As per "modern" CMake standards, the de facto interface of a project's build looks like:
cmake -S Source/clpeak -B Build/clpeak
cmake --build Build/clpeak
ctest --test-dir Build/clpeak
cmake --install Build/clpeak --prefix Install/clpeak
Configure, build, test, install. (Depening on CMake version, CLI may slightly differ.) This interface is the recommendation of others using CMake more heavily than I and is also the workflow laid out by ExternalProject, the module being used by clpeak too. (This module exists since CMake 3.0, so as of 2014 this is the typical CMake project interface.)
The OpenCL-SDK can give you all the development files with nothing else with just one build:
git clone --recursive --depth 1 https://github.com/KhronosGroup/OpenCL-SDK.git
cmake -G "Ninja" -S .\OpenCL-SDK\ -B .\OpenCL-SDK\build -D BUILD_TESTING=OFF -D BUILD_DOCS=OFF -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF -D OPENCL_SDK_BUILD_SAMPLES=OFF
cmake --build .\OpenCL-SDK\build\
cmake --install .\OpenCL-SDK\build\ .\OpenCL-SDK\install
-- Install configuration: "Debug"
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCL/OpenCLConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCL/OpenCLConfigVersion.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_d3d10.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_d3d11.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_dx9_media_sharing.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_dx9_media_sharing_intel.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_egl.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_ext.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_ext_intel.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_gl.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_gl_ext.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_half.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_icd.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_layer.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_platform.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_va_api_media_sharing_intel.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl_version.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/opencl.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeaders/OpenCLHeadersTargets.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeaders/OpenCLHeadersConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeaders/OpenCLHeadersConfigVersion.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/lib/OpenCL.lib
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/bin/OpenCL.dll
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLICDLoader/OpenCLICDLoaderTargets.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLICDLoader/OpenCLICDLoaderTargets-debug.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLICDLoader/OpenCLICDLoaderConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLICDLoader/OpenCLICDLoaderConfigVersion.cmake
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/lib/OpenCL.lib
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/bin/OpenCL.dll
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/cl2.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/opencl.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeadersCpp/OpenCLHeadersCppTargets.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeadersCpp/OpenCLHeadersCppConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLHeadersCpp/OpenCLHeadersCppConfigVersion.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/lib/OpenCLUtils.lib
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/bin/OpenCLUtils.dll
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Context.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Context.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Detail.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Device.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Error.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Error.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/ErrorCodes.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Event.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Event.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/File.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/File.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/InteropContext.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Platform.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Utils.h
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Utils.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtils/OpenCLUtilsTargets.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtils/OpenCLUtilsTargets-debug.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtils/OpenCLUtilsConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtils/OpenCLUtilsConfigVersion.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/lib/OpenCLUtilsCpp.lib
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/bin/OpenCLUtilsCpp.dll
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Context.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Context.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Detail.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Device.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Error.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Error.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/ErrorCodes.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Event.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Event.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/File.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/File.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/InteropContext.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Platform.hpp
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Utils.h
-- Up-to-date: C:/Users/mate/Desktop/.\OpenCL-SDK\install/include/CL/Utils/Utils.hpp
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtilsCpp/OpenCLUtilsCppTargets.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtilsCpp/OpenCLUtilsCppTargets-debug.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtilsCpp/OpenCLUtilsCppConfig.cmake
-- Installing: C:/Users/mate/Desktop/.\OpenCL-SDK\install/share/cmake/OpenCLUtilsCpp/OpenCLUtilsCppConfigVersion.cmake
As you can see, when one opts out of all the optional components, it's just a minimal SDK. (In the future we'll further reduce the install size by adding the option to opt-out of OpenCLUtils.dll and OpenCLUtilsCpp.dll, which are two utility libraries for third-parties to use, documented here.)
In the future, I would advise adding the OpenCL-SDK using ExternalProject_Add
, as it will provide better UX as opposed to building the components in isolation. In the coming weeks I intend on adding a little more polish, like removing the "non-standard" -D BUILD_TESTS=OFF
which comes from CLHPP and should be something along the lines of what the ICD-Loader is doing. The SDK will continue to receive polish to make it even easier to use.
Hope this helps and gives some clarity.
On it
Hi, just wanted to confirm: can this issue be closed now? Thanks!
Hello! We found this issue as part of a recent issue scrub and we believe this issue can be closed. Please let us know if it should be re-opened - thanks!
Failing case: `$ cat cmake/BuildCLHpp.cmake
set(CLHPP_ROOT "${CMAKE_CURRENT_BINARY_DIR}/clhpp_install")
set(CMAKE_LIST_CONTENT " cmake_minimum_required(VERSION 3.5) include(ExternalProject)
ExternalProject_add( hpp_headers PREFIX hpp GIT_REPOSITORY https://github.com/khronosgroup/OpenCL-CLHPP GIT_TAG master GIT_SHALLOW 1 GIT_PROGRESS 1 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CLHPP_ROOT} -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF ) ")
set(DEPS "${CMAKE_CURRENT_BINARY_DIR}/clhpp") set(DEPS_BUILD "${DEPS}/build") file(MAKE_DIRECTORY ${DEPS} ${DEPS_BUILD}) file(WRITE "${DEPS}/CMakeLists.txt" "${CMAKE_LIST_CONTENT}") execute_process(WORKING_DIRECTORY "${DEPS_BUILD}" COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} ..) execute_process(WORKING_DIRECTORY "${DEPS_BUILD}" COMMAND ${CMAKE_COMMAND} --build .) ` Passing Case:
`$ cat cmake/BuildCLHpp.cmake
set(CLHPP_ROOT "${CMAKE_CURRENT_BINARY_DIR}/clhpp_install")
set(CMAKE_LIST_CONTENT " cmake_minimum_required(VERSION 3.5) include(ExternalProject)
ExternalProject_add( hpp_headers PREFIX hpp GIT_REPOSITORY https://github.com/MathiasMagnus/OpenCL-CLHPP GIT_TAG master GIT_SHALLOW 1 GIT_PROGRESS 1 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CLHPP_ROOT} -DCMAKE_BUILD_TYPE=Release -DBUILD_DOCS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF ) ")
set(DEPS "${CMAKE_CURRENT_BINARY_DIR}/clhpp") set(DEPS_BUILD "${DEPS}/build") file(MAKE_DIRECTORY ${DEPS} ${DEPS_BUILD}) file(WRITE "${DEPS}/CMakeLists.txt" "${CMAKE_LIST_CONTENT}") execute_process(WORKING_DIRECTORY "${DEPS_BUILD}" COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} ..) execute_process(WORKING_DIRECTORY "${DEPS_BUILD}" COMMAND ${CMAKE_COMMAND} --build .) `
@bashbaug, @MathiasMagnus could anyone help here pls?
Cloning into 'hpp_headers'... remote: Enumerating objects: 556, done. remote: Counting objects: 100% (556/556), done. remote: Compressing objects: 100% (340/340), done. remote: Total 556 (delta 302), reused 359 (delta 206), pack-reused 0 Receiving objects: 100% (556/556), 815.05 KiB | 703.00 KiB/s, done. Resolving deltas: 100% (302/302), done. Already on 'master' Your branch is up to date with 'origin/master'. Submodule 'external/CMock' (https://github.com/ThrowTheSwitch/CMock) registered for path 'external/CMock' Submodule 'external/Unity' (https://github.com/ThrowTheSwitch/Unity) registered for path 'external/Unity' Cloning into '/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers/external/CMock'... Cloning into '/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers/external/Unity'... Submodule path 'external/CMock': checked out '7cc41ddfdd07dc5eb8359d278f439f14031d64ad' Submodule 'vendor/c_exception' (https://github.com/throwtheswitch/cexception.git) registered for path 'external/CMock/vendor/c_exception' Submodule 'vendor/unity' (https://github.com/throwtheswitch/unity.git) registered for path 'external/CMock/vendor/unity' Cloning into '/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers/external/CMock/vendor/c_exception'... Cloning into '/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers/external/CMock/vendor/unity'... Submodule path 'external/CMock/vendor/c_exception': checked out 'dce9e8b26f2179439002e02d691429e81a32b6c0' Submodule 'vendor/unity' (https://github.com/throwtheswitch/unity.git) registered for path 'external/CMock/vendor/c_exception/vendor/unity' Cloning into '/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers/external/CMock/vendor/c_exception/vendor/unity'... Submodule path 'external/CMock/vendor/c_exception/vendor/unity': checked out '2c7629a0ae90ffe991b5fd08e4db8672f72ed64c' Submodule path 'external/CMock/vendor/unity': checked out '031f3bbe45f8adf504ca3d13e6f093869920b091' Submodule path 'external/Unity': checked out '7d2bf62b7e6afaf38153041a9d53c21aeeca9a25' [ 37%] No patch step for 'hpp_headers' [ 50%] Performing update step for 'hpp_headers' Current branch master is up to date. [ 62%] Performing configure step for 'hpp_headers' -- The CXX compiler identification is GNU 9.3.0 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:43 (find_package): By not providing "FindOpenCLHeaders.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "OpenCLHeaders", but CMake did not find one.
Could not find a package configuration file provided by "OpenCLHeaders" with any of the following names:
Add the installation prefix of "OpenCLHeaders" to CMAKE_PREFIX_PATH or set "OpenCLHeaders_DIR" to a directory containing one of the above files. If "OpenCLHeaders" provides a separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred! See also "/data/dilippur/clpeak/build/clhpp/build/hpp/src/hpp_headers-build/CMakeFiles/CMakeOutput.log". make[2]: [CMakeFiles/hpp_headers.dir/build.make:107: hpp/src/hpp_headers-stamp/hpp_headers-configure] Error 1 make[1]: [CMakeFiles/Makefile2:76: CMakeFiles/hpp_headers.dir/all] Error 2 make: *** [Makefile:84: all] Error 2 -- Selected OpenCL includes from /usr/include;/data/dilippur/clpeak/build/clhpp_install/include -- Selected OpenCL lib /usr/lib/x86_64-linux-gnu/libOpenCL.so -- Configuring done -- Generating done -- Build files have been written to: /data/dilippur/clpeak/build