summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorJohn Jolly <jjolly@cs.utah.edu>2023-04-28 03:37:22 -0600
committerGitHub <noreply@github.com>2023-04-28 11:37:22 +0200
commit076660804d9129529f855f2fd5fdcef8acfe2510 (patch)
tree05e650f8bde6bd19b65aacfc0c0c860c8cf0c2d9 /var
parente57db5c5282dddfc5eec4d5d373fa23f262534cc (diff)
downloadspack-076660804d9129529f855f2fd5fdcef8acfe2510.tar.gz
spack-076660804d9129529f855f2fd5fdcef8acfe2510.tar.bz2
spack-076660804d9129529f855f2fd5fdcef8acfe2510.tar.xz
spack-076660804d9129529f855f2fd5fdcef8acfe2510.zip
bricks: Fix package to properly find spack opencl-clhpp (#37239)
The bricks package uses header from the opencl-clhpp package when built with the cuda variant activated. In order to find the header files, the bricks CMakeLists.txt uses the `find_package(OpenCL 2.0)` statement. The CMake FindOpenCL module searches several paths to find the header files. Eventually it will search for header files in the local /usr/include directories. If OpenCL headers are found, but CUDA is not installed locally, then the build will fail. One of the CMake variables searched for a path to the OpenCL headers is OCL_ROOT. This fix utilizes the OCL_ROOT variable to identify the correct path to the install opencl-clhpp package within Spack. Also, if the cuda variant is not used, then the OpenCL build is disabled to prevent a build failure due to improperly-identified locally-installed OpenCL header files. The default behavior of the build process has not changed. An external variable definitions must be made to activate these features. Specifically, to disable the OpenCL build, this flag must be provided to CMake: -DBRICK_USE_OPENCL=OFF The Spack build process explicitly uses this option unless the cuda variant is specified. If the cuda variant is specified, then the BRICK_USE_OPENCL variable is set to ON and the OCL_ROOT variable is set to the path of the opencl-clhpp include directory.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/bricks/bricks-cmakelists-option-opencl.patch17
-rw-r--r--var/spack/repos/builtin/packages/bricks/package.py7
2 files changed, 22 insertions, 2 deletions
diff --git a/var/spack/repos/builtin/packages/bricks/bricks-cmakelists-option-opencl.patch b/var/spack/repos/builtin/packages/bricks/bricks-cmakelists-option-opencl.patch
new file mode 100644
index 0000000000..8b55d6e707
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bricks/bricks-cmakelists-option-opencl.patch
@@ -0,0 +1,17 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 58dcbd4..f0658eb 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -43,7 +43,11 @@ endif()
+
+ find_package(OpenMP REQUIRED)
+ find_package(MPI)
+-find_package(OpenCL 2.0)
++
++option(BRICK_USE_OPENCL "Use OpenCL targets" ON)
++if (BRICK_USE_OPENCL)
++ find_package(OpenCL 2.0)
++endif()
+
+ option(BRICK_USE_MEMFD "Using memfd instead of shm_open, supported on Linux >= 3.17 with \"CONFIG_MEMFD_CREATE\"" OFF)
+ if (BRICK_USE_MEMFD)
diff --git a/var/spack/repos/builtin/packages/bricks/package.py b/var/spack/repos/builtin/packages/bricks/package.py
index e3419602cf..d20d9f170f 100644
--- a/var/spack/repos/builtin/packages/bricks/package.py
+++ b/var/spack/repos/builtin/packages/bricks/package.py
@@ -35,10 +35,13 @@ class Bricks(CMakePackage):
depends_on("cuda", when="+cuda")
depends_on("mpi")
+ patch("bricks-cmakelists-option-opencl.patch")
+
def cmake_args(self):
"""CMake arguments for configure stage"""
- args = []
-
+ args = [self.define_from_variant("BRICK_USE_OPENCL", "cuda")]
+ if "+cuda" in self.spec:
+ args.append(f"-DOCL_ROOT:STRING={self.spec['opencl-clhpp'].prefix}")
return args
def flag_handler(self, name, flags):