Skip to content

Conversation

@jjolly
Copy link
Contributor

@jjolly jjolly commented Feb 1, 2023

During the initial CMake configuration for this project, the OpenCL header would be detected, but the proper configuration would not be set for the build. This caused a failed attempt to build /stencils/3axis_cl.cpp because CL/opencl.hpp could not be found.

This is resolved when CUDA is installed. When CMake detects the CUDA compiler and headers, the correct environment is set for OpenCL as well. A change was made to only attempt detection of OpenCL when CUDA was found.

This is likely a problem with the OpenCL detection within CMake and optimally would be fixed in that package. Combined with the fact that bricklib OpenCL currently only works with CUDA, the best place to make this fix was within this library.

During the initial CMake configuration for this project, the OpenCL header
would be detected, but the proper configuration would not be set for the build.
This caused a failed attempt to build /stencils/3axis_cl.cpp because
CL/opencl.hpp could not be found.

This is resolved when CUDA is installed. When CMake detects the CUDA compiler
and headers, the correct environment is set for OpenCL as well. A change was
made to only attempt detection of OpenCL when CUDA was found.

This is likely a problem with the OpenCL detection within CMake and optimally
would be fixed in that package. Combined with the fact that bricklib OpenCL
currently only works with CUDA, the best place to make this fix was within this
library.
@jjolly
Copy link
Contributor Author

jjolly commented Feb 1, 2023

This was discovered via Spack on the UofU CHPC cluster. Seems the OpenCL headers can be found under the general include directories. This is a bad configuration for the CHPC IMO, but this fix will work even with bad configurations.

@ztuowen
Copy link
Member

ztuowen commented Feb 2, 2023

This is not the right fix. OpenCL is more useful for Intel platforms than NVIDIA ones. This will break Intel-only platforms.

What is the opencl compiler that CHPC uses? It does seems strange that both compiler/header is available and CMake report that it cannot be found.

  • Can you use a newer version of CMake to see if the problem persists?
  • What's the include path set by find OpenCL, this in CMake
  • Can you run the compiled OpenCL example?

I suspect that for build + install it does not need to compile the examples, better if we just gate the examples with option(ENABLE_EXAMPLE) for Spack builds.

@ztuowen
Copy link
Member

ztuowen commented Feb 2, 2023

It also possible that find OpenCL only returns if the c headers are found. We could check for opencl.hpp using find_path and with OpenCL_INCLUDE_DIRS as hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants