2024-11-04 03:47:34 -06:00
|
|
|
set(GPUBRIDGE_DIR opm/simulators/linalg/gpubridge)
|
|
|
|
set(KERNELS_DIR ${GPUBRIDGE_DIR}/opencl/kernels)
|
2021-12-10 05:17:19 -06:00
|
|
|
|
2021-12-22 01:16:23 -06:00
|
|
|
option(DEBUG_OPENCL_KERNELS_INTEL "Run ocloc to check kernel (works only on Intel)" OFF)
|
|
|
|
if(DEBUG_OPENCL_KERNELS_INTEL)
|
|
|
|
set(DEBUG_OPENCL_DIR ${KERNELS_DIR}/.debug)
|
2021-12-10 05:17:19 -06:00
|
|
|
|
|
|
|
execute_process(
|
2021-12-22 01:16:23 -06:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEBUG_OPENCL_DIR}
|
2021-12-10 05:17:19 -06:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CL_SRC_FILE ${PROJECT_BINARY_DIR}/clSources.cpp)
|
|
|
|
file(WRITE ${CL_SRC_FILE} "// This file is auto-generated. Do not edit!\n\n")
|
2022-01-11 13:08:25 -06:00
|
|
|
file(APPEND ${CL_SRC_FILE} "#include <config.h>\n\n")
|
2024-11-04 03:47:34 -06:00
|
|
|
file(APPEND ${CL_SRC_FILE} "#include <${GPUBRIDGE_DIR}/opencl/openclKernels.hpp>\n\n")
|
2021-12-10 05:17:19 -06:00
|
|
|
file(APPEND ${CL_SRC_FILE} "namespace Opm\{\n\n")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "namespace Accelerator\{\n\n")
|
|
|
|
|
|
|
|
file(GLOB CL_LIST "${KERNELS_DIR}/*.cl")
|
|
|
|
|
|
|
|
if(USE_CHOW_PATEL_ILU)
|
|
|
|
list(REMOVE_ITEM CL_LIST "${PROJECT_SOURCE_DIR}/${KERNELS_DIR}/ILU_apply1_fm.cl")
|
|
|
|
list(REMOVE_ITEM CL_LIST "${PROJECT_SOURCE_DIR}/${KERNELS_DIR}/ILU_apply2_fm.cl")
|
|
|
|
else()
|
|
|
|
list(REMOVE_ITEM CL_LIST "${PROJECT_SOURCE_DIR}/${KERNELS_DIR}/ILU_apply1.cl")
|
|
|
|
list(REMOVE_ITEM CL_LIST "${PROJECT_SOURCE_DIR}/${KERNELS_DIR}/ILU_apply2.cl")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(CL ${CL_LIST})
|
|
|
|
get_filename_component(FNAME ${CL} NAME_WE)
|
|
|
|
|
2024-04-15 09:45:13 -05:00
|
|
|
file(APPEND ${CL_SRC_FILE} "template<> const std::string OpenclKernels<double>::${FNAME}_str = R\"\( \n")
|
2021-12-10 05:17:19 -06:00
|
|
|
file(READ "${CL}" CL_CONTENT)
|
|
|
|
file(APPEND ${CL_SRC_FILE} "${CL_CONTENT}")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "\)\"; \n\n")
|
2024-04-16 06:13:36 -05:00
|
|
|
if(BUILD_FLOW_FLOAT_VARIANTS)
|
|
|
|
string(REPLACE double float CL_CONTENT "${CL_CONTENT}")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "template<> const std::string OpenclKernels<float>::${FNAME}_str = R\"\( \n")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "${CL_CONTENT}")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "\)\"; \n\n")
|
|
|
|
endif()
|
2021-12-10 05:17:19 -06:00
|
|
|
|
2021-12-22 01:16:23 -06:00
|
|
|
if(DEBUG_OPENCL_KERNELS_INTEL)
|
2021-12-10 05:17:19 -06:00
|
|
|
execute_process(
|
2021-12-22 01:16:23 -06:00
|
|
|
COMMAND ocloc -file ${CL} -device kbl -out_dir ${DEBUG_OPENCL_DIR}
|
2021-12-10 05:17:19 -06:00
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
file(APPEND ${CL_SRC_FILE} "\}\n")
|
|
|
|
file(APPEND ${CL_SRC_FILE} "\}")
|
|
|
|
|
2021-12-22 01:16:23 -06:00
|
|
|
if(DEBUG_OPENCL_KERNELS_INTEL)
|
2021-12-10 05:17:19 -06:00
|
|
|
file(REMOVE_RECURSE ${DEBUG_DIR})
|
|
|
|
endif()
|