opencl: make OpenCL required, remove redundant lib and inc directories
* `ggml-base`, `..` and `.` are added by `ggml_add_backend_library`
This commit is contained in:
parent
97a12703dd
commit
22411ab58f
1 changed files with 143 additions and 149 deletions
|
@ -1,30 +1,27 @@
|
||||||
|
find_package(OpenCL REQUIRED)
|
||||||
|
find_package(Python3 REQUIRED)
|
||||||
|
|
||||||
find_package(OpenCL)
|
set(TARGET_NAME ggml-opencl)
|
||||||
|
|
||||||
if (OpenCL_FOUND)
|
ggml_add_backend_library(${TARGET_NAME}
|
||||||
find_package(Python3 REQUIRED)
|
|
||||||
|
|
||||||
set(TARGET_NAME ggml-opencl)
|
|
||||||
|
|
||||||
ggml_add_backend_library(${TARGET_NAME}
|
|
||||||
ggml-opencl.cpp
|
ggml-opencl.cpp
|
||||||
../../include/ggml-opencl.h)
|
../../include/ggml-opencl.h)
|
||||||
target_link_libraries(${TARGET_NAME} PRIVATE ggml-base ${OpenCL_LIBRARIES})
|
target_link_libraries(${TARGET_NAME} PRIVATE ${OpenCL_LIBRARIES})
|
||||||
target_include_directories(${TARGET_NAME} PRIVATE . .. ${OpenCL_INCLUDE_DIRS})
|
target_include_directories(${TARGET_NAME} PRIVATE ${OpenCL_INCLUDE_DIRS})
|
||||||
|
|
||||||
if (GGML_OPENCL_PROFILING)
|
if (GGML_OPENCL_PROFILING)
|
||||||
message(STATUS "OpenCL profiling enabled (increases CPU overhead)")
|
message(STATUS "OpenCL profiling enabled (increases CPU overhead)")
|
||||||
add_compile_definitions(GGML_OPENCL_PROFILING)
|
add_compile_definitions(GGML_OPENCL_PROFILING)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
add_compile_definitions(GGML_OPENCL_SOA_Q)
|
add_compile_definitions(GGML_OPENCL_SOA_Q)
|
||||||
|
|
||||||
if (GGML_OPENCL_USE_ADRENO_KERNELS)
|
if (GGML_OPENCL_USE_ADRENO_KERNELS)
|
||||||
message(STATUS "OpenCL will use matmul kernels optimized for Adreno")
|
message(STATUS "OpenCL will use matmul kernels optimized for Adreno")
|
||||||
add_compile_definitions(GGML_OPENCL_USE_ADRENO_KERNELS)
|
add_compile_definitions(GGML_OPENCL_USE_ADRENO_KERNELS)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (GGML_OPENCL_EMBED_KERNELS)
|
if (GGML_OPENCL_EMBED_KERNELS)
|
||||||
add_compile_definitions(GGML_OPENCL_EMBED_KERNELS)
|
add_compile_definitions(GGML_OPENCL_EMBED_KERNELS)
|
||||||
|
|
||||||
set(OPENCL_CL_SOURCE_EMBED "${CMAKE_BINARY_DIR}/autogenerated/ggml-opencl.cl.h")
|
set(OPENCL_CL_SOURCE_EMBED "${CMAKE_BINARY_DIR}/autogenerated/ggml-opencl.cl.h")
|
||||||
|
@ -50,7 +47,7 @@ if (OpenCL_FOUND)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/kernels/ggml-opencl.cl
|
${CMAKE_CURRENT_SOURCE_DIR}/kernels/ggml-opencl.cl
|
||||||
${OPENCL_CL_SOURCE_EMBED}
|
${OPENCL_CL_SOURCE_EMBED}
|
||||||
DEPENDS kernels/ggml-opencl.cl ${EMBED_KERNEL_SCRIPT}
|
DEPENDS kernels/ggml-opencl.cl ${EMBED_KERNEL_SCRIPT}
|
||||||
COMMENT "Generate ggml-opencl2.cl.h"
|
COMMENT "Generate ggml-opencl.cl.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -135,7 +132,7 @@ if (OpenCL_FOUND)
|
||||||
${OPENCL_TRANSPOSE_16_SOURCE_EMBED}
|
${OPENCL_TRANSPOSE_16_SOURCE_EMBED}
|
||||||
${OPENCL_TRANSPOSE_32_SOURCE_EMBED}
|
${OPENCL_TRANSPOSE_32_SOURCE_EMBED}
|
||||||
${OPENCL_TRANSPOSE_32_16_SOURCE_EMBED})
|
${OPENCL_TRANSPOSE_32_16_SOURCE_EMBED})
|
||||||
else ()
|
else ()
|
||||||
# copy ggml-opencl.cl to bin directory
|
# copy ggml-opencl.cl to bin directory
|
||||||
configure_file(kernels/ggml-opencl.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl.cl COPYONLY)
|
configure_file(kernels/ggml-opencl.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl.cl COPYONLY)
|
||||||
configure_file(kernels/ggml-opencl_mm.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_mm.cl COPYONLY)
|
configure_file(kernels/ggml-opencl_mm.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_mm.cl COPYONLY)
|
||||||
|
@ -147,7 +144,4 @@ if (OpenCL_FOUND)
|
||||||
configure_file(kernels/ggml-opencl_transpose_16.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_16.cl COPYONLY)
|
configure_file(kernels/ggml-opencl_transpose_16.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_16.cl COPYONLY)
|
||||||
configure_file(kernels/ggml-opencl_transpose_32.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_32.cl COPYONLY)
|
configure_file(kernels/ggml-opencl_transpose_32.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_32.cl COPYONLY)
|
||||||
configure_file(kernels/ggml-opencl_transpose_32_16.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_32_16.cl COPYONLY)
|
configure_file(kernels/ggml-opencl_transpose_32_16.cl ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ggml-opencl_transpose_32_16.cl COPYONLY)
|
||||||
endif ()
|
|
||||||
else ()
|
|
||||||
message(WARNING "OpenCL not found")
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue