mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-21 22:32:57 -06:00
Merge pull request #5793 from kjetilly/opencl_optional
Make OpenCL optional
This commit is contained in:
commit
d0eba9ffe2
@ -37,6 +37,7 @@ option(USE_TRACY_PROFILER "Enable tracy profiling" OFF)
|
||||
option(CONVERT_CUDA_TO_HIP "Convert CUDA code to HIP (to run on AMD cards)" OFF)
|
||||
option(USE_HYPRE "Use the Hypre library for linear solvers?" OFF)
|
||||
set(OPM_COMPILE_COMPONENTS "2;3;4;5;6;7" CACHE STRING "The components to compile support for")
|
||||
option(USE_OPENCL "Enable OpenCL support?" ON)
|
||||
|
||||
# Ensure OPM_COMPILE_COMPONENTS is a list of at least one element
|
||||
if(OPM_COMPILE_COMPONENTS STREQUAL "")
|
||||
@ -222,41 +223,43 @@ if(CUDA_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(OpenCL)
|
||||
if (USE_OPENCL)
|
||||
find_package(OpenCL)
|
||||
|
||||
if(OpenCL_FOUND)
|
||||
# the current OpenCL implementation relies on cl2.hpp, not cl.hpp
|
||||
# make sure it is available, otherwise disable OpenCL
|
||||
find_file(CL2_HPP CL/cl2.hpp HINTS ${OpenCL_INCLUDE_DIRS})
|
||||
if(CL2_HPP)
|
||||
set(HAVE_OPENCL 1)
|
||||
include_directories(${OpenCL_INCLUDE_DIRS})
|
||||
find_file(OPENCL_HPP CL/opencl.hpp HINTS ${OpenCL_INCLUDE_DIRS})
|
||||
if(OPENCL_HPP)
|
||||
set(HAVE_OPENCL_HPP 1)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING " OpenCL was found, but this version of opm-simulators relies on CL/cl2.hpp, which implements OpenCL 1.0, 1.1 and 1.2.\n Deactivating OpenCL")
|
||||
set(OpenCL_FOUND OFF)
|
||||
set(OPENCL_FOUND OFF)
|
||||
endif()
|
||||
if(USE_CHOW_PATEL_ILU)
|
||||
add_compile_options(-DCHOW_PATEL=1)
|
||||
if(USE_CHOW_PATEL_ILU_GPU)
|
||||
add_compile_options(-DCHOW_PATEL_GPU=1)
|
||||
if(USE_CHOW_PATEL_ILU_GPU_PARALLEL)
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=1)
|
||||
else()
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=0)
|
||||
if(OpenCL_FOUND)
|
||||
# the current OpenCL implementation relies on cl2.hpp, not cl.hpp
|
||||
# make sure it is available, otherwise disable OpenCL
|
||||
find_file(CL2_HPP CL/cl2.hpp HINTS ${OpenCL_INCLUDE_DIRS})
|
||||
if(CL2_HPP)
|
||||
set(HAVE_OPENCL 1)
|
||||
include_directories(${OpenCL_INCLUDE_DIRS})
|
||||
find_file(OPENCL_HPP CL/opencl.hpp HINTS ${OpenCL_INCLUDE_DIRS})
|
||||
if(OPENCL_HPP)
|
||||
set(HAVE_OPENCL_HPP 1)
|
||||
endif()
|
||||
else()
|
||||
add_compile_options(-DCHOW_PATEL_GPU=0)
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=0)
|
||||
message(WARNING " OpenCL was found, but this version of opm-simulators relies on CL/cl2.hpp, which implements OpenCL 1.0, 1.1 and 1.2.\n Deactivating OpenCL")
|
||||
set(OpenCL_FOUND OFF)
|
||||
set(OPENCL_FOUND OFF)
|
||||
endif()
|
||||
if(USE_CHOW_PATEL_ILU)
|
||||
add_compile_options(-DCHOW_PATEL=1)
|
||||
if(USE_CHOW_PATEL_ILU_GPU)
|
||||
add_compile_options(-DCHOW_PATEL_GPU=1)
|
||||
if(USE_CHOW_PATEL_ILU_GPU_PARALLEL)
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=1)
|
||||
else()
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=0)
|
||||
endif()
|
||||
else()
|
||||
add_compile_options(-DCHOW_PATEL_GPU=0)
|
||||
add_compile_options(-DCHOW_PATEL_GPU_PARALLEL=0)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(USE_CHOW_PATEL_ILU)
|
||||
message(FATAL_ERROR " CHOW_PATEL_ILU only works for openclSolver, but OpenCL was not found")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(USE_CHOW_PATEL_ILU)
|
||||
message(FATAL_ERROR " CHOW_PATEL_ILU only works for openclSolver, but OpenCL was not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user